forked from qt-creator/qt-creator
LSP: add PrepareRename request to the protocol implementation
Task-number: QTCREATORBUG-21578 Change-Id: I5bd87610d7c49f1e4a09ee1bd2221e4786a1856b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -144,6 +144,7 @@ constexpr char openCloseKey[] = "openClose";
|
||||
constexpr char optionsKey[] = "options";
|
||||
constexpr char parametersKey[] = "params";
|
||||
constexpr char patternKey[] = "pattern";
|
||||
constexpr char placeHolderKey[] = "placeHolder";
|
||||
constexpr char positionKey[] = "position";
|
||||
constexpr char prepareProviderKey[] = "prepareProvider";
|
||||
constexpr char prepareSupportKey[] = "prepareSupport";
|
||||
|
@@ -245,6 +245,10 @@ DocumentOnTypeFormattingRequest::DocumentOnTypeFormattingRequest(
|
||||
: Request(methodName, params)
|
||||
{ }
|
||||
|
||||
PrepareRenameRequest::PrepareRenameRequest(const TextDocumentPositionParams ¶ms)
|
||||
: Request(methodName, params)
|
||||
{ }
|
||||
|
||||
bool RenameParams::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return check<TextDocumentIdentifier>(error, textDocumentKey)
|
||||
@@ -511,4 +515,35 @@ bool SemanticHighlightingParams::isValid(ErrorHierarchy *error) const
|
||||
&& checkArray<SemanticHighlightingInformation>(error, linesKey);
|
||||
}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult()
|
||||
: Utils::variant<PlaceHolderResult, Range, nullptr_t>(nullptr)
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(
|
||||
const Utils::variant<PlaceHolderResult, Range, std::nullptr_t> &val)
|
||||
: Utils::variant<PlaceHolderResult, Range, nullptr_t>(val)
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(const PlaceHolderResult &val)
|
||||
: Utils::variant<PlaceHolderResult, Range, nullptr_t>(val)
|
||||
|
||||
{}
|
||||
|
||||
PrepareRenameResult::PrepareRenameResult(const Range &val)
|
||||
: Utils::variant<PlaceHolderResult, Range, nullptr_t>(val)
|
||||
{}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LanguageServerProtocol
|
||||
|
@@ -778,6 +778,44 @@ public:
|
||||
constexpr static const char methodName[] = "textDocument/onTypeFormatting";
|
||||
};
|
||||
|
||||
class PlaceHolderResult : public JsonObject
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
|
||||
Range range() const { return typedValue<Range>(rangeKey); }
|
||||
void setRange(const Range &range) { insert(rangeKey, range); }
|
||||
|
||||
QString placeHolder() const { return typedValue<QString>(placeHolderKey); }
|
||||
void setPlaceHolder(const QString &placeHolder) { insert(placeHolderKey, placeHolder); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override
|
||||
{
|
||||
return check<Range>(error, rangeKey) && checkOptional<QString>(error, placeHolderKey);
|
||||
}
|
||||
};
|
||||
|
||||
class PrepareRenameResult : public Utils::variant<PlaceHolderResult, Range, nullptr_t>
|
||||
{
|
||||
public:
|
||||
PrepareRenameResult();
|
||||
PrepareRenameResult(const Utils::variant<PlaceHolderResult, Range, nullptr_t> &val);
|
||||
explicit PrepareRenameResult(const PlaceHolderResult &val);
|
||||
explicit PrepareRenameResult(const Range &val);
|
||||
PrepareRenameResult(const QJsonValue &val);
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const;
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT PrepareRenameRequest
|
||||
: public Request<PrepareRenameResult, std::nullptr_t, TextDocumentPositionParams>
|
||||
{
|
||||
public:
|
||||
PrepareRenameRequest(const TextDocumentPositionParams ¶ms = TextDocumentPositionParams());
|
||||
using Request::Request;
|
||||
constexpr static const char methodName[] = "textDocument/prepareRename";
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT RenameParams : public JsonObject
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user