aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmljseditor
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-09-04 13:46:04 +0200
committerSami Shalayel <sami.shalayel@qt.io>2023-09-20 12:59:27 +0000
commit77b368045c5a6a332c2dae25fef567f8b373bfa3 (patch)
treeba468d6f862a54500f4b0f85a182601d0d2e4076 /src/plugins/qmljseditor
parent726cc7f5cd52c298bf517e9e201215fe1bf61d6b (diff)
qmljs: use qmlls for 'go to definition'
Use the language client in qmljseditorWidget to do 'go to definition' aka 'findLinkAt', when the language client is enabled. Also move static helper method getQmllsClient up in the file. Task-number: QTCREATORBUG-29567 Change-Id: I4f9132ba5f6bffc5090f3b1f7f6ccfd0c7b40e2a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 1e0cc5d29ae..e6ceb513072 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -94,6 +94,18 @@ using namespace Utils;
namespace QmlJSEditor {
+static LanguageClient::Client *getQmllsClient(const Utils::FilePath &fileName)
+{
+ // the value in disableBuiltinCodemodel is only valid when useQmlls is enabled
+ if (QmlJsEditingSettings::get().qmllsSettings().useQmlls
+ && !QmlJsEditingSettings::get().qmllsSettings().disableBuiltinCodemodel)
+ return nullptr;
+
+ auto client = LanguageClient::LanguageClientManager::clientForFilePath(fileName);
+ return client;
+}
+
+
//
// QmlJSEditorWidget
//
@@ -741,9 +753,14 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const
void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
const Utils::LinkHandler &processLinkCallback,
- bool /*resolveTarget*/,
+ bool resolveTarget,
bool /*inNextSplit*/)
{
+ if (auto client = getQmllsClient(textDocument()->filePath())) {
+ client->findLinkAt(textDocument(), cursor, processLinkCallback, resolveTarget);
+ return;
+ }
+
const SemanticInfo semanticInfo = m_qmlJsEditorDocument->semanticInfo();
if (! semanticInfo.isValid())
return processLinkCallback(Utils::Link());
@@ -859,17 +876,6 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
processLinkCallback(Utils::Link());
}
-static LanguageClient::Client *getQmllsClient(const Utils::FilePath &fileName)
-{
- // the value in disableBuiltinCodemodel is only valid when useQmlls is enabled
- if (QmlJsEditingSettings::get().qmllsSettings().useQmlls
- && !QmlJsEditingSettings::get().qmllsSettings().disableBuiltinCodemodel)
- return nullptr;
-
- auto client = LanguageClient::LanguageClientManager::clientForFilePath(fileName);
- return client;
-}
-
void QmlJSEditorWidget::findUsages()
{
const Utils::FilePath fileName = textDocument()->filePath();