forked from qt-creator/qt-creator
LSP: support WorkDoneProgressOptions in server capabilities
These options indicate whether a server provides extra messages to track the status of specific requests. Change-Id: I3fb78f7fa7144a5a9418b32cb5b33d55b668c484 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -215,6 +215,7 @@ constexpr char valueSetKey[] = "valueSet";
|
||||
constexpr char versionKey[] = "version";
|
||||
constexpr char willSaveKey[] = "willSave";
|
||||
constexpr char willSaveWaitUntilKey[] = "willSaveWaitUntil";
|
||||
constexpr char workDoneProgressKey[] = "workDoneProgress";
|
||||
constexpr char workspaceEditKey[] = "workspaceEdit";
|
||||
constexpr char workspaceFoldersKey[] = "workspaceFolders";
|
||||
constexpr char workspaceKey[] = "workspace";
|
||||
|
@@ -55,11 +55,29 @@ TextDocumentSyncKind ServerCapabilities::textDocumentSyncKindHelper()
|
||||
return TextDocumentSyncKind::None;
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> ServerCapabilities::hoverProvider()
|
||||
const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(hoverProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setHoverProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &hoverProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(hoverProviderKey, hoverProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||
ServerCapabilities::typeDefinitionProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||
QJsonValue provider = value(typeDefinitionProviderKey);
|
||||
const QJsonValue &provider = value(typeDefinitionProviderKey);
|
||||
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
||||
return Utils::nullopt;
|
||||
return Utils::make_optional(provider.isBool() ? RetType(provider.toBool())
|
||||
@@ -77,7 +95,7 @@ Utils::optional<Utils::variant<bool, ServerCapabilities::RegistrationOptions>>
|
||||
ServerCapabilities::implementationProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, ServerCapabilities::RegistrationOptions>;
|
||||
QJsonValue provider = value(implementationProviderKey);
|
||||
const QJsonValue &provider = value(implementationProviderKey);
|
||||
if (provider.isUndefined() || !(provider.isBool() || provider.isObject()))
|
||||
return Utils::nullopt;
|
||||
return Utils::make_optional(provider.isBool() ? RetType(provider.toBool())
|
||||
@@ -90,9 +108,85 @@ void ServerCapabilities::setImplementationProvider(
|
||||
insertVariant<bool, RegistrationOptions>(implementationProviderKey, implementationProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::referencesProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(referencesProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setReferencesProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &referencesProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(referencesProviderKey,
|
||||
referencesProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentHighlightProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentHighlightProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentHighlightProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentHighlightProviderKey,
|
||||
documentHighlightProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentSymbolProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentSymbolProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentSymbolProvider(
|
||||
Utils::variant<bool, WorkDoneProgressOptions> documentSymbolProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentSymbolProviderKey,
|
||||
documentSymbolProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::workspaceSymbolProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(workspaceSymbolProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setWorkspaceSymbolProvider(
|
||||
Utils::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(workspaceSymbolProviderKey,
|
||||
workspaceSymbolProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, CodeActionOptions>> ServerCapabilities::codeActionProvider() const
|
||||
{
|
||||
QJsonValue provider = value(codeActionProviderKey);
|
||||
const QJsonValue &provider = value(codeActionProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(Utils::variant<bool, CodeActionOptions>(provider.toBool()));
|
||||
if (provider.isObject()) {
|
||||
@@ -103,6 +197,44 @@ Utils::optional<Utils::variant<bool, CodeActionOptions>> ServerCapabilities::cod
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentFormattingProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentFormattingProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentFormattingProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentFormattingProviderKey,
|
||||
documentFormattingProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>>
|
||||
ServerCapabilities::documentRangeFormattingProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<bool, WorkDoneProgressOptions>;
|
||||
const QJsonValue &provider = value(documentRangeFormattingProviderKey);
|
||||
if (provider.isBool())
|
||||
return Utils::make_optional(RetType(provider.toBool()));
|
||||
if (provider.isObject())
|
||||
return Utils::make_optional(RetType(WorkDoneProgressOptions(provider.toObject())));
|
||||
return Utils::nullopt;
|
||||
}
|
||||
|
||||
void ServerCapabilities::setDocumentRangeFormattingProvider(
|
||||
Utils::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider)
|
||||
{
|
||||
insertVariant<bool, WorkDoneProgressOptions>(documentRangeFormattingProviderKey,
|
||||
documentRangeFormattingProvider);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::variant<ServerCapabilities::RenameOptions, bool>> ServerCapabilities::renameProvider() const
|
||||
{
|
||||
using RetType = Utils::variant<ServerCapabilities::RenameOptions, bool>;
|
||||
@@ -164,7 +296,7 @@ Utils::optional<Utils::variant<QString, bool> >
|
||||
ServerCapabilities::WorkspaceServerCapabilities::WorkspaceFoldersCapabilities::changeNotifications() const
|
||||
{
|
||||
using RetType = Utils::variant<QString, bool>;
|
||||
QJsonValue provider = value(implementationProviderKey);
|
||||
const QJsonValue &provider = value(implementationProviderKey);
|
||||
if (provider.isUndefined())
|
||||
return Utils::nullopt;
|
||||
return Utils::make_optional(provider.isBool() ? RetType(provider.toBool())
|
||||
@@ -247,4 +379,34 @@ bool ServerCapabilities::SemanticHighlightingServerCapabilities::isValid(ErrorHi
|
||||
});
|
||||
}
|
||||
|
||||
bool ServerCapabilities::ExecuteCommandOptions::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return WorkDoneProgressOptions::isValid(error) && checkArray<QString>(error, commandsKey);
|
||||
}
|
||||
|
||||
bool ServerCapabilities::CompletionOptions::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return WorkDoneProgressOptions::isValid(error)
|
||||
&& checkOptionalArray<QString>(error, triggerCharactersKey)
|
||||
&& checkOptional<bool>(error, resolveProviderKey);
|
||||
}
|
||||
|
||||
bool ServerCapabilities::SignatureHelpOptions::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return WorkDoneProgressOptions::isValid(error)
|
||||
&& checkOptionalArray<QString>(error, triggerCharactersKey);
|
||||
}
|
||||
|
||||
bool CodeActionOptions::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return WorkDoneProgressOptions::isValid(error)
|
||||
&& checkArray<QString>(error, codeActionKindsKey);
|
||||
}
|
||||
|
||||
bool ServerCapabilities::RenameOptions::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return WorkDoneProgressOptions::isValid(error)
|
||||
&& checkOptional<bool>(error, prepareProviderKey);
|
||||
}
|
||||
|
||||
} // namespace LanguageServerProtocol
|
||||
|
@@ -29,6 +29,19 @@
|
||||
|
||||
namespace LanguageServerProtocol {
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT WorkDoneProgressOptions : public JsonObject
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
|
||||
Utils::optional<bool> workDoneProgress() const { return optionalValue<bool>(workDoneProgressKey); }
|
||||
void setWorkDoneProgress(bool workDoneProgress) { insert(workDoneProgressKey, workDoneProgress); }
|
||||
void clearWorkDoneProgress() { remove(workDoneProgressKey); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override
|
||||
{ return checkOptional<bool>(error, workDoneProgressKey); }
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ResolveProviderOption : public JsonObject
|
||||
{
|
||||
public:
|
||||
@@ -120,17 +133,16 @@ enum class TextDocumentSyncKind
|
||||
Incremental = 2
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT CodeActionOptions : public JsonObject
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT CodeActionOptions : public WorkDoneProgressOptions
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
using WorkDoneProgressOptions::WorkDoneProgressOptions;
|
||||
|
||||
QList<QString> codeActionKinds() const { return array<QString>(codeActionKindsKey); }
|
||||
void setCodeActionKinds(const QList<QString> &codeActionKinds)
|
||||
{ insertArray(codeActionKindsKey, codeActionKinds); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override
|
||||
{ return checkArray<QString>(error, codeActionKindsKey); }
|
||||
bool isValid(ErrorHierarchy *error) const override;
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ServerCapabilities : public JsonObject
|
||||
@@ -140,10 +152,10 @@ public:
|
||||
|
||||
// Defines how the host (editor) should sync document changes to the language server.
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT CompletionOptions : public ResolveProviderOption
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT CompletionOptions : public WorkDoneProgressOptions
|
||||
{
|
||||
public:
|
||||
using ResolveProviderOption::ResolveProviderOption;
|
||||
using WorkDoneProgressOptions::WorkDoneProgressOptions;
|
||||
|
||||
// The characters that trigger completion automatically.
|
||||
Utils::optional<QList<QString>> triggerCharacters() const
|
||||
@@ -152,14 +164,17 @@ public:
|
||||
{ insertArray(triggerCharactersKey, triggerCharacters); }
|
||||
void clearTriggerCharacters() { remove(triggerCharactersKey); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override
|
||||
{ return checkOptionalArray<QString>(error, triggerCharactersKey); }
|
||||
Utils::optional<bool> resolveProvider() const { return optionalValue<bool>(resolveProviderKey); }
|
||||
void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); }
|
||||
void clearResolveProvider() { remove(resolveProviderKey); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override;
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT SignatureHelpOptions : public JsonObject
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT SignatureHelpOptions : public WorkDoneProgressOptions
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
using WorkDoneProgressOptions::WorkDoneProgressOptions;
|
||||
|
||||
// The characters that trigger signature help automatically.
|
||||
Utils::optional<QList<QString>> triggerCharacters() const
|
||||
@@ -167,6 +182,8 @@ public:
|
||||
void setTriggerCharacters(const QList<QString> &triggerCharacters)
|
||||
{ insertArray(triggerCharactersKey, triggerCharacters); }
|
||||
void clearTriggerCharacters() { remove(triggerCharactersKey); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override;
|
||||
};
|
||||
|
||||
using CodeLensOptions = ResolveProviderOption;
|
||||
@@ -197,16 +214,15 @@ public:
|
||||
|
||||
using DocumentLinkOptions = ResolveProviderOption;
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ExecuteCommandOptions : public JsonObject
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ExecuteCommandOptions : public WorkDoneProgressOptions
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
using WorkDoneProgressOptions::WorkDoneProgressOptions;
|
||||
|
||||
QList<QString> commands() const { return array<QString>(commandsKey); }
|
||||
void setCommands(const QList<QString> &commands) { insertArray(commandsKey, commands); }
|
||||
|
||||
bool isValid(ErrorHierarchy *error) const override
|
||||
{ return checkArray<QString>(error, commandsKey); }
|
||||
bool isValid(ErrorHierarchy *error) const override;
|
||||
};
|
||||
|
||||
using ColorProviderOptions = JsonObject;
|
||||
@@ -244,8 +260,8 @@ public:
|
||||
TextDocumentSyncKind textDocumentSyncKindHelper();
|
||||
|
||||
// The server provides hover support.
|
||||
Utils::optional<bool> hoverProvider() const { return optionalValue<bool>(hoverProviderKey); }
|
||||
void setHoverProvider(bool hoverProvider) { insert(hoverProviderKey, hoverProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> hoverProvider() const;
|
||||
void setHoverProvider(const Utils::variant<bool, WorkDoneProgressOptions> &hoverProvider);
|
||||
void clearHoverProvider() { remove(hoverProviderKey); }
|
||||
|
||||
// The server provides completion support.
|
||||
@@ -303,29 +319,24 @@ public:
|
||||
void clearImplementationProvider() { remove(implementationProviderKey); }
|
||||
|
||||
// The server provides find references support.
|
||||
Utils::optional<bool> referencesProvider() const { return optionalValue<bool>(referencesProviderKey); }
|
||||
void setReferencesProvider(bool referenceProvider) { insert(referencesProviderKey, referenceProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> referencesProvider() const;
|
||||
void setReferencesProvider(const Utils::variant<bool, WorkDoneProgressOptions> &referencesProvider);
|
||||
void clearReferencesProvider() { remove(referencesProviderKey); }
|
||||
|
||||
// The server provides document highlight support.
|
||||
Utils::optional<bool> documentHighlightProvider() const
|
||||
{ return optionalValue<bool>(documentHighlightProviderKey); }
|
||||
void setDocumentHighlightProvider(bool documentHighlightProvider)
|
||||
{ insert(documentHighlightProviderKey, documentHighlightProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentHighlightProvider() const;
|
||||
void setDocumentHighlightProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentHighlightProvider);
|
||||
void clearDocumentHighlightProvider() { remove(documentHighlightProviderKey); }
|
||||
|
||||
// The server provides document symbol support.
|
||||
Utils::optional<bool> documentSymbolProvider() const
|
||||
{ return optionalValue<bool>(documentSymbolProviderKey); }
|
||||
void setDocumentSymbolProvider(bool documentSymbolProvider)
|
||||
{ insert(documentSymbolProviderKey, documentSymbolProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider() const;
|
||||
void setDocumentSymbolProvider(Utils::variant<bool, WorkDoneProgressOptions> documentSymbolProvider);
|
||||
void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); }
|
||||
|
||||
// The server provides workspace symbol support.
|
||||
Utils::optional<bool> workspaceSymbolProvider() const
|
||||
{ return optionalValue<bool>(workspaceSymbolProviderKey); }
|
||||
void setWorkspaceSymbolProvider(bool workspaceSymbolProvider)
|
||||
{ insert(workspaceSymbolProviderKey, workspaceSymbolProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> workspaceSymbolProvider() const;
|
||||
void setWorkspaceSymbolProvider(Utils::variant<bool, WorkDoneProgressOptions> workspaceSymbolProvider);
|
||||
void clearWorkspaceSymbolProvider() { remove(workspaceSymbolProviderKey); }
|
||||
|
||||
// The server provides code actions.
|
||||
@@ -344,31 +355,27 @@ public:
|
||||
void clearCodeLensProvider() { remove(codeLensProviderKey); }
|
||||
|
||||
// The server provides document formatting.
|
||||
Utils::optional<bool> documentFormattingProvider() const
|
||||
{ return optionalValue<bool>(documentFormattingProviderKey); }
|
||||
void setDocumentFormattingProvider(bool documentFormattingProvider)
|
||||
{ insert(documentFormattingProviderKey, documentFormattingProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentFormattingProvider() const;
|
||||
void setDocumentFormattingProvider(
|
||||
const Utils::variant<bool, WorkDoneProgressOptions> &documentFormattingProvider);
|
||||
void clearDocumentFormattingProvider() { remove(documentFormattingProviderKey); }
|
||||
|
||||
// The server provides document formatting on typing.
|
||||
Utils::optional<bool> documentRangeFormattingProvider() const
|
||||
{ return optionalValue<bool>(documentRangeFormattingProviderKey); }
|
||||
void setDocumentRangeFormattingProvider(bool documentRangeFormattingProvider)
|
||||
{ insert(documentRangeFormattingProviderKey, documentRangeFormattingProvider); }
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentRangeFormattingProvider() const;
|
||||
void setDocumentRangeFormattingProvider(Utils::variant<bool, WorkDoneProgressOptions> documentRangeFormattingProvider);
|
||||
void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); }
|
||||
|
||||
class RenameOptions : public JsonObject
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT RenameOptions : public WorkDoneProgressOptions
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
using WorkDoneProgressOptions::WorkDoneProgressOptions;
|
||||
|
||||
// Renames should be checked and tested before being executed.
|
||||
Utils::optional<bool> prepareProvider() const { return optionalValue<bool>(prepareProviderKey); }
|
||||
void setPrepareProvider(bool prepareProvider) { insert(prepareProviderKey, prepareProvider); }
|
||||
void clearPrepareProvider() { remove(prepareProviderKey); }
|
||||
|
||||
bool isValid(ErrorHierarchy * error) const override
|
||||
{ return checkOptional<bool>(error, prepareProviderKey); }
|
||||
bool isValid(ErrorHierarchy * error) const override;
|
||||
};
|
||||
|
||||
// The server provides rename support.
|
||||
|
@@ -625,8 +625,13 @@ void Client::cursorPositionChanged(TextEditor::TextEditorWidget *widget)
|
||||
m_dynamicCapabilities.option(DocumentHighlightsRequest::methodName));
|
||||
if (!option.filterApplies(widget->textDocument()->filePath()))
|
||||
return;
|
||||
} else if (!m_serverCapabilities.documentHighlightProvider().value_or(false)) {
|
||||
return;
|
||||
} else {
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> provider
|
||||
= m_serverCapabilities.documentHighlightProvider();
|
||||
if (!provider.has_value())
|
||||
return;
|
||||
if (Utils::holds_alternative<bool>(*provider) && !Utils::get<bool>(*provider))
|
||||
return;
|
||||
}
|
||||
|
||||
auto runningRequest = m_highlightRequests.find(uri);
|
||||
@@ -1233,9 +1238,13 @@ void Client::initializeCallback(const InitializeRequest::Response &initResponse)
|
||||
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
||||
m_state = Initialized;
|
||||
sendContent(InitializeNotification(InitializedParams()));
|
||||
if (m_dynamicCapabilities.isRegistered(DocumentSymbolsRequest::methodName)
|
||||
.value_or(capabilities().documentSymbolProvider().value_or(false))) {
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider
|
||||
= capabilities().documentSymbolProvider();
|
||||
if (documentSymbolProvider.has_value()) {
|
||||
if (!Utils::holds_alternative<bool>(*documentSymbolProvider)
|
||||
|| Utils::get<bool>(*documentSymbolProvider)) {
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_openedDocument.cbegin(); it != m_openedDocument.cend(); ++it)
|
||||
|
@@ -84,8 +84,13 @@ QFutureWatcher<ChangeSet> *LanguageClientFormatter::format(
|
||||
&& !option.filterApplies(filePath, Utils::mimeTypeForName(m_document->mimeType()))) {
|
||||
return nullptr;
|
||||
}
|
||||
} else if (!m_client->capabilities().documentRangeFormattingProvider().value_or(false)) {
|
||||
return nullptr;
|
||||
} else {
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= m_client->capabilities().documentRangeFormattingProvider();
|
||||
if (!provider.has_value())
|
||||
return nullptr;
|
||||
if (Utils::holds_alternative<bool>(*provider) && !Utils::get<bool>(*provider))
|
||||
return nullptr;
|
||||
}
|
||||
DocumentRangeFormattingParams params;
|
||||
const DocumentUri uri = DocumentUri::fromFilePath(filePath);
|
||||
|
@@ -74,7 +74,11 @@ void HoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidget,
|
||||
return;
|
||||
}
|
||||
|
||||
bool sendMessage = m_client->capabilities().hoverProvider().value_or(false);
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= m_client->capabilities().hoverProvider();
|
||||
bool sendMessage = provider.has_value();
|
||||
if (sendMessage && Utils::holds_alternative<bool>(*provider))
|
||||
sendMessage = Utils::get<bool>(*provider);
|
||||
if (Utils::optional<bool> registered = m_client->dynamicCapabilities().isRegistered(
|
||||
HoverRequest::methodName)) {
|
||||
sendMessage = registered.value();
|
||||
|
@@ -234,7 +234,13 @@ bool LanguageClientOutlineWidgetFactory::clientSupportsDocumentSymbols(
|
||||
return !options.isValid(nullptr)
|
||||
|| options.filterApplies(doc->filePath(), Utils::mimeTypeForName(doc->mimeType()));
|
||||
}
|
||||
return client->capabilities().documentSymbolProvider().value_or(false);
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= client->capabilities().documentSymbolProvider();
|
||||
if (!provider.has_value())
|
||||
return false;
|
||||
if (Utils::holds_alternative<bool>(*provider))
|
||||
return Utils::get<bool>(*provider);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LanguageClientOutlineWidgetFactory::supportsEditor(Core::IEditor *editor) const
|
||||
|
@@ -46,7 +46,7 @@ template<typename Request>
|
||||
static void sendTextDocumentPositionParamsRequest(Client *client,
|
||||
const Request &request,
|
||||
const DynamicCapabilities &dynamicCapabilities,
|
||||
const Utils::optional<bool> &serverCapability)
|
||||
const ServerCapabilities &serverCapability)
|
||||
{
|
||||
if (!request.isValid(nullptr))
|
||||
return;
|
||||
@@ -62,7 +62,11 @@ static void sendTextDocumentPositionParamsRequest(Client *client,
|
||||
else
|
||||
sendMessage = supportedFile;
|
||||
} else {
|
||||
sendMessage = serverCapability.value_or(sendMessage) && supportedFile;
|
||||
const Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> &provider
|
||||
= serverCapability.referencesProvider();
|
||||
sendMessage = provider.has_value();
|
||||
if (sendMessage && Utils::holds_alternative<bool>(*provider))
|
||||
sendMessage = Utils::get<bool>(*provider);
|
||||
}
|
||||
if (sendMessage)
|
||||
client->sendContent(request);
|
||||
@@ -121,7 +125,7 @@ void SymbolSupport::findLinkAt(TextEditor::TextDocument *document,
|
||||
sendTextDocumentPositionParamsRequest(m_client,
|
||||
request,
|
||||
m_client->dynamicCapabilities(),
|
||||
m_client->capabilities().referencesProvider());
|
||||
m_client->capabilities());
|
||||
|
||||
}
|
||||
|
||||
@@ -230,7 +234,7 @@ void SymbolSupport::findUsages(TextEditor::TextDocument *document, const QTextCu
|
||||
sendTextDocumentPositionParamsRequest(m_client,
|
||||
request,
|
||||
m_client->dynamicCapabilities(),
|
||||
m_client->capabilities().referencesProvider());
|
||||
m_client->capabilities());
|
||||
}
|
||||
|
||||
static bool supportsRename(Client *client,
|
||||
|
@@ -221,15 +221,19 @@ void WorkspaceLocatorFilter::prepareSearch(const QString &entry)
|
||||
|
||||
QMutexLocker locker(&m_mutex);
|
||||
for (auto client : Utils::filtered(LanguageClientManager::clients(), &Client::reachable)) {
|
||||
if (client->capabilities().workspaceSymbolProvider().value_or(false)) {
|
||||
WorkspaceSymbolRequest request(params);
|
||||
request.setResponseCallback(
|
||||
[this, client](const WorkspaceSymbolRequest::Response &response) {
|
||||
handleResponse(client, response);
|
||||
});
|
||||
m_pendingRequests[client] = request.id();
|
||||
client->sendContent(request);
|
||||
}
|
||||
Utils::optional<Utils::variant<bool, WorkDoneProgressOptions>> capability
|
||||
= client->capabilities().workspaceSymbolProvider();
|
||||
if (!capability.has_value())
|
||||
continue;
|
||||
if (Utils::holds_alternative<bool>(*capability) && !Utils::get<bool>(*capability))
|
||||
continue;
|
||||
WorkspaceSymbolRequest request(params);
|
||||
request.setResponseCallback(
|
||||
[this, client](const WorkspaceSymbolRequest::Response &response) {
|
||||
handleResponse(client, response);
|
||||
});
|
||||
m_pendingRequests[client] = request.id();
|
||||
client->sendContent(request);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user