Pass in the whole AST path for scope creation.

Just the declaring member isn't enough.
This commit is contained in:
Christian Kamm
2010-02-19 12:25:26 +01:00
parent 8274197366
commit 08cfc8f28c
8 changed files with 45 additions and 28 deletions

View File

@@ -670,8 +670,8 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
Interpreter::Context context(&interp);
// Set up the current scope chain.
AST::Node *declaringMember = semanticInfo.declaringMember(editor->position());
context.build(declaringMember, document, snapshot);
QList<AST::Node *> astPath = semanticInfo.astPath(editor->position());
context.build(astPath , document, snapshot);
// Search for the operator that triggered the completion.
QChar completionOperator;

View File

@@ -904,7 +904,7 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
Interpreter::Engine interp;
Interpreter::Context context(&interp);
context.build(semanticInfo.declaringMember(cursorPosition), semanticInfo.document, semanticInfo.snapshot);
context.build(semanticInfo.astPath(cursorPosition), semanticInfo.document, semanticInfo.snapshot);
Evaluate check(&context);
const Interpreter::Value *value = check.reference(node);

View File

@@ -168,11 +168,11 @@ void HoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int p
if (m_helpId.isEmpty() && m_toolTip.isEmpty()) {
AST::Node *node = semanticInfo.nodeUnderCursor(pos);
if (node && !(AST::cast<AST::StringLiteral *>(node) != 0 || AST::cast<AST::NumericLiteral *>(node) != 0)) {
AST::Node *declaringMember = semanticInfo.declaringMember(pos);
QList<AST::Node *> astPath = semanticInfo.astPath(pos);
Interpreter::Engine interp;
Interpreter::Context context(&interp);
context.build(declaringMember, qmlDocument, snapshot);
context.build(astPath, qmlDocument, snapshot);
Evaluate check(&context);
const Interpreter::Value *value = check(node);