Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmldocumentsymbolsupport.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "documentSymbolSupport/documentsymbolutils_p.h"
6
8
9using namespace Qt::StringLiterals;
10QQmlDocumentSymbolSupport::QQmlDocumentSymbolSupport(QmlLsp::QQmlCodeModelManager *model)
11 : BaseT(model)
12{
13}
14
16{
17 return u"QQmlDocumentSymbolSupport"_s;
18}
19
21 const QLspSpecification::InitializeParams &,
22 QLspSpecification::InitializeResult &serverCapabilities)
23{
24 serverCapabilities.capabilities.documentSymbolProvider = true;
25}
26
28 QLanguageServerProtocol *protocol)
29{
30 protocol->registerDocumentSymbolRequestHandler(getRequestHandler());
31}
32
33void QQmlDocumentSymbolSupport::process(QQmlDocumentSymbolSupport::RequestPointerArgument request)
34{
35 const auto doc = m_codeModelManager->openDocumentByUrl(
36 QQmlLSUtils::lspUriToQmlUrl(request->m_parameters.textDocument.uri));
37 const auto qmlFileItem = doc.snapshot.validDoc.fileObject(QQmlJS::Dom::GoTo::MostLikely);
38 QList<QLspSpecification::DocumentSymbol> results;
39 ResponseScopeGuard guard(results, request->m_response);
40 if (qmlFileItem.internalKind() != QQmlJS::Dom::DomType::QmlFile)
41 return;
42 results = DocumentSymbolUtils::assembleSymbolsForQmlFile(qmlFileItem);
44}
45
46QT_END_NAMESPACE
QQmlDocumentSymbolSupport(QmlLsp::QQmlCodeModelManager *codeModel)
void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, QLspSpecification::InitializeResult &) override
void process(RequestPointerArgument req) override
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override
void reorganizeForOutlineView(SymbolsList &qmlFileSymbols)