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
......@@ -176,6 +176,7 @@ Check::Check(Document::Ptr doc, const Snapshot &snapshot, const QStringList &imp
, _context(&_engine)
, _link(&_context, doc, snapshot, importPaths)
, _scopeBuilder(doc, &_context)
, _ignoreTypeErrors(_context.documentImportsPlugins(_doc.data()))
{
}
......@@ -227,7 +228,8 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
_scopeBuilder.push(ast);
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
// the scope object list
// ### todo: better way?
......
......@@ -72,6 +72,8 @@ private:
ScopeBuilder _scopeBuilder;
QList<DiagnosticMessage> _messages;
bool _ignoreTypeErrors;
};
} // namespace QmlJS
......
......@@ -1448,6 +1448,16 @@ void Context::setProperty(const ObjectValue *object, const QString &name, const
_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)
: _engine(engine)
{
......
......@@ -308,6 +308,9 @@ public:
const Value *property(const ObjectValue *object, const QString &name) const;
void setProperty(const ObjectValue *object, const QString &name, const Value *value);
bool documentImportsPlugins(const Document *doc) const;
void setDocumentImportsPlugins(const Document *doc);
private:
typedef QHash<QString, const Value *> Properties;
......@@ -315,6 +318,7 @@ private:
LookupMode _lookupMode;
QHash<const ObjectValue *, Properties> _properties;
QHash<QString, const ObjectValue *> _typeEnvironments;
QSet<QString> _documentsImportingPlugins;
ScopeChain _scopeChain;
int _qmlScopeObjectIndex;
bool _qmlScopeObjectSet;
......
......@@ -302,6 +302,9 @@ void Link::importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, A
if (!libraryInfo.isValid())
continue;
if (!libraryInfo.plugins().isEmpty())
_context->setDocumentImportsPlugins(doc.data());
QSet<QString> importedTypes;
foreach (const QmlDirParser::Component &component, libraryInfo.components()) {
if (importedTypes.contains(component.typeName))
......
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