forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -94,6 +94,18 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace QmlJSEditor {
|
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
|
// QmlJSEditorWidget
|
||||||
//
|
//
|
||||||
@@ -741,9 +753,14 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const
|
|||||||
|
|
||||||
void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||||
const Utils::LinkHandler &processLinkCallback,
|
const Utils::LinkHandler &processLinkCallback,
|
||||||
bool /*resolveTarget*/,
|
bool resolveTarget,
|
||||||
bool /*inNextSplit*/)
|
bool /*inNextSplit*/)
|
||||||
{
|
{
|
||||||
|
if (auto client = getQmllsClient(textDocument()->filePath())) {
|
||||||
|
client->findLinkAt(textDocument(), cursor, processLinkCallback, resolveTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const SemanticInfo semanticInfo = m_qmlJsEditorDocument->semanticInfo();
|
const SemanticInfo semanticInfo = m_qmlJsEditorDocument->semanticInfo();
|
||||||
if (! semanticInfo.isValid())
|
if (! semanticInfo.isValid())
|
||||||
return processLinkCallback(Utils::Link());
|
return processLinkCallback(Utils::Link());
|
||||||
@@ -859,17 +876,6 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
processLinkCallback(Utils::Link());
|
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()
|
void QmlJSEditorWidget::findUsages()
|
||||||
{
|
{
|
||||||
const Utils::FilePath fileName = textDocument()->filePath();
|
const Utils::FilePath fileName = textDocument()->filePath();
|
||||||
|
|||||||
Reference in New Issue
Block a user