Skip to content
Snippets Groups Projects
Commit b102690b authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Bind the reachable documents.

parent fcf67d7d
No related branches found
No related tags found
No related merge requests found
...@@ -203,6 +203,11 @@ QStringList Bind::includedScripts() const ...@@ -203,6 +203,11 @@ QStringList Bind::includedScripts() const
return _includedScripts; return _includedScripts;
} }
QStringList Bind::localImports() const
{
return _localImports;
}
ObjectValue *Bind::switchObjectValue(ObjectValue *newObjectValue) ObjectValue *Bind::switchObjectValue(ObjectValue *newObjectValue)
{ {
ObjectValue *oldObjectValue = _currentObjectValue; ObjectValue *oldObjectValue = _currentObjectValue;
...@@ -216,13 +221,37 @@ ObjectValue *Bind::scopeChainAt(Document::Ptr currentDocument, const Snapshot &s ...@@ -216,13 +221,37 @@ ObjectValue *Bind::scopeChainAt(Document::Ptr currentDocument, const Snapshot &s
Bind *currentBind = 0; Bind *currentBind = 0;
QList<Bind *> binds; QList<Bind *> binds;
Snapshot::const_iterator end = snapshot.end(); QSet<QString> processed;
for (Snapshot::const_iterator iter = snapshot.begin(); iter != end; ++iter) { QStringList todo;
Document::Ptr doc = *iter;
Bind *newBind = new Bind(doc, snapshot, interp); QMultiHash<QString, Document::Ptr> documentByPath;
binds += newBind; foreach (Document::Ptr doc, snapshot)
if (doc == currentDocument) documentByPath.insert(doc->path(), doc);
currentBind = newBind;
todo.append(currentDocument->path());
// Bind the reachable documents.
while (! todo.isEmpty()) {
const QString path = todo.takeFirst();
if (processed.contains(path))
continue;
processed.insert(path);
QStringList localImports;
foreach (Document::Ptr doc, documentByPath.values(path)) {
Bind *newBind = new Bind(doc, snapshot, interp);
binds += newBind;
localImports += newBind->localImports();
if (doc == currentDocument)
currentBind = newBind;
}
localImports.removeDuplicates();
todo += localImports;
} }
LinkImports linkImports; LinkImports linkImports;
...@@ -397,6 +426,12 @@ bool Bind::visit(UiImport *ast) ...@@ -397,6 +426,12 @@ bool Bind::visit(UiImport *ast)
namespaceObject->setProperty(object->qmlTypeName(), object); namespaceObject->setProperty(object->qmlTypeName(), object);
} }
#endif // NO_DECLARATIVE_BACKEND #endif // NO_DECLARATIVE_BACKEND
} else if (ast->fileName) {
QString path = _doc->path();
path += QLatin1Char('/');
path += ast->fileName->asString();
path = QDir::cleanPath(path);
_localImports.append(path);
} }
return false; return false;
......
...@@ -51,6 +51,7 @@ public: ...@@ -51,6 +51,7 @@ public:
virtual ~Bind(); virtual ~Bind();
QStringList includedScripts() const; QStringList includedScripts() const;
QStringList localImports() const;
// ### TODO: This methods should go. Bind each document after parsing, link later. // ### TODO: This methods should go. Bind each document after parsing, link later.
static Interpreter::ObjectValue *scopeChainAt(Document::Ptr currentDocument, static Interpreter::ObjectValue *scopeChainAt(Document::Ptr currentDocument,
...@@ -95,6 +96,7 @@ private: ...@@ -95,6 +96,7 @@ private:
QHash<AST::UiObjectDefinition *, Interpreter::ObjectValue *> _qmlObjectDefinitions; QHash<AST::UiObjectDefinition *, Interpreter::ObjectValue *> _qmlObjectDefinitions;
QHash<AST::UiObjectBinding *, Interpreter::ObjectValue *> _qmlObjectBindings; QHash<AST::UiObjectBinding *, Interpreter::ObjectValue *> _qmlObjectBindings;
QStringList _includedScripts; QStringList _includedScripts;
QStringList _localImports;
friend class LinkImports; friend class LinkImports;
friend class Link; friend class Link;
......
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