diff --git a/src/libs/qmljs/qmljsbind.cpp b/src/libs/qmljs/qmljsbind.cpp
index 01f489c336f2d1993b1d93c09c5dff5810871c8a..37617c297c76d876cdaae983c2d546c89b42dd49 100644
--- a/src/libs/qmljs/qmljsbind.cpp
+++ b/src/libs/qmljs/qmljsbind.cpp
@@ -314,6 +314,9 @@ bool Bind::visit(FunctionDeclaration *ast)
         return false;
 
     ASTFunctionValue *function = new ASTFunctionValue(ast, &_interp);
+    // ### set the function's scope.
+
     _currentObjectValue->setProperty(ast->name->asString(), function);
+
     return false; // ### eventually want to visit function bodies
 }
diff --git a/src/libs/qmljs/qmljsbind.h b/src/libs/qmljs/qmljsbind.h
index d5ce0e6f0af21a4c0301cdb2591ac92a8244bea4..10c74a18d64d4ad6835ede4e369e4e7aca21e707 100644
--- a/src/libs/qmljs/qmljsbind.h
+++ b/src/libs/qmljs/qmljsbind.h
@@ -72,7 +72,6 @@ protected:
 
 protected:
     Interpreter::ObjectValue *switchObjectValue(Interpreter::ObjectValue *newObjectValue);
-    const Interpreter::ObjectValue *lookupType(AST::UiQualifiedId *qualifiedTypeNameId);
     Interpreter::ObjectValue *bindObject(AST::UiQualifiedId *qualifiedTypeNameId, AST::UiObjectInitializer *initializer);
 
 private:
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index 57c99b33ab2dcce3ce2695e24b75d349a0acf3e4..3d654ad5c54608453ca0bf703ebc8220061395ce 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -51,7 +51,7 @@ static ObjectValue *pushScope(ObjectValue *next, ObjectValue *onto)
     return next;
 }
 
-ObjectValue *Link::scopeChainAt(Document::Ptr doc, UiObjectMember *currentObject)
+ObjectValue *Link::scopeChainAt(Document::Ptr doc, Node *currentObject)
 {
     BindPtr bind = doc->bind();
 
@@ -188,6 +188,8 @@ void Link::populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Pt
 void Link::importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
                       AST::UiImport *import, const QString &startPath)
 {
+    Q_UNUSED(doc)
+
     if (!import->fileName)
         return;
 
diff --git a/src/libs/qmljs/qmljslink.h b/src/libs/qmljs/qmljslink.h
index dc37c106700d45ea2a95325f31056504cdcd0010..998c03dd685a6dd039636a1f362d19c097822ac5 100644
--- a/src/libs/qmljs/qmljslink.h
+++ b/src/libs/qmljs/qmljslink.h
@@ -24,7 +24,7 @@ public:
     ~Link();
 
     // Get the scope chain for the currentObject inside doc.
-    Interpreter::ObjectValue *scopeChainAt(Document::Ptr doc, AST::UiObjectMember *currentObject);
+    Interpreter::ObjectValue *scopeChainAt(Document::Ptr doc, AST::Node *currentObject);
 
 private:
     static QList<Document::Ptr> reachableDocuments(Document::Ptr startDoc, const Snapshot &snapshot);
diff --git a/src/plugins/qmljseditor/qmlcodecompletion.cpp b/src/plugins/qmljseditor/qmlcodecompletion.cpp
index 043bdd28fa931d1f35e2b8057f9cc347434d3ed3..097b659189704d1a1ef9206a6be80c4f67ef53cb 100644
--- a/src/plugins/qmljseditor/qmlcodecompletion.cpp
+++ b/src/plugins/qmljseditor/qmlcodecompletion.cpp
@@ -618,7 +618,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
 
     const SemanticInfo semanticInfo = edit->semanticInfo();
     const QmlJS::Snapshot snapshot = semanticInfo.snapshot;
-    const Document::Ptr qmlDocument = semanticInfo.document;
+    const Document::Ptr document = semanticInfo.document;
 
     const QFileInfo currentFileInfo(fileName);
 
@@ -632,11 +632,11 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
 
     // Set up the current scope chain.
     Interpreter::ObjectValue *scope = interp.globalObject();
-    Link link(qmlDocument, snapshot, &interp);
+    Link link(document, snapshot, &interp);
 
-    if (isQmlFile && qmlDocument) {
-        AST::UiObjectMember *declaringMember = semanticInfo.declaringMember(editor->position());
-        scope = link.scopeChainAt(qmlDocument, declaringMember);
+    if (document) {
+        AST::Node *declaringMember = semanticInfo.declaringMember(editor->position());
+        scope = link.scopeChainAt(document, declaringMember);
     }
 
     // Search for the operator that triggered the completion.
diff --git a/src/plugins/qmljseditor/qmlhoverhandler.cpp b/src/plugins/qmljseditor/qmlhoverhandler.cpp
index fc2dd793d1f558cb7715c02ec1772b468fb57ec1..979d8ea490ed20c580fb2fbcc6ce3591ff7b3550 100644
--- a/src/plugins/qmljseditor/qmlhoverhandler.cpp
+++ b/src/plugins/qmljseditor/qmlhoverhandler.cpp
@@ -169,7 +169,7 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
     if (m_helpId.isEmpty()) {
         AST::Node *node = semanticInfo.nodeUnderCursor(pos);
         if (node && !(AST::cast<AST::StringLiteral *>(node) != 0 || AST::cast<AST::NumericLiteral *>(node) != 0)) {
-            AST::UiObjectMember *declaringMember = semanticInfo.declaringMember(pos);
+            AST::Node *declaringMember = semanticInfo.declaringMember(pos);
 
             Interpreter::Engine interp;
             Link link(qmlDocument, snapshot, &interp);
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 56c8790b5bf27749a7f08bcbea75ad3156636c59..19c3d441dd1ff7f670568d2d47535290c253eb31 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -409,6 +409,20 @@ protected:
         return true;
     }
 
+#if 0 // ### create ranges for function declarations.
+    virtual bool visit(AST::FunctionExpression *ast)
+    {
+        _ranges.append(createRange(ast));
+        return true;
+    }
+
+    virtual bool visit(AST::FunctionDeclaration *ast)
+    {
+        _ranges.append(createRange(ast));
+        return true;
+    }
+#endif
+
     Range createRange(AST::UiObjectMember *member, AST::UiObjectInitializer *ast)
     {
         Range range;
@@ -422,6 +436,21 @@ protected:
         range.end.setPosition(ast->rbraceToken.end());
         return range;
     }
+
+    Range createRange(AST::FunctionExpression *ast)
+    {
+        Range range;
+
+        range.ast = ast;
+
+        range.begin = QTextCursor(_textDocument);
+        range.begin.setPosition(ast->lbraceToken.begin());
+
+        range.end = QTextCursor(_textDocument);
+        range.end.setPosition(ast->rbraceToken.end());
+        return range;
+    }
+
 };
 
 
@@ -463,9 +492,9 @@ protected:
 } // end of anonymous namespace
 
 
-AST::UiObjectMember *SemanticInfo::declaringMember(int cursorPosition) const
+AST::Node *SemanticInfo::declaringMember(int cursorPosition) const
 {
-    AST::UiObjectMember *declaringMember = 0;
+    AST::Node *declaringMember = 0;
 
     for (int i = ranges.size() - 1; i != -1; --i) {
         const Range &range = ranges.at(i);
diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h
index 28e50bb89001c7cdeccc78d16bc358b459546bdb..c332cc66d698165b7256f1b7552588737fe0dd0f 100644
--- a/src/plugins/qmljseditor/qmljseditor.h
+++ b/src/plugins/qmljseditor/qmljseditor.h
@@ -93,7 +93,7 @@ public:
     Range(): ast(0) {}
 
 public: // attributes
-    QmlJS::AST::UiObjectMember *ast;
+    QmlJS::AST::Node *ast;
     QTextCursor begin;
     QTextCursor end;
 };
@@ -106,7 +106,7 @@ public:
     int revision() const;
 
     // Returns the declaring member
-    QmlJS::AST::UiObjectMember *declaringMember(int cursorPosition) const;
+    QmlJS::AST::Node *declaringMember(int cursorPosition) const;
 
     // Returns the AST node under cursor
     QmlJS::AST::Node *nodeUnderCursor(int cursorPosition) const;