Skip to content
Snippets Groups Projects
Commit db2f91ef authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Don't produce Qml type errors if plugins are imported.

Task-number: QTCREATORBUG-1021
Reviewed-by: Erik Verbruggen
parent eae88f02
No related branches found
No related tags found
No related merge requests found
...@@ -176,6 +176,7 @@ Check::Check(Document::Ptr doc, const Snapshot &snapshot, const QStringList &imp ...@@ -176,6 +176,7 @@ Check::Check(Document::Ptr doc, const Snapshot &snapshot, const QStringList &imp
, _context(&_engine) , _context(&_engine)
, _link(&_context, doc, snapshot, importPaths) , _link(&_context, doc, snapshot, importPaths)
, _scopeBuilder(doc, &_context) , _scopeBuilder(doc, &_context)
, _ignoreTypeErrors(_context.documentImportsPlugins(_doc.data()))
{ {
} }
...@@ -227,7 +228,8 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId, ...@@ -227,7 +228,8 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
_scopeBuilder.push(ast); _scopeBuilder.push(ast);
if (! _context.lookupType(_doc.data(), typeId)) { if (! _context.lookupType(_doc.data(), typeId)) {
warning(typeId->identifierToken, tr(Messages::unknown_type)); if (! _ignoreTypeErrors)
error(typeId->identifierToken, tr(Messages::unknown_type));
// suppress subsequent errors about scope object lookup by clearing // suppress subsequent errors about scope object lookup by clearing
// the scope object list // the scope object list
// ### todo: better way? // ### todo: better way?
......
...@@ -72,6 +72,8 @@ private: ...@@ -72,6 +72,8 @@ private:
ScopeBuilder _scopeBuilder; ScopeBuilder _scopeBuilder;
QList<DiagnosticMessage> _messages; QList<DiagnosticMessage> _messages;
bool _ignoreTypeErrors;
}; };
} // namespace QmlJS } // namespace QmlJS
......
...@@ -1448,6 +1448,16 @@ void Context::setProperty(const ObjectValue *object, const QString &name, const ...@@ -1448,6 +1448,16 @@ void Context::setProperty(const ObjectValue *object, const QString &name, const
_properties[object].insert(name, value); _properties[object].insert(name, value);
} }
bool Context::documentImportsPlugins(const Document *doc) const
{
return _documentsImportingPlugins.contains(doc->fileName());
}
void Context::setDocumentImportsPlugins(const Document *doc)
{
_documentsImportingPlugins.insert(doc->fileName());
}
Reference::Reference(Engine *engine) Reference::Reference(Engine *engine)
: _engine(engine) : _engine(engine)
{ {
......
...@@ -308,6 +308,9 @@ public: ...@@ -308,6 +308,9 @@ public:
const Value *property(const ObjectValue *object, const QString &name) const; const Value *property(const ObjectValue *object, const QString &name) const;
void setProperty(const ObjectValue *object, const QString &name, const Value *value); void setProperty(const ObjectValue *object, const QString &name, const Value *value);
bool documentImportsPlugins(const Document *doc) const;
void setDocumentImportsPlugins(const Document *doc);
private: private:
typedef QHash<QString, const Value *> Properties; typedef QHash<QString, const Value *> Properties;
...@@ -315,6 +318,7 @@ private: ...@@ -315,6 +318,7 @@ private:
LookupMode _lookupMode; LookupMode _lookupMode;
QHash<const ObjectValue *, Properties> _properties; QHash<const ObjectValue *, Properties> _properties;
QHash<QString, const ObjectValue *> _typeEnvironments; QHash<QString, const ObjectValue *> _typeEnvironments;
QSet<QString> _documentsImportingPlugins;
ScopeChain _scopeChain; ScopeChain _scopeChain;
int _qmlScopeObjectIndex; int _qmlScopeObjectIndex;
bool _qmlScopeObjectSet; bool _qmlScopeObjectSet;
......
...@@ -302,6 +302,9 @@ void Link::importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, A ...@@ -302,6 +302,9 @@ void Link::importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, A
if (!libraryInfo.isValid()) if (!libraryInfo.isValid())
continue; continue;
if (!libraryInfo.plugins().isEmpty())
_context->setDocumentImportsPlugins(doc.data());
QSet<QString> importedTypes; QSet<QString> importedTypes;
foreach (const QmlDirParser::Component &component, libraryInfo.components()) { foreach (const QmlDirParser::Component &component, libraryInfo.components()) {
if (importedTypes.contains(component.typeName)) if (importedTypes.contains(component.typeName))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment