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 "private/documentsymbolutils_p.h"
6
8
9using namespace Qt::StringLiterals;
10QQmlDocumentSymbolSupport::QQmlDocumentSymbolSupport(QmlLsp::QQmlCodeModelManager *model)
11 : BaseT(model)
12{
13}
14
15void QQmlDocumentSymbolSupport::setupCapabilities(QLspSpecification::ServerCapabilities &caps)
16{
17 caps.documentSymbolProvider = true;
18}
19
21 QLanguageServerProtocol *protocol)
22{
23 protocol->registerDocumentSymbolRequestHandler(getRequestHandler());
24}
25
26void QQmlDocumentSymbolSupport::process(QQmlDocumentSymbolSupport::RequestPointerArgument request)
27{
28 const auto doc = m_codeModelManager->openDocumentByUrl(
29 QQmlLSUtils::lspUriToQmlUrl(request->m_parameters.textDocument.uri));
30 const auto qmlFileItem = doc.snapshot.validDoc.fileObject(QQmlJS::Dom::GoTo::MostLikely);
31 QList<QLspSpecification::DocumentSymbol> results;
32 ResponseScopeGuard guard(results, request->m_response);
33 if (qmlFileItem.internalKind() != QQmlJS::Dom::DomType::QmlFile)
34 return;
35 results = DocumentSymbolUtils::assembleSymbolsForQmlFile(qmlFileItem);
36 DocumentSymbolUtils::reorganizeForOutlineView(results);
37}
38
39QT_END_NAMESPACE
QQmlDocumentSymbolSupport(QmlLsp::QQmlCodeModelManager *codeModel)
void process(RequestPointerArgument req) override
void setupCapabilities(QLspSpecification::ServerCapabilities &caps) override
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override
Combined button and popup list for selecting options.