forked from qt-creator/qt-creator
QmlJS: Speed up Link significantly, provide more info on imports.
Link now caches imports. That means importing the same library (say, Qt) from more than one file no longer creates an importing namespace for each one. Instead, a single one is created for the instance of Link. To make this work, the type environment in ScopeChain has been given its own type: Interpreter::TypeEnvironment. That has the added benefit of being able to carry meta-information about imports. You can use TypeEnvironment::importInfo(qmlComponentName) to get information about the import node that caused the import of the component.
This commit is contained in:
@@ -64,8 +64,6 @@ private:
|
||||
|
||||
void warning(const AST::SourceLocation &loc, const QString &message);
|
||||
void error(const AST::SourceLocation &loc, const QString &message);
|
||||
static AST::SourceLocation locationFromRange(const AST::SourceLocation &start,
|
||||
const AST::SourceLocation &end);
|
||||
|
||||
Document::Ptr _doc;
|
||||
Snapshot _snapshot;
|
||||
@@ -80,6 +78,20 @@ private:
|
||||
|
||||
QMLJS_EXPORT QColor toQColor(const QString &qmlColorString);
|
||||
|
||||
QMLJS_EXPORT AST::SourceLocation locationFromRange(const AST::SourceLocation &start,
|
||||
const AST::SourceLocation &end);
|
||||
QMLJS_EXPORT DiagnosticMessage errorMessage(const AST::SourceLocation &loc,
|
||||
const QString &message);
|
||||
|
||||
template <class T>
|
||||
DiagnosticMessage errorMessage(const T *node, const QString &message)
|
||||
{
|
||||
return DiagnosticMessage(DiagnosticMessage::Error,
|
||||
locationFromRange(node->firstSourceLocation(),
|
||||
node->lastSourceLocation()),
|
||||
message);
|
||||
}
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
#endif // QMLJSCHECK_H
|
||||
|
||||
Reference in New Issue
Block a user