From 43a6a6d58cdfe7cec9e4bd8a0809b13d2566bdee Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 9 Sep 2011 13:56:41 +0200 Subject: [PATCH] QmlJS: Improve import error messages. Change-Id: Ief305b787fbc4577acfdec41083bc72e178db46d Reviewed-on: http://codereview.qt-project.org/4537 Reviewed-by: Thomas Hartmann --- src/libs/qmljs/qmljslink.cpp | 9 +++++-- src/plugins/qmljstools/qmljsplugindumper.cpp | 40 +++++++++++++++++----------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 62cec1aaeb..45eea43e6f 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -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) { diff --git a/src/plugins/qmljstools/qmljsplugindumper.cpp b/src/plugins/qmljstools/qmljsplugindumper.cpp index f27373e4b2..3983033682 100644 --- a/src/plugins/qmljstools/qmljsplugindumper.cpp +++ b/src/plugins/qmljstools/qmljsplugindumper.cpp @@ -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 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; } -- 2.11.0