forked from qt-creator/qt-creator
		
	QmlJS: Improve error reporting for failed plugin dumps.
Reviewed-by: Erik Verbruggen
This commit is contained in:
		| @@ -356,6 +356,7 @@ void Document::extractPragmas(QString *source) | ||||
|  | ||||
| LibraryInfo::LibraryInfo() | ||||
|     : _valid(false) | ||||
|     , _dumpStatus(DumpNotStartedOrRunning) | ||||
| { | ||||
| } | ||||
|  | ||||
| @@ -363,7 +364,7 @@ LibraryInfo::LibraryInfo(const QmlDirParser &parser) | ||||
|     : _valid(true) | ||||
|     , _components(parser.components()) | ||||
|     , _plugins(parser.plugins()) | ||||
|     , _dumped(false) | ||||
|     , _dumpStatus(DumpNotStartedOrRunning) | ||||
| { | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -119,12 +119,22 @@ private: | ||||
|  | ||||
| class QMLJS_EXPORT LibraryInfo | ||||
| { | ||||
| public: | ||||
|     enum DumpStatus { | ||||
|         DumpNotStartedOrRunning, | ||||
|         DumpDone, | ||||
|         DumpError | ||||
|     }; | ||||
|  | ||||
| private: | ||||
|     bool _valid; | ||||
|     QList<QmlDirParser::Component> _components; | ||||
|     QList<QmlDirParser::Plugin> _plugins; | ||||
|     typedef QList<const Interpreter::FakeMetaObject *> FakeMetaObjectList; | ||||
|     FakeMetaObjectList _metaObjects; | ||||
|     bool _dumped; | ||||
|  | ||||
|     DumpStatus _dumpStatus; | ||||
|     QString _dumpError; | ||||
|  | ||||
| public: | ||||
|     LibraryInfo(); | ||||
| @@ -146,11 +156,14 @@ public: | ||||
|     bool isValid() const | ||||
|     { return _valid; } | ||||
|  | ||||
|     bool isDumped() const | ||||
|     { return _dumped; } | ||||
|     DumpStatus dumpStatus() const | ||||
|     { return _dumpStatus; } | ||||
|  | ||||
|     void setDumped(bool dumped) | ||||
|     { _dumped = dumped; } | ||||
|     QString dumpError() const | ||||
|     { return _dumpError; } | ||||
|  | ||||
|     void setDumpStatus(DumpStatus dumped, const QString &error = QString()) | ||||
|     { _dumpStatus = dumped; _dumpError = error; } | ||||
| }; | ||||
|  | ||||
| class QMLJS_EXPORT Snapshot | ||||
|   | ||||
| @@ -256,10 +256,17 @@ ObjectValue *Link::importNonFile(Document::Ptr doc, const ImportInfo &importInfo | ||||
|         importFound = true; | ||||
|  | ||||
|         if (!libraryInfo.plugins().isEmpty()) { | ||||
|             if (libraryInfo.metaObjects().isEmpty()) { | ||||
|             if (libraryInfo.dumpStatus() == LibraryInfo::DumpNotStartedOrRunning) { | ||||
|                 ModelManagerInterface *modelManager = ModelManagerInterface::instance(); | ||||
|                 if (modelManager) | ||||
|                     modelManager->loadPluginTypes(libraryPath, importPath, packageName); | ||||
|                 warning(doc, locationFromRange(importInfo.ast()->firstSourceLocation(), | ||||
|                                                importInfo.ast()->lastSourceLocation()), | ||||
|                         tr("Library contains C++ plugins, type dump is in progress.")); | ||||
|             } else if (libraryInfo.dumpStatus() == LibraryInfo::DumpError) { | ||||
|                 error(doc, locationFromRange(importInfo.ast()->firstSourceLocation(), | ||||
|                                              importInfo.ast()->lastSourceLocation()), | ||||
|                       libraryInfo.dumpError()); | ||||
|             } else { | ||||
|                 engine()->cppQmlTypes().load(engine(), libraryInfo.metaObjects()); | ||||
|             } | ||||
| @@ -321,3 +328,11 @@ void Link::error(const Document::Ptr &doc, const AST::SourceLocation &loc, const | ||||
|     if (doc->fileName() == d->doc->fileName()) | ||||
|         d->diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Error, loc, message)); | ||||
| } | ||||
|  | ||||
| void Link::warning(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message) | ||||
| { | ||||
|     Q_D(Link); | ||||
|  | ||||
|     if (doc->fileName() == d->doc->fileName()) | ||||
|         d->diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Warning, loc, message)); | ||||
| } | ||||
|   | ||||
| @@ -73,6 +73,7 @@ private: | ||||
|     void importObject(Bind *bind, const QString &name, Interpreter::ObjectValue *object, NameId *targetNamespace); | ||||
|  | ||||
|     void error(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message); | ||||
|     void warning(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message); | ||||
|  | ||||
| private: | ||||
|     QScopedPointer<LinkPrivate> d_ptr; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user