From ab3c256338c10e463cece3872f141f8456e0013f Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Tue, 9 Aug 2011 11:10:53 +0200 Subject: [PATCH] QmlJS: String literals with file names link to files. Task-number: QTCREATORBUG-5701 Change-Id: If8e0cf2ba685de6fb5d2d11cff05d0dd5893ff82 Reviewed-on: http://codereview.qt.nokia.com/2775 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com> --- src/plugins/qmljseditor/qmljseditor.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 6a267ad9578..285482d6758 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -1292,6 +1292,25 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q return Link(); } + // string literals that could refer to a file link to them + if (StringLiteral *literal = cast<StringLiteral *>(node)) { + const QString text = literal->value->asString(); + BaseTextEditorWidget::Link link; + link.begin = literal->literalToken.begin(); + link.end = literal->literalToken.end(); + if (semanticInfo.snapshot.document(text)) { + link.fileName = text; + return link; + } + const QString relative = QString("%1/%2").arg( + semanticInfo.document->path(), + text); + if (semanticInfo.snapshot.document(relative)) { + link.fileName = relative; + return link; + } + } + const ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition)); Evaluate evaluator(&scopeChain); const Value *value = evaluator.reference(node); -- GitLab