/**************************************************************************** ** ** 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. ** ****************************************************************************/ #pragma once #include "lsptypes.h" #include "semantictokens.h" namespace LanguageServerProtocol { class LANGUAGESERVERPROTOCOL_EXPORT WorkDoneProgressOptions : public JsonObject { public: using JsonObject::JsonObject; Utils::optional workDoneProgress() const { return optionalValue(workDoneProgressKey); } void setWorkDoneProgress(bool workDoneProgress) { insert(workDoneProgressKey, workDoneProgress); } void clearWorkDoneProgress() { remove(workDoneProgressKey); } }; class LANGUAGESERVERPROTOCOL_EXPORT ResolveProviderOption : public JsonObject { public: using JsonObject::JsonObject; Utils::optional resolveProvider() const { return optionalValue(resolveProviderKey); } void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); } void clearResolveProvider() { remove(resolveProviderKey); } }; class LANGUAGESERVERPROTOCOL_EXPORT TextDocumentRegistrationOptions : public JsonObject { public: using JsonObject::JsonObject; LanguageClientArray documentSelector() const { return clientArray(documentSelectorKey); } void setDocumentSelector(const LanguageClientArray &documentSelector) { insert(documentSelectorKey, documentSelector.toJson()); } bool filterApplies(const Utils::FilePath &fileName, const Utils::MimeType &mimeType = Utils::MimeType()) const; bool isValid() const override { return contains(documentSelectorKey); } }; class LANGUAGESERVERPROTOCOL_EXPORT SaveOptions : public JsonObject { public: using JsonObject::JsonObject; // The client is supposed to include the content on save. Utils::optional includeText() const { return optionalValue(includeTextKey); } void setIncludeText(bool includeText) { insert(includeTextKey, includeText); } void clearIncludeText() { remove(includeTextKey); } }; class LANGUAGESERVERPROTOCOL_EXPORT TextDocumentSyncOptions : public JsonObject { public: using JsonObject::JsonObject; // Open and close notifications are sent to the server. Utils::optional openClose() const { return optionalValue(openCloseKey); } void setOpenClose(bool openClose) { insert(openCloseKey, openClose); } void clearOpenClose() { remove(openCloseKey); } // Change notifications are sent to the server. See TextDocumentSyncKind.None, // TextDocumentSyncKind.Full and TextDocumentSyncKind.Incremental. Utils::optional change() const { return optionalValue(changeKey); } void setChange(int change) { insert(changeKey, change); } void clearChange() { remove(changeKey); } // Will save notifications are sent to the server. Utils::optional willSave() const { return optionalValue(willSaveKey); } void setWillSave(bool willSave) { insert(willSaveKey, willSave); } void clearWillSave() { remove(willSaveKey); } // Will save wait until requests are sent to the server. Utils::optional willSaveWaitUntil() const { return optionalValue(willSaveWaitUntilKey); } void setWillSaveWaitUntil(bool willSaveWaitUntil) { insert(willSaveWaitUntilKey, willSaveWaitUntil); } void clearWillSaveWaitUntil() { remove(willSaveWaitUntilKey); } // Save notifications are sent to the server. Utils::optional save() const { return optionalValue(saveKey); } void setSave(const SaveOptions &save) { insert(saveKey, save); } void clearSave() { remove(saveKey); } }; enum class TextDocumentSyncKind { // Documents should not be synced at all. None = 0, // Documents are synced by always sending the full content of the document. Full = 1, // Documents are synced by sending the full content on open. // After that only incremental updates to the document are send. Incremental = 2 }; class LANGUAGESERVERPROTOCOL_EXPORT CodeActionOptions : public WorkDoneProgressOptions { public: using WorkDoneProgressOptions::WorkDoneProgressOptions; QList codeActionKinds() const { return array(codeActionKindsKey); } void setCodeActionKinds(const QList &codeActionKinds) { insertArray(codeActionKindsKey, codeActionKinds); } bool isValid() const override; }; enum class SemanticRequestType { None = 0x0, Full = 0x1, FullDelta = 0x2, Range = 0x4 }; Q_DECLARE_FLAGS(SemanticRequestTypes, SemanticRequestType) class LANGUAGESERVERPROTOCOL_EXPORT SemanticTokensOptions : public WorkDoneProgressOptions { public: using WorkDoneProgressOptions::WorkDoneProgressOptions; /// The legend used by the server SemanticTokensLegend legend() const { return typedValue(legendKey); } void setLegend(const SemanticTokensLegend &legend) { insert(legendKey, legend); } /// Server supports providing semantic tokens for a specific range of a document. Utils::optional> range() const; void setRange(const Utils::variant &range); void clearRange() { remove(rangeKey); } class FullSemanticTokenOptions : public JsonObject { public: using JsonObject::JsonObject; /// The server supports deltas for full documents. Utils::optional delta() const { return optionalValue(deltaKey); } void setDelta(bool delta) { insert(deltaKey, delta); } void clearDelta() { remove(deltaKey); } }; /// Server supports providing semantic tokens for a full document. Utils::optional> full() const; void setFull(const Utils::variant &full); void clearFull() { remove(fullKey); } bool isValid() const override { return contains(legendKey); } SemanticRequestTypes supportedRequests() const; }; class LANGUAGESERVERPROTOCOL_EXPORT ServerCapabilities : public JsonObject { public: using JsonObject::JsonObject; // Defines how the host (editor) should sync document changes to the language server. class LANGUAGESERVERPROTOCOL_EXPORT CompletionOptions : public WorkDoneProgressOptions { public: using WorkDoneProgressOptions::WorkDoneProgressOptions; // The characters that trigger completion automatically. Utils::optional> triggerCharacters() const { return optionalArray(triggerCharactersKey); } void setTriggerCharacters(const QList &triggerCharacters) { insertArray(triggerCharactersKey, triggerCharacters); } void clearTriggerCharacters() { remove(triggerCharactersKey); } Utils::optional resolveProvider() const { return optionalValue(resolveProviderKey); } void setResolveProvider(bool resolveProvider) { insert(resolveProviderKey, resolveProvider); } void clearResolveProvider() { remove(resolveProviderKey); } }; class LANGUAGESERVERPROTOCOL_EXPORT SignatureHelpOptions : public WorkDoneProgressOptions { public: using WorkDoneProgressOptions::WorkDoneProgressOptions; // The characters that trigger signature help automatically. Utils::optional> triggerCharacters() const { return optionalArray(triggerCharactersKey); } void setTriggerCharacters(const QList &triggerCharacters) { insertArray(triggerCharactersKey, triggerCharacters); } void clearTriggerCharacters() { remove(triggerCharactersKey); } }; using CodeLensOptions = ResolveProviderOption; class LANGUAGESERVERPROTOCOL_EXPORT DocumentOnTypeFormattingOptions : public JsonObject { public: using JsonObject::JsonObject; // A character on which formatting should be triggered, like `}`. QString firstTriggerCharacter() const { return typedValue(firstTriggerCharacterKey); } void setFirstTriggerCharacter(QString firstTriggerCharacter) { insert(firstTriggerCharacterKey, firstTriggerCharacter); } // More trigger characters. Utils::optional> moreTriggerCharacter() const { return optionalArray(moreTriggerCharacterKey); } void setMoreTriggerCharacter(const QList &moreTriggerCharacter) { insertArray(moreTriggerCharacterKey, moreTriggerCharacter); } void clearMoreTriggerCharacter() { remove(moreTriggerCharacterKey); } bool isValid() const override { return contains(firstTriggerCharacterKey); } }; using DocumentLinkOptions = ResolveProviderOption; class LANGUAGESERVERPROTOCOL_EXPORT ExecuteCommandOptions : public WorkDoneProgressOptions { public: using WorkDoneProgressOptions::WorkDoneProgressOptions; QList commands() const { return array(commandsKey); } void setCommands(const QList &commands) { insertArray(commandsKey, commands); } bool isValid() const override; }; using ColorProviderOptions = JsonObject; class LANGUAGESERVERPROTOCOL_EXPORT StaticRegistrationOptions : public JsonObject { public: using JsonObject::JsonObject; // The id used to register the request. The id can be used to deregister // the request again. See also Registration#id. Utils::optional id() const { return optionalValue(idKey); } void setId(const QString &id) { insert(idKey, id); } void clearId() { remove(idKey); } }; class LANGUAGESERVERPROTOCOL_EXPORT SemanticHighlightingServerCapabilities : public JsonObject { public: using JsonObject::JsonObject; Utils::optional>> scopes() const; void setScopes(const QList> &scopes); bool isValid() const override; }; // Defines how text documents are synced. Is either a detailed structure defining each // notification or for backwards compatibility the TextDocumentSyncKind number. using TextDocumentSync = Utils::variant; Utils::optional textDocumentSync() const; void setTextDocumentSync(const TextDocumentSync &textDocumentSync); void clearTextDocumentSync() { remove(textDocumentSyncKey); } TextDocumentSyncKind textDocumentSyncKindHelper(); // The server provides hover support. Utils::optional> hoverProvider() const; void setHoverProvider(const Utils::variant &hoverProvider); void clearHoverProvider() { remove(hoverProviderKey); } // The server provides completion support. Utils::optional completionProvider() const { return optionalValue(completionProviderKey); } void setCompletionProvider(const CompletionOptions &completionProvider) { insert(completionProviderKey, completionProvider); } void clearCompletionProvider() { remove(completionProviderKey); } // The server provides signature help support. Utils::optional signatureHelpProvider() const { return optionalValue(signatureHelpProviderKey); } void setSignatureHelpProvider(const SignatureHelpOptions &signatureHelpProvider) { insert(signatureHelpProviderKey, signatureHelpProvider); } void clearSignatureHelpProvider() { remove(signatureHelpProviderKey); } // The server provides goto definition support. Utils::optional definitionProvider() const { return optionalValue(definitionProviderKey); } void setDefinitionProvider(bool definitionProvider) { insert(definitionProviderKey, definitionProvider); } void clearDefinitionProvider() { remove(definitionProviderKey); } class LANGUAGESERVERPROTOCOL_EXPORT RegistrationOptions : public JsonObject { public: using JsonObject::JsonObject; LanguageClientArray documentSelector() const { return clientArray(documentSelectorKey); } void setDocumentSelector(const LanguageClientArray &documentSelector) { insert(documentSelectorKey, documentSelector.toJson()); } bool filterApplies(const Utils::FilePath &fileName, const Utils::MimeType &mimeType = Utils::MimeType()) const; // The id used to register the request. The id can be used to deregister // the request again. See also Registration#id. Utils::optional id() const { return optionalValue(idKey); } void setId(const QString &id) { insert(idKey, id); } void clearId() { remove(idKey); } bool isValid() const override { return contains(documentSelectorKey); } }; // The server provides Goto Type Definition support. Utils::optional> typeDefinitionProvider() const; void setTypeDefinitionProvider(const Utils::variant &typeDefinitionProvider); void clearTypeDefinitionProvider() { remove(typeDefinitionProviderKey); } // The server provides Goto Implementation support. Utils::optional> implementationProvider() const; void setImplementationProvider(const Utils::variant &implementationProvider); void clearImplementationProvider() { remove(implementationProviderKey); } // The server provides find references support. Utils::optional> referencesProvider() const; void setReferencesProvider(const Utils::variant &referencesProvider); void clearReferencesProvider() { remove(referencesProviderKey); } // The server provides document highlight support. Utils::optional> documentHighlightProvider() const; void setDocumentHighlightProvider( const Utils::variant &documentHighlightProvider); void clearDocumentHighlightProvider() { remove(documentHighlightProviderKey); } // The server provides document symbol support. Utils::optional> documentSymbolProvider() const; void setDocumentSymbolProvider(Utils::variant documentSymbolProvider); void clearDocumentSymbolProvider() { remove(documentSymbolProviderKey); } Utils::optional semanticTokensProvider() const; void setSemanticTokensProvider(const SemanticTokensOptions &semanticTokensProvider); void clearSemanticTokensProvider() { remove(semanticTokensProviderKey); } // The server provides workspace symbol support. Utils::optional> workspaceSymbolProvider() const; void setWorkspaceSymbolProvider(Utils::variant workspaceSymbolProvider); void clearWorkspaceSymbolProvider() { remove(workspaceSymbolProviderKey); } // The server provides code actions. Utils::optional> codeActionProvider() const; void setCodeActionProvider(bool codeActionProvider) { insert(codeActionProviderKey, codeActionProvider); } void setCodeActionProvider(CodeActionOptions options) { insert(codeActionProviderKey, options); } void clearCodeActionProvider() { remove(codeActionProviderKey); } // The server provides code lens. Utils::optional codeLensProvider() const { return optionalValue(codeLensProviderKey); } void setCodeLensProvider(CodeLensOptions codeLensProvider) { insert(codeLensProviderKey, codeLensProvider); } void clearCodeLensProvider() { remove(codeLensProviderKey); } // The server provides document formatting. Utils::optional> documentFormattingProvider() const; void setDocumentFormattingProvider( const Utils::variant &documentFormattingProvider); void clearDocumentFormattingProvider() { remove(documentFormattingProviderKey); } // The server provides document formatting on typing. Utils::optional> documentRangeFormattingProvider() const; void setDocumentRangeFormattingProvider(Utils::variant documentRangeFormattingProvider); void clearDocumentRangeFormattingProvider() { remove(documentRangeFormattingProviderKey); } class LANGUAGESERVERPROTOCOL_EXPORT RenameOptions : public WorkDoneProgressOptions { public: using WorkDoneProgressOptions::WorkDoneProgressOptions; // Renames should be checked and tested before being executed. Utils::optional prepareProvider() const { return optionalValue(prepareProviderKey); } void setPrepareProvider(bool prepareProvider) { insert(prepareProviderKey, prepareProvider); } void clearPrepareProvider() { remove(prepareProviderKey); } }; // The server provides rename support. Utils::optional> renameProvider() const; void setRenameProvider(Utils::variant renameProvider); void clearRenameProvider() { remove(renameProviderKey); } // The server provides document link support. Utils::optional documentLinkProvider() const { return optionalValue(documentLinkProviderKey); } void setDocumentLinkProvider(const DocumentLinkOptions &documentLinkProvider) { insert(documentLinkProviderKey, documentLinkProvider); } void clearDocumentLinkProvider() { remove(documentLinkProviderKey); } // The server provides color provider support. Utils::optional> colorProvider() const; void setColorProvider(Utils::variant colorProvider); void clearColorProvider() { remove(colorProviderKey); } // The server provides execute command support. Utils::optional executeCommandProvider() const { return optionalValue(executeCommandProviderKey); } void setExecuteCommandProvider(ExecuteCommandOptions executeCommandProvider) { insert(executeCommandProviderKey, executeCommandProvider); } void clearExecuteCommandProvider() { remove(executeCommandProviderKey); } class LANGUAGESERVERPROTOCOL_EXPORT WorkspaceServerCapabilities : public JsonObject { public: using JsonObject::JsonObject; class LANGUAGESERVERPROTOCOL_EXPORT WorkspaceFoldersCapabilities : public JsonObject { public: using JsonObject::JsonObject; // The server has support for workspace folders Utils::optional supported() const { return optionalValue(supportedKey); } void setSupported(bool supported) { insert(supportedKey, supported); } void clearSupported() { remove(supportedKey); } Utils::optional> changeNotifications() const; void setChangeNotifications(Utils::variant changeNotifications); void clearChangeNotifications() { remove(changeNotificationsKey); } }; Utils::optional workspaceFolders() const { return optionalValue(workspaceFoldersKey); } void setWorkspaceFolders(const WorkspaceFoldersCapabilities &workspaceFolders) { insert(workspaceFoldersKey, workspaceFolders); } void clearWorkspaceFolders() { remove(workspaceFoldersKey); } }; Utils::optional workspace() const { return optionalValue(workspaceKey); } void setWorkspace(const WorkspaceServerCapabilities &workspace) { insert(workspaceKey, workspace); } void clearWorkspace() { remove(workspaceKey); } Utils::optional experimental() const { return optionalValue(experimentalKey); } void setExperimental(const JsonObject &experimental) { insert(experimentalKey, experimental); } void clearExperimental() { remove(experimentalKey); } Utils::optional semanticHighlighting() const { return optionalValue(semanticHighlightingKey); } void setSemanticHighlighting(const SemanticHighlightingServerCapabilities &semanticHighlighting) { insert(semanticHighlightingKey, semanticHighlighting); } void clearSemanticHighlighting() { remove(semanticHighlightingKey); } }; } // namespace LanguageClient