Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmlgototypedefinitionsupport.cpp
Go to the documentation of this file.
1
// Copyright (C) 2023 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
// Qt-Security score:significant reason:default
4
5
#
include
"qqmlgototypedefinitionsupport_p.h"
6
#
include
"qqmllsutils_p.h"
7
#
include
<
QtLanguageServer
/
private
/
qlanguageserverspectypes_p
.
h
>
8
#
include
<
QtQmlDom
/
private
/
qqmldomexternalitems_p
.
h
>
9
#
include
<
QtQmlDom
/
private
/
qqmldomtop_p
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
using
namespace
Qt::StringLiterals;
14
15
QmlGoToTypeDefinitionSupport
::QmlGoToTypeDefinitionSupport(QmlLsp::QQmlCodeModelManager *codeModel)
16
: BaseT(codeModel)
17
{
18
}
19
20
void
QmlGoToTypeDefinitionSupport
::
setupCapabilities
(QLspSpecification::ServerCapabilities &caps)
21
{
22
// just assume caps.typeDefinitionProvider is a bool for now
23
// handle the TypeDefinitionOptions and TypeDefinitionRegistrationOptions cases later on, if
24
// needed (as they just allow more fancy go-to-type-definition action).
25
caps.typeDefinitionProvider =
true
;
26
}
27
28
void
QmlGoToTypeDefinitionSupport
::
registerHandlers
(QLanguageServer *,
29
QLanguageServerProtocol *protocol)
30
{
31
protocol->registerTypeDefinitionRequestHandler(getRequestHandler());
32
}
33
34
void
QmlGoToTypeDefinitionSupport
::
process
(RequestPointerArgument request)
35
{
36
QList<QLspSpecification::Location> results;
37
ResponseScopeGuard guard(results, request->m_response);
38
39
auto
itemsFound = itemsForRequest(request);
40
if
(!itemsFound.has_value()) {
41
guard.setError(itemsFound.error());
42
return
;
43
}
44
45
auto
&front = itemsFound.value().front();
46
47
auto
base = QQmlLSUtils::findTypeDefinitionOf(front.domItem);
48
49
if
(!base) {
50
qDebug() << u"Could not obtain the base from the item"_s;
51
return
;
52
}
53
54
QLspSpecification::Location l;
55
l.uri = QUrl::fromLocalFile(base->filename()).toEncoded();
56
l.range = QQmlLSUtils::qmlLocationToLspLocation(*base);
57
58
results.append(l);
59
}
60
61
QT_END_NAMESPACE
QmlGoToTypeDefinitionSupport
Definition
qqmlgototypedefinitionsupport_p.h:31
QmlGoToTypeDefinitionSupport::process
void process(RequestPointerArgument request) override
Definition
qqmlgototypedefinitionsupport.cpp:34
QmlGoToTypeDefinitionSupport::setupCapabilities
void setupCapabilities(QLspSpecification::ServerCapabilities &caps) override
Definition
qqmlgototypedefinitionsupport.cpp:20
QmlGoToTypeDefinitionSupport::registerHandlers
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override
Definition
qqmlgototypedefinitionsupport.cpp:28
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
qmlls
qqmlgototypedefinitionsupport.cpp
Generated on
for Qt by
1.18.0