Improved the navigation and code completion in the QML editor.

This commit is contained in:
Erik Verbruggen
2009-10-02 10:49:33 +02:00
parent efe336b605
commit c3d1019deb
19 changed files with 798 additions and 348 deletions

View File

@@ -719,12 +719,28 @@ TextEditor::BaseTextEditor::Link ScriptEditor::findLinkAt(const QTextCursor &cur
if (!doc)
return link;
QTextCursor expressionCursor(cursor);
{
// correct the position by moving to the end of an identifier (if we're hovering over one):
const QString txt = cursor.block().text();
int pos = cursor.position();
forever {
const QChar ch = characterAt(pos);
if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
++pos;
else
break;
}
expressionCursor.setPosition(pos);
}
QmlExpressionUnderCursor expressionUnderCursor;
expressionUnderCursor(cursor, doc->program());
expressionUnderCursor(expressionCursor, doc);
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, snapshot);
QmlResolveExpression resolve(context);
QmlSymbol *symbol = resolve(expressionUnderCursor.expressionNode());
QmlResolveExpression resolver(context);
QmlSymbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
if (!symbol)
return link;