From 4722c6cf844424eb37842413e38f548dc9f1f401 Mon Sep 17 00:00:00 2001
From: Christian Kamm <christian.d.kamm@nokia.com>
Date: Wed, 10 Mar 2010 14:50:56 +0100
Subject: [PATCH] Fix the scope chain not being set up correctly for the
 outermost scope.

This bug manifested itself as not getting a tooltip and correct context
help for the type of the root object in a Qml file.
---
 src/libs/qmljs/qmljslink.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index 5490fd67bc8..e99c3bf7404 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -73,9 +73,13 @@ void Link::scopeChainAt(Document::Ptr doc, const QList<Node *> &astPath)
         scopeChain.jsScopes += bind->rootObjectValue();
     }
 
-    ScopeBuilder scopeBuilder(doc, _context);
-    foreach (Node *node, astPath)
-        scopeBuilder.push(node);
+    if (astPath.isEmpty()) {
+        scopeChain.update();
+    } else {
+        ScopeBuilder scopeBuilder(doc, _context);
+        foreach (Node *node, astPath)
+            scopeBuilder.push(node);
+    }
 }
 
 void Link::makeComponentChain(
-- 
GitLab