Commit 43a6a6d5 authored by Christian Kamm's avatar Christian Kamm

QmlJS: Improve import error messages.

Change-Id: Ief305b787fbc4577acfdec41083bc72e178db46d
Reviewed-on: http://codereview.qt-project.org/4537Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 16b4a6fe
......@@ -357,7 +357,12 @@ Import Link::importNonFile(Document::Ptr doc, const ImportInfo &importInfo)
if (!importFound && importInfo.ast()) {
error(doc, locationFromRange(importInfo.ast()->firstSourceLocation(),
importInfo.ast()->lastSourceLocation()),
tr("package not found"));
tr("QML module not found\n\n"
"Import paths:\n"
"%1\n\n"
"For qmake projects, use the QML_IMPORT_PATH variable to add import paths.\n"
"For qmlproject projects, use the importPaths property to add import paths.").arg(
d->importPaths.join(QLatin1String("\n"))));
}
return import;
......@@ -403,7 +408,7 @@ bool Link::importLibrary(Document::Ptr doc,
}
if (errorLoc.isValid()) {
warning(doc, errorLoc,
tr("Library contains C++ plugins, type dump is in progress."));
tr("QML module contains C++ plugins, currently reading type information..."));
}
} else if (libraryInfo.pluginTypeInfoStatus() == LibraryInfo::DumpError
|| libraryInfo.pluginTypeInfoStatus() == LibraryInfo::TypeInfoFileError) {
......
......@@ -220,23 +220,31 @@ void PluginDumper::dumpAllPlugins()
}
}
static QString qmldumpErrorPreamble()
{
return PluginDumper::tr("QML module does not contain information about components contained in plugins.\n"
"See \"Using QML Modules with Plugins\" in the documentation.") + QLatin1String("\n\n");
}
static QString qmldumpErrorMessage(const QString &libraryPath, const QString &error)
{
return PluginDumper::tr("Type dump of QML plugin in %1 failed.\nErrors:\n%2\n").
arg(libraryPath, error);
return qmldumpErrorPreamble() +
PluginDumper::tr("Automatic type dump of QML module in %1 failed.\nErrors:\n%2\n").
arg(libraryPath, error);
}
static QString qmldumpFailedMessage(const QString &error)
static QString qmldumpFailedMessage(const QString &libraryPath, const QString &error)
{
QString firstLines =
QStringList(error.split(QLatin1Char('\n')).mid(0, 10)).join(QLatin1String("\n"));
return PluginDumper::tr("Type dump of C++ plugin failed.\n"
"First 10 lines or errors:\n"
"\n"
"%1"
"\n"
"Check 'General Messages' output pane for details."
).arg(firstLines);
return qmldumpErrorPreamble() +
PluginDumper::tr("Automatic type dump of QML module in %1 failed.\n"
"First 10 lines or errors:\n"
"\n"
"%2"
"\n"
"Check 'General Messages' output pane for details."
).arg(libraryPath, firstLines);
}
static void printParseWarnings(const QString &libraryPath, const QString &warning)
......@@ -279,7 +287,7 @@ void PluginDumper::qmlPluginTypeDumpDone(int exitCode)
Core::MessageManager *messageManager = Core::MessageManager::instance();
const QString errorMessages = process->readAllStandardError();
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, errorMessages));
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, qmldumpFailedMessage(errorMessages));
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, qmldumpFailedMessage(libraryPath, errorMessages));
}
const QByteArray output = process->readAllStandardOutput();
......@@ -288,7 +296,8 @@ void PluginDumper::qmlPluginTypeDumpDone(int exitCode)
QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(output, &error, &warning);
if (exitCode == 0) {
if (!error.isEmpty()) {
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, tr("Type dump of C++ plugin failed. Parse error:\n'%1'").arg(error));
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError,
qmldumpErrorMessage(libraryPath, error));
} else {
libraryInfo.setMetaObjects(objectsList);
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpDone);
......@@ -319,7 +328,7 @@ void PluginDumper::qmlPluginTypeDumpError(QProcess::ProcessError)
if (!libraryPath.isEmpty()) {
const Snapshot snapshot = m_modelManager->snapshot();
LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, qmldumpFailedMessage(errorMessages));
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, qmldumpFailedMessage(libraryPath, errorMessages));
m_modelManager->updateLibraryInfo(libraryPath, libraryInfo);
}
}
......@@ -398,8 +407,9 @@ void PluginDumper::dump(const Plugin &plugin)
return;
libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError,
tr("Could not locate the helper application for dumping type information from C++ plugins.\n"
"Please build the debugging helpers on the Qt version options page."));
qmldumpErrorMessage(plugin.qmldirPath,
tr("Could not locate the helper application for dumping type information from C++ plugins.\n"
"Please build the qmldump applcation on the Qt version options page.")));
m_modelManager->updateLibraryInfo(plugin.qmldirPath, libraryInfo);
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment