Skip to content
Snippets Groups Projects
Commit ab3c2563 authored by Christian Kamm's avatar Christian Kamm
Browse files

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: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent c879b9ae
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment