Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmllsutils_p.h
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
4#ifndef QLANGUAGESERVERUTILS_P_H
5#define QLANGUAGESERVERUTILS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtLanguageServer/private/qlanguageserverspectypes_p.h>
19#include <QtQmlDom/private/qqmldomexternalitems_p.h>
20#include <QtQmlDom/private/qqmldomtop_p.h>
21#include <algorithm>
22#include <optional>
23#include <tuple>
24#include <variant>
25
27
29
35
41
58
64
71
73{
76
77 static QQmlLSUtilsLocation from(const QString &fileName, const QString &code, quint32 startLine,
78 quint32 startCharacter, quint32 length);
79
81 {
82 return std::make_tuple(a.filename, a.sourceLocation.begin(), a.sourceLocation.end())
83 < std::make_tuple(b.filename, b.sourceLocation.begin(), b.sourceLocation.end());
84 }
86 {
87 return std::make_tuple(a.filename, a.sourceLocation.begin(), a.sourceLocation.end())
88 == std::make_tuple(b.filename, b.sourceLocation.begin(), b.sourceLocation.end());
89 }
90};
91
93{
96
97 static QQmlLSUtilsEdit from(const QString &fileName, const QString &code, quint32 startLine,
98 quint32 startCharacter, quint32 length, const QString &newName);
99
100 friend bool operator<(const QQmlLSUtilsEdit &a, const QQmlLSUtilsEdit &b)
101 {
102 return std::make_tuple(a.location, a.replacement)
103 < std::make_tuple(b.location, b.replacement);
104 }
105 friend bool operator==(const QQmlLSUtilsEdit &a, const QQmlLSUtilsEdit &b)
106 {
107 return std::make_tuple(a.location, a.replacement)
108 == std::make_tuple(b.location, b.replacement);
109 }
110};
111
129
131
133
135{
136public:
137 static qsizetype textOffsetFrom(const QString &code, int row, int character);
139 static QList<QQmlLSUtilsItemLocation> itemsFromTextLocation(const DomItem &file,
140 int line, int character);
143 static QByteArray lspUriToQmlUrl(const QByteArray &uri);
145 static QLspSpecification::Range qmlLocationToLspLocation(const QString &code,
146 QQmlJS::SourceLocation qmlLocation);
147 static DomItem baseObject(const DomItem &qmlObject);
148 static std::optional<QQmlLSUtilsLocation>
150 static std::optional<QQmlLSUtilsLocation> findDefinitionOf(const DomItem &item);
151 static QList<QQmlLSUtilsLocation> findUsagesOf(const DomItem &item);
152
153 static std::optional<QQmlLSUtilsErrorMessage> checkNameForRename(
154 const DomItem &item, const QString &newName,
155 const std::optional<QQmlLSUtilsExpressionType> &targetType = std::nullopt);
156 static QList<QQmlLSUtilsEdit> renameUsagesOf(
157 const DomItem &item, const QString &newName,
158 const std::optional<QQmlLSUtilsExpressionType> &targetType = std::nullopt);
159
160 static std::optional<QQmlLSUtilsExpressionType> resolveExpressionType(
163
164 static QPair<QString, QStringList> cmakeBuildCommand(const QString &path);
165
166 // Documentation Hints
168
169 static bool isFieldMemberExpression(const DomItem &item);
170 static bool isFieldMemberAccess(const DomItem &item);
172 const DomItem &stopAtChild = {});
173
174 static QString qualifiersFrom(const DomItem &el);
175};
177
178#endif // QLANGUAGESERVERUTILS_P_H
\inmodule QtCore
Definition qbytearray.h:57
std::shared_ptr< AttachedInfoT< FileLocations > > Tree
static QList< QQmlLSUtilsLocation > findUsagesOf(const DomItem &item)
static bool isValidEcmaScriptIdentifier(QStringView view)
static QPair< QString, QStringList > cmakeBuildCommand(const QString &path)
static QList< QQmlLSUtilsItemLocation > itemsFromTextLocation(const DomItem &file, int line, int character)
Find the DomItem representing the object situated in file at given line and character/column.
static std::optional< QQmlLSUtilsErrorMessage > checkNameForRename(const DomItem &item, const QString &newName, const std::optional< QQmlLSUtilsExpressionType > &targetType=std::nullopt)
static DomItem baseObject(const DomItem &qmlObject)
static QByteArray lspUriToQmlUrl(const QByteArray &uri)
static DomItem sourceLocationToDomItem(const DomItem &file, const QQmlJS::SourceLocation &location)
static std::optional< QQmlLSUtilsExpressionType > resolveExpressionType(const DomItem &item, QQmlLSUtilsResolveOptions)
static QStringList fieldMemberExpressionBits(const DomItem &item, const DomItem &stopAtChild={})
static QByteArray qmlUrlToLspUri(const QByteArray &url)
static QString qualifiersFrom(const DomItem &el)
static bool isFieldMemberExpression(const DomItem &item)
static bool isFieldMemberAccess(const DomItem &item)
static QLspSpecification::Range qmlLocationToLspLocation(const QString &code, QQmlJS::SourceLocation qmlLocation)
Converts a QQmlJS::SourceLocation to a LSP Range.
static std::optional< QQmlLSUtilsLocation > findTypeDefinitionOf(const DomItem &item)
Returns the location of the type definition pointed by object.
static std::optional< QQmlLSUtilsLocation > findDefinitionOf(const DomItem &item)
static qsizetype textOffsetFrom(const QString &code, int row, int character)
Convert a text position from (line, column) into an offset.
static QList< QQmlLSUtilsEdit > renameUsagesOf(const DomItem &item, const QString &newName, const std::optional< QQmlLSUtilsExpressionType > &targetType=std::nullopt)
Rename the appearance of item to newName.
static QByteArray getDocumentationFromLocation(const DomItem &file, const QQmlLSUtilsTextPosition &position)
static QQmlLSUtilsTextPosition textRowAndColumnFrom(const QString &code, qsizetype offset)
Convert a text position from an offset into (line, column).
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLint location
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLenum GLuint GLintptr offset
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void * row
QQmlLSUtilsIdentifierType
@ PropertyChangedSignalIdentifier
@ JavaScriptIdentifier
@ EnumeratorIdentifier
@ QmlObjectIdIdentifier
@ AttachedTypeIdentifier
@ SignalHandlerIdentifier
@ SingletonIdentifier
@ PropertyChangedHandlerIdentifier
@ SignalIdentifier
@ QmlComponentIdentifier
@ PropertyIdentifier
@ MethodIdentifier
@ GroupedPropertyIdentifier
@ EnumeratorValueIdentifier
ImportCompletionType
QQmlLSUtilsResolveOptions
@ ResolveOwnerType
@ ResolveActualTypeForFieldMemberExpression
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
unsigned int quint32
Definition qtypes.h:50
ptrdiff_t qsizetype
Definition qtypes.h:165
QFile file
[0]
QUrl url("example.com")
[constructor-url-reference]
QGraphicsItem * item
QQuickView * view
[0]
QStringView el
QQmlLSUtilsLocation location
static QQmlLSUtilsEdit from(const QString &fileName, const QString &code, quint32 startLine, quint32 startCharacter, quint32 length, const QString &newName)
friend bool operator==(const QQmlLSUtilsEdit &a, const QQmlLSUtilsEdit &b)
friend bool operator<(const QQmlLSUtilsEdit &a, const QQmlLSUtilsEdit &b)
std::optional< QString > name
QQmlLSUtilsIdentifierType type
QQmlJSScope::ConstPtr semanticScope
QQmlJS::Dom::DomItem domItem
QQmlJS::Dom::FileLocations::Tree fileLocation
friend bool operator==(const QQmlLSUtilsLocation &a, const QQmlLSUtilsLocation &b)
QQmlJS::SourceLocation sourceLocation
friend bool operator<(const QQmlLSUtilsLocation &a, const QQmlLSUtilsLocation &b)
static QQmlLSUtilsLocation from(const QString &fileName, const QString &code, quint32 startLine, quint32 startCharacter, quint32 length)