diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 6a267ad9578afd494988ed86639d5da61a5a9a5f..285482d675810f57922f92cee5220119a3716f05 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);