2018-07-13 12:33:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2018 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "languagefeatures.h"
|
|
|
|
|
|
2019-02-08 10:54:32 +01:00
|
|
|
#include <cstddef>
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
namespace LanguageServerProtocol {
|
|
|
|
|
|
|
|
|
|
constexpr const char HoverRequest::methodName[];
|
|
|
|
|
constexpr const char GotoDefinitionRequest::methodName[];
|
|
|
|
|
constexpr const char GotoTypeDefinitionRequest::methodName[];
|
|
|
|
|
constexpr const char GotoImplementationRequest::methodName[];
|
|
|
|
|
constexpr const char FindReferencesRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentHighlightsRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentSymbolsRequest::methodName[];
|
|
|
|
|
constexpr const char CodeActionRequest::methodName[];
|
|
|
|
|
constexpr const char CodeLensRequest::methodName[];
|
|
|
|
|
constexpr const char CodeLensResolveRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentLinkRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentLinkResolveRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentColorRequest::methodName[];
|
|
|
|
|
constexpr const char ColorPresentationRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentFormattingRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentRangeFormattingRequest::methodName[];
|
|
|
|
|
constexpr const char DocumentOnTypeFormattingRequest::methodName[];
|
|
|
|
|
constexpr const char RenameRequest::methodName[];
|
|
|
|
|
constexpr const char SignatureHelpRequest::methodName[];
|
2019-06-12 12:55:06 +02:00
|
|
|
constexpr const char SemanticHighlightNotification::methodName[];
|
2020-05-19 13:11:21 +02:00
|
|
|
constexpr const char PrepareRenameRequest::methodName[];
|
2018-07-13 12:33:46 +02:00
|
|
|
|
2019-05-15 11:19:31 +02:00
|
|
|
HoverContent LanguageServerProtocol::Hover::content() const
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
2019-05-15 11:19:31 +02:00
|
|
|
return HoverContent(value(contentsKey));
|
2018-07-13 12:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-15 11:19:31 +02:00
|
|
|
void Hover::setContent(const HoverContent &content)
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
2019-05-15 11:19:31 +02:00
|
|
|
if (auto val = Utils::get_if<MarkedString>(&content))
|
|
|
|
|
insert(contentsKey, *val);
|
2018-07-13 12:33:46 +02:00
|
|
|
else if (auto val = Utils::get_if<MarkupContent>(&content))
|
2019-05-15 11:19:31 +02:00
|
|
|
insert(contentsKey, *val);
|
|
|
|
|
else if (auto val = Utils::get_if<QList<MarkedString>>(&content))
|
|
|
|
|
insert(contentsKey, LanguageClientArray<MarkedString>(*val).toJson());
|
2018-07-13 12:33:46 +02:00
|
|
|
else
|
|
|
|
|
QTC_ASSERT_STRING("LanguageClient Using unknown type Hover::setContent");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HoverRequest::HoverRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
Utils::optional<MarkupOrString> ParameterInformation::documentation() const
|
|
|
|
|
{
|
|
|
|
|
QJsonValue documentation = value(documentationKey);
|
|
|
|
|
if (documentation.isUndefined())
|
|
|
|
|
return Utils::nullopt;
|
|
|
|
|
return MarkupOrString(documentation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GotoDefinitionRequest::GotoDefinitionRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
GotoTypeDefinitionRequest::GotoTypeDefinitionRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
GotoImplementationRequest::GotoImplementationRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
FindReferencesRequest::FindReferencesRequest(const ReferenceParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
DocumentHighlightsRequest::DocumentHighlightsRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
DocumentSymbolsRequest::DocumentSymbolsRequest(const DocumentSymbolParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
2019-01-25 09:48:44 +01:00
|
|
|
Utils::optional<QList<CodeActionKind> > CodeActionParams::CodeActionContext::only() const
|
|
|
|
|
{
|
|
|
|
|
return optionalArray<CodeActionKind>(onlyKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CodeActionParams::CodeActionContext::setOnly(const QList<CodeActionKind> &only)
|
|
|
|
|
{
|
|
|
|
|
insertArray(onlyKey, only);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
CodeActionRequest::CodeActionRequest(const CodeActionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
CodeLensRequest::CodeLensRequest(const CodeLensParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
CodeLensResolveRequest::CodeLensResolveRequest(const CodeLens ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
DocumentLinkRequest::DocumentLinkRequest(const DocumentLinkParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
DocumentLinkResolveRequest::DocumentLinkResolveRequest(const DocumentLink ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
DocumentColorRequest::DocumentColorRequest(const DocumentColorParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
ColorPresentationRequest::ColorPresentationRequest(const ColorPresentationParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QHash<QString, DocumentFormattingProperty> FormattingOptions::properties() const
|
|
|
|
|
{
|
|
|
|
|
QHash<QString, DocumentFormattingProperty> ret;
|
|
|
|
|
for (const QString &key : keys()) {
|
|
|
|
|
if (key == tabSizeKey || key == insertSpaceKey)
|
|
|
|
|
continue;
|
|
|
|
|
QJsonValue property = value(key);
|
|
|
|
|
if (property.isBool())
|
|
|
|
|
ret[key] = property.toBool();
|
|
|
|
|
if (property.isDouble())
|
|
|
|
|
ret[key] = property.toDouble();
|
|
|
|
|
if (property.isString())
|
|
|
|
|
ret[key] = property.toString();
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FormattingOptions::setProperty(const QString &key, const DocumentFormattingProperty &property)
|
|
|
|
|
{
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
if (auto val = get_if<double>(&property))
|
|
|
|
|
insert(key, *val);
|
|
|
|
|
else if (auto val = get_if<QString>(&property))
|
|
|
|
|
insert(key, *val);
|
|
|
|
|
else if (auto val = get_if<bool>(&property))
|
|
|
|
|
insert(key, *val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DocumentFormattingRequest::DocumentFormattingRequest(const DocumentFormattingParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
DocumentRangeFormattingRequest::DocumentRangeFormattingRequest(
|
2020-01-08 11:13:58 +01:00
|
|
|
const DocumentRangeFormattingParams ¶ms)
|
2018-07-13 12:33:46 +02:00
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
2021-02-26 08:29:15 +01:00
|
|
|
bool DocumentOnTypeFormattingParams::isValid() const
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
2021-02-26 08:29:15 +01:00
|
|
|
return contains(textDocumentKey) && contains(positionKey) && contains(chKey)
|
|
|
|
|
&& contains(optionsKey);
|
2018-07-13 12:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DocumentOnTypeFormattingRequest::DocumentOnTypeFormattingRequest(
|
2021-02-22 17:29:39 +01:00
|
|
|
const DocumentOnTypeFormattingParams ¶ms)
|
2018-07-13 12:33:46 +02:00
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
2020-05-07 14:52:45 +02:00
|
|
|
PrepareRenameRequest::PrepareRenameRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
2021-02-26 08:29:15 +01:00
|
|
|
bool RenameParams::isValid() const
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
2021-02-26 08:29:15 +01:00
|
|
|
return contains(textDocumentKey) && contains(positionKey) && contains(newNameKey);
|
2018-07-13 12:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenameRequest::RenameRequest(const RenameParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
Utils::optional<DocumentUri> DocumentLink::target() const
|
|
|
|
|
{
|
|
|
|
|
Utils::optional<QString> optionalTarget = optionalValue<QString>(targetKey);
|
|
|
|
|
return optionalTarget.has_value()
|
|
|
|
|
? Utils::make_optional(DocumentUri::fromProtocol(optionalTarget.value()))
|
|
|
|
|
: Utils::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-26 08:29:15 +01:00
|
|
|
Utils::optional<QJsonValue> DocumentLink::data() const
|
|
|
|
|
{
|
|
|
|
|
return contains(dataKey) ? Utils::make_optional(value(dataKey)) : Utils::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
TextDocumentParams::TextDocumentParams()
|
|
|
|
|
: TextDocumentParams(TextDocumentIdentifier())
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
TextDocumentParams::TextDocumentParams(const TextDocumentIdentifier &identifier)
|
|
|
|
|
: JsonObject()
|
|
|
|
|
{
|
|
|
|
|
setTextDocument(identifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GotoResult::GotoResult(const QJsonValue &value)
|
|
|
|
|
{
|
|
|
|
|
if (value.isArray()) {
|
|
|
|
|
QList<Location> locations;
|
|
|
|
|
for (auto arrayValue : value.toArray()) {
|
|
|
|
|
if (arrayValue.isObject())
|
|
|
|
|
locations.append(Location(arrayValue.toObject()));
|
|
|
|
|
}
|
|
|
|
|
emplace<QList<Location>>(locations);
|
|
|
|
|
} else if (value.isObject()) {
|
|
|
|
|
emplace<Location>(value.toObject());
|
|
|
|
|
} else {
|
|
|
|
|
emplace<std::nullptr_t>(nullptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-21 13:59:52 +01:00
|
|
|
template<typename Symbol>
|
|
|
|
|
QList<Symbol> documentSymbolsResultArray(const QJsonArray &array)
|
|
|
|
|
{
|
|
|
|
|
QList<Symbol> ret;
|
2019-01-16 14:47:24 +01:00
|
|
|
for (const auto &arrayValue : array) {
|
2018-11-21 13:59:52 +01:00
|
|
|
if (arrayValue.isObject())
|
|
|
|
|
ret << Symbol(arrayValue.toObject());
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
DocumentSymbolsResult::DocumentSymbolsResult(const QJsonValue &value)
|
|
|
|
|
{
|
|
|
|
|
if (value.isArray()) {
|
2018-11-21 13:59:52 +01:00
|
|
|
QJsonArray array = value.toArray();
|
|
|
|
|
if (array.isEmpty()) {
|
|
|
|
|
*this = QList<SymbolInformation>();
|
|
|
|
|
} else {
|
|
|
|
|
QJsonObject arrayObject = array.first().toObject();
|
|
|
|
|
if (arrayObject.contains(rangeKey))
|
|
|
|
|
*this = documentSymbolsResultArray<DocumentSymbol>(array);
|
|
|
|
|
else
|
|
|
|
|
*this = documentSymbolsResultArray<SymbolInformation>(array);
|
2018-07-13 12:33:46 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
*this = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DocumentHighlightsResult::DocumentHighlightsResult(const QJsonValue &value)
|
|
|
|
|
{
|
|
|
|
|
if (value.isArray()) {
|
|
|
|
|
QList<DocumentHighlight> highlights;
|
|
|
|
|
for (auto arrayValue : value.toArray()) {
|
|
|
|
|
if (arrayValue.isObject())
|
|
|
|
|
highlights.append(DocumentHighlight(arrayValue.toObject()));
|
|
|
|
|
}
|
|
|
|
|
*this = highlights;
|
|
|
|
|
} else {
|
|
|
|
|
*this = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MarkedString::MarkedString(const QJsonValue &value)
|
2019-05-15 11:19:31 +02:00
|
|
|
{
|
2021-02-26 08:29:15 +01:00
|
|
|
if (value.isObject())
|
|
|
|
|
emplace<MarkedLanguageString>(MarkedLanguageString(value.toObject()));
|
|
|
|
|
else
|
2019-05-15 11:19:31 +02:00
|
|
|
emplace<QString>(value.toString());
|
2021-02-26 08:29:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MarkedString::isValid() const
|
|
|
|
|
{
|
|
|
|
|
if (auto markedLanguageString = Utils::get_if<MarkedLanguageString>(this))
|
|
|
|
|
return markedLanguageString->isValid();
|
|
|
|
|
return true;
|
2019-05-15 11:19:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-17 13:09:15 +02:00
|
|
|
LanguageServerProtocol::MarkedString::operator QJsonValue() const
|
2019-05-15 11:19:31 +02:00
|
|
|
{
|
|
|
|
|
if (auto val = Utils::get_if<QString>(this))
|
|
|
|
|
return *val;
|
|
|
|
|
if (auto val = Utils::get_if<MarkedLanguageString>(this))
|
|
|
|
|
return QJsonValue(*val);
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HoverContent::HoverContent(const QJsonValue &value)
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
|
|
|
|
if (value.isArray()) {
|
2019-05-15 11:19:31 +02:00
|
|
|
emplace<QList<MarkedString>>(LanguageClientArray<MarkedString>(value).toList());
|
2018-07-13 12:33:46 +02:00
|
|
|
} else if (value.isObject()) {
|
|
|
|
|
const QJsonObject &object = value.toObject();
|
|
|
|
|
MarkedLanguageString markedLanguageString(object);
|
2021-02-26 08:29:15 +01:00
|
|
|
if (markedLanguageString.isValid())
|
2019-05-15 11:19:31 +02:00
|
|
|
emplace<MarkedString>(markedLanguageString);
|
2018-07-13 12:33:46 +02:00
|
|
|
else
|
|
|
|
|
emplace<MarkupContent>(MarkupContent(object));
|
2019-05-15 11:19:31 +02:00
|
|
|
} else if (value.isString()) {
|
|
|
|
|
emplace<MarkedString>(MarkedString(value.toString()));
|
2018-07-13 12:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-26 08:29:15 +01:00
|
|
|
bool HoverContent::isValid() const
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
2021-02-26 08:29:15 +01:00
|
|
|
if (Utils::holds_alternative<MarkedString>(*this))
|
|
|
|
|
return Utils::get<MarkedString>(*this).isValid();
|
|
|
|
|
return true;
|
2018-07-13 12:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DocumentFormattingProperty::DocumentFormattingProperty(const QJsonValue &value)
|
|
|
|
|
{
|
|
|
|
|
if (value.isBool())
|
|
|
|
|
*this = value.toBool();
|
|
|
|
|
if (value.isDouble())
|
|
|
|
|
*this = value.toDouble();
|
|
|
|
|
if (value.isString())
|
|
|
|
|
*this = value.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SignatureHelpRequest::SignatureHelpRequest(const TextDocumentPositionParams ¶ms)
|
|
|
|
|
: Request(methodName, params)
|
|
|
|
|
{ }
|
|
|
|
|
|
2019-01-25 09:48:44 +01:00
|
|
|
CodeActionResult::CodeActionResult(const QJsonValue &val)
|
|
|
|
|
{
|
|
|
|
|
using ResultArray = QList<Utils::variant<Command, CodeAction>>;
|
|
|
|
|
if (val.isArray()) {
|
2019-02-08 11:19:19 +01:00
|
|
|
const QJsonArray array = val.toArray();
|
2019-01-25 09:48:44 +01:00
|
|
|
ResultArray result;
|
|
|
|
|
for (const QJsonValue &val : array) {
|
|
|
|
|
Command command(val);
|
2021-02-26 08:29:15 +01:00
|
|
|
if (command.isValid())
|
2019-01-25 09:48:44 +01:00
|
|
|
result << command;
|
|
|
|
|
else
|
|
|
|
|
result << CodeAction(val);
|
|
|
|
|
}
|
|
|
|
|
emplace<ResultArray>(result);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-02-08 10:54:32 +01:00
|
|
|
emplace<std::nullptr_t>(nullptr);
|
2019-01-25 09:48:44 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-12 12:55:06 +02:00
|
|
|
Utils::optional<QList<SemanticHighlightToken>> SemanticHighlightingInformation::tokens() const
|
|
|
|
|
{
|
|
|
|
|
QList<SemanticHighlightToken> resultTokens;
|
|
|
|
|
|
|
|
|
|
const QByteArray tokensByteArray = QByteArray::fromBase64(
|
|
|
|
|
typedValue<QString>(tokensKey).toLocal8Bit());
|
|
|
|
|
constexpr int tokensByteSize = 8;
|
|
|
|
|
int index = 0;
|
|
|
|
|
while (index + tokensByteSize <= tokensByteArray.size()) {
|
|
|
|
|
resultTokens << SemanticHighlightToken(tokensByteArray.mid(index, tokensByteSize));
|
|
|
|
|
index += tokensByteSize;
|
|
|
|
|
}
|
|
|
|
|
return Utils::make_optional(resultTokens);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SemanticHighlightingInformation::setTokens(const QList<SemanticHighlightToken> &tokens)
|
|
|
|
|
{
|
|
|
|
|
QByteArray byteArray;
|
|
|
|
|
byteArray.reserve(8 * tokens.size());
|
|
|
|
|
for (const SemanticHighlightToken &token : tokens)
|
|
|
|
|
token.appendToByteArray(byteArray);
|
|
|
|
|
insert(tokensKey, QString::fromLocal8Bit(byteArray.toBase64()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SemanticHighlightToken::SemanticHighlightToken(const QByteArray &token)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(token.size() == 8, return );
|
|
|
|
|
character = ( quint32(token.at(0)) << 24
|
|
|
|
|
| quint32(token.at(1)) << 16
|
|
|
|
|
| quint32(token.at(2)) << 8
|
|
|
|
|
| quint32(token.at(3)));
|
|
|
|
|
|
|
|
|
|
length = quint16(token.at(4) << 8 | token.at(5));
|
|
|
|
|
|
|
|
|
|
scope = quint16(token.at(6) << 8 | token.at(7));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SemanticHighlightToken::appendToByteArray(QByteArray &byteArray) const
|
|
|
|
|
{
|
|
|
|
|
byteArray.append(char((character & 0xff000000) >> 24));
|
|
|
|
|
byteArray.append(char((character & 0x00ff0000) >> 16));
|
|
|
|
|
byteArray.append(char((character & 0x0000ff00) >> 8));
|
|
|
|
|
byteArray.append(char((character & 0x000000ff)));
|
|
|
|
|
byteArray.append(char((length & 0xff00) >> 8));
|
|
|
|
|
byteArray.append(char((length & 0x00ff)));
|
|
|
|
|
byteArray.append(char((scope & 0xff00) >> 8));
|
|
|
|
|
byteArray.append(char((scope & 0x00ff)));
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-26 19:31:15 +02:00
|
|
|
Utils::variant<VersionedTextDocumentIdentifier, TextDocumentIdentifier>
|
|
|
|
|
SemanticHighlightingParams::textDocument() const
|
|
|
|
|
{
|
|
|
|
|
VersionedTextDocumentIdentifier textDocument = fromJsonValue<VersionedTextDocumentIdentifier>(
|
|
|
|
|
value(textDocumentKey));
|
2021-02-26 08:29:15 +01:00
|
|
|
return textDocument.isValid() ? textDocument : TextDocumentIdentifier(textDocument);
|
2019-06-12 12:55:06 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-07 14:52:45 +02:00
|
|
|
PrepareRenameResult::PrepareRenameResult()
|
2020-05-19 18:38:03 +02:00
|
|
|
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(nullptr)
|
2020-05-07 14:52:45 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
PrepareRenameResult::PrepareRenameResult(
|
|
|
|
|
const Utils::variant<PlaceHolderResult, Range, std::nullptr_t> &val)
|
2020-05-19 18:38:03 +02:00
|
|
|
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
2020-05-07 14:52:45 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
PrepareRenameResult::PrepareRenameResult(const PlaceHolderResult &val)
|
2020-05-19 18:38:03 +02:00
|
|
|
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
2020-05-07 14:52:45 +02:00
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
PrepareRenameResult::PrepareRenameResult(const Range &val)
|
2020-05-19 18:38:03 +02:00
|
|
|
: Utils::variant<PlaceHolderResult, Range, std::nullptr_t>(val)
|
2020-05-07 14:52:45 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
PrepareRenameResult::PrepareRenameResult(const QJsonValue &val)
|
|
|
|
|
{
|
|
|
|
|
if (val.isNull()) {
|
|
|
|
|
emplace<std::nullptr_t>(nullptr);
|
|
|
|
|
} else if (val.isObject()) {
|
|
|
|
|
const QJsonObject object = val.toObject();
|
|
|
|
|
if (object.keys().contains(rangeKey))
|
|
|
|
|
emplace<PlaceHolderResult>(PlaceHolderResult(object));
|
|
|
|
|
else
|
|
|
|
|
emplace<Range>(Range(object));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-30 15:11:15 +02:00
|
|
|
SemanticHighlightNotification::SemanticHighlightNotification(const SemanticHighlightingParams ¶ms)
|
|
|
|
|
: Notification(methodName, params)
|
|
|
|
|
{}
|
|
|
|
|
|
2021-02-26 08:29:15 +01:00
|
|
|
Utils::optional<QJsonValue> CodeLens::data() const
|
|
|
|
|
{
|
|
|
|
|
return contains(dataKey) ? Utils::make_optional(value(dataKey)) : Utils::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
} // namespace LanguageServerProtocol
|