From d90bb222eff43635f29db831e3c03253fd15cca1 Mon Sep 17 00:00:00 2001 From: Yaohai Zheng Date: Mon, 29 Oct 2018 11:22:21 +0800 Subject: [PATCH] Add LSP resource operation support. Signed-off-by: Yaohai Zheng --- .../eclipse/lsp4j/FailureHandlingKind.java | 48 + .../java/org/eclipse/lsp4j/Protocol.xtend | 3470 +++++++++-------- .../eclipse/lsp4j/ResourceOperationKind.java | 37 + .../adapters/DocumentChangeListAdapter.java | 45 + .../ResourceOperationTypeAdapter.java | 90 + .../lsp4j/services/TextDocumentService.java | 13 + .../org/eclipse/lsp4j/CreateFile.java | 126 + .../org/eclipse/lsp4j/CreateFileOptions.java | 110 + .../org/eclipse/lsp4j/DeleteFile.java | 126 + .../org/eclipse/lsp4j/DeleteFileOptions.java | 110 + .../eclipse/lsp4j/PrepareRenameResult.java | 104 + .../org/eclipse/lsp4j/RenameFile.java | 157 + .../org/eclipse/lsp4j/RenameFileOptions.java | 110 + .../org/eclipse/lsp4j/RenameOptions.java | 80 + .../org/eclipse/lsp4j/ResourceOperation.java | 74 + .../org/eclipse/lsp4j/ServerCapabilities.java | 23 +- .../org/eclipse/lsp4j/WorkspaceEdit.java | 13 +- .../lsp4j/WorkspaceEditCapabilities.java | 65 +- .../lsp4j/test/services/JsonParseTest.xtend | 95 + .../lsp4j/test/services/JsonParseTest.java | 219 ++ 20 files changed, 3491 insertions(+), 1624 deletions(-) create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FailureHandlingKind.java create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ResourceOperationKind.java create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/DocumentChangeListAdapter.java create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceOperationTypeAdapter.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFile.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFileOptions.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFile.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFileOptions.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/PrepareRenameResult.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFile.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFileOptions.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameOptions.java create mode 100644 org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ResourceOperation.java diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FailureHandlingKind.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FailureHandlingKind.java new file mode 100644 index 000000000..7b0c832de --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FailureHandlingKind.java @@ -0,0 +1,48 @@ +/****************************************************************************** + * Copyright (c) 2018 Microsoft Corporation and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + ******************************************************************************/ + +package org.eclipse.lsp4j; + +/** + * The kind of failure handling supported by the client. + */ +public final class FailureHandlingKind { + + private FailureHandlingKind() { + } + + /** + * Applying the workspace change is simply aborted if one of the changes + * provided fails. All operations executed before the failing operation stay + * executed. + */ + public static final String Abort = "abort"; + + /** + * All operations are executed transactional. That means they either all succeed + * or no changes at all are applied to the workspace. + */ + public static final String Transactional = "transactional"; + + /** + * If the workspace edit contains only textual file changes they are executed + * transactional. If resource changes (create, rename or delete file) are part + * of the change the failure handling strategy is abort. + */ + public static final String TextOnlyTransactional = "textOnlyTransactional"; + + /** + * The client tries to undo the operations already executed. But there is no + * guaruntee that this is succeeding. + */ + public static final String Undo = "undo"; +} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend index 68b575ac6..548844e1b 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend @@ -17,9 +17,11 @@ import java.util.ArrayList import java.util.LinkedHashMap import java.util.List import java.util.Map +import org.eclipse.lsp4j.adapters.DocumentChangeListAdapter import org.eclipse.lsp4j.adapters.HoverTypeAdapter import org.eclipse.lsp4j.adapters.InitializeParamsTypeAdapter import org.eclipse.lsp4j.adapters.ResourceChangeListAdapter +import org.eclipse.lsp4j.adapters.ResourceOperationTypeAdapter import org.eclipse.lsp4j.adapters.VersionedTextDocumentIdentifierTypeAdapter import org.eclipse.lsp4j.generator.JsonRpcData import org.eclipse.lsp4j.jsonrpc.json.adapters.JsonElementTypeAdapter @@ -30,16 +32,16 @@ import org.eclipse.lsp4j.jsonrpc.validation.NonNull @JsonRpcData class DynamicRegistrationCapabilities { /** - * Supports dynamic registration. - */ - Boolean dynamicRegistration - - new() { - } - - new(Boolean dynamicRegistration) { - this.dynamicRegistration = dynamicRegistration - } + * Supports dynamic registration. + */ + Boolean dynamicRegistration + + new() { + } + + new(Boolean dynamicRegistration) { + this.dynamicRegistration = dynamicRegistration + } } /** @@ -51,19 +53,31 @@ class WorkspaceEditCapabilities { * The client supports versioned document changes in `WorkspaceEdit`s */ Boolean documentChanges - + /** * The client supports resource changes * in `WorkspaceEdit`s. */ @Beta Boolean resourceChanges - new() { - } - - new(Boolean documentChanges) { - this.documentChanges = documentChanges - } + /** + * The resource operations the client supports. Clients should at least + * support 'create', 'rename' and 'delete' files and folders. + */ + List resourceOperations; + + /** + * The failure handling strategy of a client if applying the workspace edit + * fails. + */ + FailureHandlingKind failureHandling; + + new() { + } + + new(Boolean documentChanges) { + this.documentChanges = documentChanges + } } /** @@ -71,12 +85,12 @@ class WorkspaceEditCapabilities { */ @JsonRpcData class DidChangeConfigurationCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -84,12 +98,12 @@ class DidChangeConfigurationCapabilities extends DynamicRegistrationCapabilities */ @JsonRpcData class DidChangeWatchedFilesCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -97,27 +111,27 @@ class DidChangeWatchedFilesCapabilities extends DynamicRegistrationCapabilities */ @JsonRpcData class SymbolCapabilities extends DynamicRegistrationCapabilities { - + /** * Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. */ SymbolKindCapabilities symbolKind - - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } - - new(SymbolKindCapabilities symbolKind) { - this.symbolKind = symbolKind - } - - new(SymbolKindCapabilities symbolKind, Boolean dynamicRegistration) { - super(dynamicRegistration) - this.symbolKind = symbolKind - } + + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } + + new(SymbolKindCapabilities symbolKind) { + this.symbolKind = symbolKind + } + + new(SymbolKindCapabilities symbolKind, Boolean dynamicRegistration) { + super(dynamicRegistration) + this.symbolKind = symbolKind + } } /** @@ -125,12 +139,12 @@ class SymbolCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class ExecuteCommandCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -139,46 +153,46 @@ class ExecuteCommandCapabilities extends DynamicRegistrationCapabilities { @JsonRpcData class WorkspaceClientCapabilities { /** - * The client supports applying batch edits to the workspace by supporting - * the request 'workspace/applyEdit'. - */ - Boolean applyEdit - - /** - * Capabilities specific to `WorkspaceEdit`s - */ - WorkspaceEditCapabilities workspaceEdit - - /** - * Capabilities specific to the `workspace/didChangeConfiguration` notification. - */ - DidChangeConfigurationCapabilities didChangeConfiguration - - /** - * Capabilities specific to the `workspace/didChangeConfiguration` notification. - */ - DidChangeWatchedFilesCapabilities didChangeWatchedFiles - - /** - * Capabilities specific to the `workspace/symbol` request. - */ - SymbolCapabilities symbol - - /** - * Capabilities specific to the `workspace/executeCommand` request. - */ - ExecuteCommandCapabilities executeCommand - - /** + * The client supports applying batch edits to the workspace by supporting + * the request 'workspace/applyEdit'. + */ + Boolean applyEdit + + /** + * Capabilities specific to `WorkspaceEdit`s + */ + WorkspaceEditCapabilities workspaceEdit + + /** + * Capabilities specific to the `workspace/didChangeConfiguration` notification. + */ + DidChangeConfigurationCapabilities didChangeConfiguration + + /** + * Capabilities specific to the `workspace/didChangeConfiguration` notification. + */ + DidChangeWatchedFilesCapabilities didChangeWatchedFiles + + /** + * Capabilities specific to the `workspace/symbol` request. + */ + SymbolCapabilities symbol + + /** + * Capabilities specific to the `workspace/executeCommand` request. + */ + ExecuteCommandCapabilities executeCommand + + /** * The client has support for workspace folders. * * Since 3.6.0 */ Boolean workspaceFolders - + /** * The client supports `workspace/configuration` requests. - * + * * Since 3.6.0 */ Boolean configuration @@ -186,38 +200,38 @@ class WorkspaceClientCapabilities { @JsonRpcData class SynchronizationCapabilities extends DynamicRegistrationCapabilities { - /** - * The client supports sending will save notifications. - */ - Boolean willSave - - /** - * The client supports sending a will save request and - * waits for a response providing text edits which will - * be applied to the document before it is saved. - */ - Boolean willSaveWaitUntil - - /** - * The client supports did save notifications. - */ - Boolean didSave - - new() { - } - - new(Boolean willSave, Boolean willSaveWaitUntil, Boolean didSave) { - this.willSave = willSave - this.willSaveWaitUntil = willSaveWaitUntil - this.didSave = didSave - } - - new(Boolean willSave, Boolean willSaveWaitUntil, Boolean didSave, Boolean dynamicRegistration) { - super(dynamicRegistration) - this.willSave = willSave - this.willSaveWaitUntil = willSaveWaitUntil - this.didSave = didSave - } + /** + * The client supports sending will save notifications. + */ + Boolean willSave + + /** + * The client supports sending a will save request and + * waits for a response providing text edits which will + * be applied to the document before it is saved. + */ + Boolean willSaveWaitUntil + + /** + * The client supports did save notifications. + */ + Boolean didSave + + new() { + } + + new(Boolean willSave, Boolean willSaveWaitUntil, Boolean didSave) { + this.willSave = willSave + this.willSaveWaitUntil = willSaveWaitUntil + this.didSave = didSave + } + + new(Boolean willSave, Boolean willSaveWaitUntil, Boolean didSave, Boolean dynamicRegistration) { + super(dynamicRegistration) + this.willSave = willSave + this.willSaveWaitUntil = willSaveWaitUntil + this.didSave = didSave + } } /** @@ -250,7 +264,7 @@ class CompletionItemCapabilities { * Client supports the deprecated property on a completion item. */ Boolean deprecatedSupport - + /** * Client supports the preselect property on a completion item. */ @@ -266,63 +280,63 @@ class CompletionItemCapabilities { @JsonRpcData class CompletionItemKindCapabilities { - /** - * The completion item kind values the client supports. When this - * property exists the client also guarantees that it will - * handle values outside its set gracefully and falls back - * to a default value when unknown. - * - * If this property is not present the client only supports - * the completion items kinds from `Text` to `Reference` as defined in - * the initial version of the protocol. - */ - List valueSet - - new() { - } - - new(List valueSet) { - this.valueSet = valueSet - } + /** + * The completion item kind values the client supports. When this + * property exists the client also guarantees that it will + * handle values outside its set gracefully and falls back + * to a default value when unknown. + * + * If this property is not present the client only supports + * the completion items kinds from `Text` to `Reference` as defined in + * the initial version of the protocol. + */ + List valueSet + + new() { + } + + new(List valueSet) { + this.valueSet = valueSet + } } /** * Capabilities specific to the `textDocument/completion` */ @JsonRpcData -class CompletionCapabilities extends DynamicRegistrationCapabilities { - /** - * The client supports the following `CompletionItem` specific - * capabilities. - */ - CompletionItemCapabilities completionItem - - /** - * The client supports the following `CompletionItemKind` specific - * capabilities. - */ - CompletionItemKindCapabilities completionItemKind - - /** - * The client supports sending additional context information for a - * `textDocument/completion` request. - */ - Boolean contextSupport - - new() { - } - - new(CompletionItemCapabilities completionItem) { - this.completionItem = completionItem - } - - new(CompletionItemKindCapabilities completionItemKind) { - this.completionItemKind = completionItemKind - } - - new(Boolean contextSupport) { - this.contextSupport = contextSupport - } +class CompletionCapabilities extends DynamicRegistrationCapabilities { + /** + * The client supports the following `CompletionItem` specific + * capabilities. + */ + CompletionItemCapabilities completionItem + + /** + * The client supports the following `CompletionItemKind` specific + * capabilities. + */ + CompletionItemKindCapabilities completionItemKind + + /** + * The client supports sending additional context information for a + * `textDocument/completion` request. + */ + Boolean contextSupport + + new() { + } + + new(CompletionItemCapabilities completionItem) { + this.completionItem = completionItem + } + + new(CompletionItemKindCapabilities completionItemKind) { + this.completionItemKind = completionItemKind + } + + new(Boolean contextSupport) { + this.contextSupport = contextSupport + } } /** @@ -330,25 +344,25 @@ class CompletionCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class HoverCapabilities extends DynamicRegistrationCapabilities { - /** - * Client supports the following content formats for the content - * property. The order describes the preferred format of the client. - * - * See {@link MarkupKind} for allowed values. - */ - List contentFormat - - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } - - new(List contentFormat, Boolean dynamicRegistration) { - super(dynamicRegistration) - this.contentFormat = contentFormat - } + /** + * Client supports the following content formats for the content + * property. The order describes the preferred format of the client. + * + * See {@link MarkupKind} for allowed values. + */ + List contentFormat + + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } + + new(List contentFormat, Boolean dynamicRegistration) { + super(dynamicRegistration) + this.contentFormat = contentFormat + } } /** @@ -356,70 +370,70 @@ class HoverCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class SignatureInformationCapabilities { - /** - * Client supports the following content formats for the documentation - * property. The order describes the preferred format of the client. - * - * See {@link MarkupKind} for allowed values. - */ - List documentationFormat - - new() { - } - - new(List documentationFormat) { - this.documentationFormat = documentationFormat - } + /** + * Client supports the following content formats for the documentation + * property. The order describes the preferred format of the client. + * + * See {@link MarkupKind} for allowed values. + */ + List documentationFormat + + new() { + } + + new(List documentationFormat) { + this.documentationFormat = documentationFormat + } } /** * Capabilities specific to the `textDocument/signatureHelp` */ @JsonRpcData -class SignatureHelpCapabilities extends DynamicRegistrationCapabilities { - /** - * The client supports the following `SignatureInformation` - * specific properties. - */ - SignatureInformationCapabilities signatureInformation - - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } - - new(SignatureInformationCapabilities signatureInformation, Boolean dynamicRegistration) { - super(dynamicRegistration) - this.signatureInformation = signatureInformation - } +class SignatureHelpCapabilities extends DynamicRegistrationCapabilities { + /** + * The client supports the following `SignatureInformation` + * specific properties. + */ + SignatureInformationCapabilities signatureInformation + + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } + + new(SignatureInformationCapabilities signatureInformation, Boolean dynamicRegistration) { + super(dynamicRegistration) + this.signatureInformation = signatureInformation + } } /** * Capabilities specific to the `textDocument/references` */ @JsonRpcData -class ReferencesCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } +class ReferencesCapabilities extends DynamicRegistrationCapabilities { + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** * Capabilities specific to the `textDocument/documentHighlight` */ @JsonRpcData -class DocumentHighlightCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } +class DocumentHighlightCapabilities extends DynamicRegistrationCapabilities { + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -427,24 +441,24 @@ class DocumentHighlightCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class SymbolKindCapabilities { - /** - * The symbol kind values the client supports. When this - * property exists the client also guarantees that it will - * handle values outside its set gracefully and falls back - * to a default value when unknown. - * - * If this property is not present the client only supports - * the symbol kinds from `File` to `Array` as defined in - * the initial version of the protocol. - */ - List valueSet - - new() { - } - - new(List valueSet) { - this.valueSet = valueSet - } + /** + * The symbol kind values the client supports. When this + * property exists the client also guarantees that it will + * handle values outside its set gracefully and falls back + * to a default value when unknown. + * + * If this property is not present the client only supports + * the symbol kinds from `File` to `Array` as defined in + * the initial version of the protocol. + */ + List valueSet + + new() { + } + + new(List valueSet) { + this.valueSet = valueSet + } } /** @@ -452,31 +466,31 @@ class SymbolKindCapabilities { */ @JsonRpcData class DocumentSymbolCapabilities extends DynamicRegistrationCapabilities { - /** - * Specific capabilities for the `SymbolKind`. - */ - SymbolKindCapabilities symbolKind - - /** - * The client support hierarchical document symbols. - */ - Boolean hierarchicalDocumentSymbolSupport - - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } - - new(SymbolKindCapabilities symbolKind) { - this.symbolKind = symbolKind - } - - new(SymbolKindCapabilities symbolKind, Boolean dynamicRegistration) { - super(dynamicRegistration) - this.symbolKind = symbolKind - } + /** + * Specific capabilities for the `SymbolKind`. + */ + SymbolKindCapabilities symbolKind + + /** + * The client support hierarchical document symbols. + */ + Boolean hierarchicalDocumentSymbolSupport + + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } + + new(SymbolKindCapabilities symbolKind) { + this.symbolKind = symbolKind + } + + new(SymbolKindCapabilities symbolKind, Boolean dynamicRegistration) { + super(dynamicRegistration) + this.symbolKind = symbolKind + } } /** @@ -484,12 +498,12 @@ class DocumentSymbolCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class FormattingCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -497,12 +511,12 @@ class FormattingCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class RangeFormattingCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -510,12 +524,12 @@ class RangeFormattingCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class OnTypeFormattingCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -523,42 +537,42 @@ class OnTypeFormattingCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class DefinitionCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** * Capabilities specific to the `textDocument/typeDefinition` - * + * * Since 3.6.0 */ @JsonRpcData class TypeDefinitionCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** * Capabilities specific to the `textDocument/implementation`. - * + * * Since 3.6.0 */ @JsonRpcData class ImplementationCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } @@ -572,31 +586,31 @@ class CodeActionKindCapabilities { * * See {@link CodeActionKind} for allowed values. */ - List valueSet + List valueSet - new() { - } - - new(List valueSet) { - this.valueSet = valueSet - } + new() { + } + + new(List valueSet) { + this.valueSet = valueSet + } } @JsonRpcData class CodeActionLiteralSupportCapabilities { /** - * The code action kind is support with the following value - * set. - */ - CodeActionKindCapabilities codeActionKind - - new() { - } - - new(CodeActionKindCapabilities codeActionKind) { - this.codeActionKind = codeActionKind; - } + * The code action kind is support with the following value + * set. + */ + CodeActionKindCapabilities codeActionKind + + new() { + } + + new(CodeActionKindCapabilities codeActionKind) { + this.codeActionKind = codeActionKind; + } } /** @@ -604,24 +618,24 @@ class CodeActionLiteralSupportCapabilities { */ @JsonRpcData class CodeActionCapabilities extends DynamicRegistrationCapabilities { - + /** * The client support code action literals as a valid * response of the `textDocument/codeAction` request. */ - CodeActionLiteralSupportCapabilities codeActionLiteralSupport + CodeActionLiteralSupportCapabilities codeActionLiteralSupport + + new() { + } - new() { - } + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } - - new(CodeActionLiteralSupportCapabilities codeActionLiteralSupport, Boolean dynamicRegistration) { - super(dynamicRegistration) - this.codeActionLiteralSupport = codeActionLiteralSupport - } + new(CodeActionLiteralSupportCapabilities codeActionLiteralSupport, Boolean dynamicRegistration) { + super(dynamicRegistration) + this.codeActionLiteralSupport = codeActionLiteralSupport + } } /** @@ -629,12 +643,12 @@ class CodeActionCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class CodeLensCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -642,28 +656,28 @@ class CodeLensCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class DocumentLinkCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** * Capabilities specific to the `textDocument/documentColor` and the * `textDocument/colorPresentation` request. - * + * * Since 3.6.0 */ @JsonRpcData class ColorProviderCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -671,12 +685,12 @@ class ColorProviderCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class RenameCapabilities extends DynamicRegistrationCapabilities { - new() { - } - - new(Boolean dynamicRegistration) { - super(dynamicRegistration) - } + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -688,10 +702,10 @@ class PublishDiagnosticsCapabilities { * Whether the client accepts diagnostics with related information. */ Boolean relatedInformation - + new() { } - + new(Boolean relatedInformation) { this.relatedInformation = relatedInformation } @@ -709,7 +723,7 @@ class FoldingRangeCapabilities extends DynamicRegistrationCapabilities { * hint, servers are free to follow the limit. */ Integer rangeLimit - + /** * If set, the client signals that it only supports folding complete lines. If set, client will * ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange. @@ -741,104 +755,104 @@ class SemanticHighlightingCapabilities { @JsonRpcData class TextDocumentClientCapabilities { SynchronizationCapabilities synchronization - - /** - * Capabilities specific to the `textDocument/completion` - */ - CompletionCapabilities completion - - /** - * Capabilities specific to the `textDocument/hover` - */ - HoverCapabilities hover - - /** - * Capabilities specific to the `textDocument/signatureHelp` - */ - SignatureHelpCapabilities signatureHelp - - /** - * Capabilities specific to the `textDocument/references` - */ - ReferencesCapabilities references - - /** - * Capabilities specific to the `textDocument/documentHighlight` - */ - DocumentHighlightCapabilities documentHighlight - - /** - * Capabilities specific to the `textDocument/documentSymbol` - */ - DocumentSymbolCapabilities documentSymbol - - /** - * Capabilities specific to the `textDocument/formatting` - */ - FormattingCapabilities formatting - - /** - * Capabilities specific to the `textDocument/rangeFormatting` - */ - RangeFormattingCapabilities rangeFormatting - - /** - * Capabilities specific to the `textDocument/onTypeFormatting` - */ - OnTypeFormattingCapabilities onTypeFormatting - - /** - * Capabilities specific to the `textDocument/definition` - */ - DefinitionCapabilities definition - - /** - * Capabilities specific to the `textDocument/typeDefinition` - * - * Since 3.6.0 - */ - TypeDefinitionCapabilities typeDefinition - - /** - * Capabilities specific to the `textDocument/implementation` - * - * Since 3.6.0 - */ - ImplementationCapabilities implementation - - /** - * Capabilities specific to the `textDocument/codeAction` - */ - CodeActionCapabilities codeAction - - /** - * Capabilities specific to the `textDocument/codeLens` - */ - CodeLensCapabilities codeLens - - /** - * Capabilities specific to the `textDocument/documentLink` - */ - DocumentLinkCapabilities documentLink - - /** - * Capabilities specific to the `textDocument/documentColor` and the - * `textDocument/colorPresentation` request. - * - * Since 3.6.0 - */ - ColorProviderCapabilities colorProvider - - /** - * Capabilities specific to the `textDocument/rename` - */ - RenameCapabilities rename - - /** + + /** + * Capabilities specific to the `textDocument/completion` + */ + CompletionCapabilities completion + + /** + * Capabilities specific to the `textDocument/hover` + */ + HoverCapabilities hover + + /** + * Capabilities specific to the `textDocument/signatureHelp` + */ + SignatureHelpCapabilities signatureHelp + + /** + * Capabilities specific to the `textDocument/references` + */ + ReferencesCapabilities references + + /** + * Capabilities specific to the `textDocument/documentHighlight` + */ + DocumentHighlightCapabilities documentHighlight + + /** + * Capabilities specific to the `textDocument/documentSymbol` + */ + DocumentSymbolCapabilities documentSymbol + + /** + * Capabilities specific to the `textDocument/formatting` + */ + FormattingCapabilities formatting + + /** + * Capabilities specific to the `textDocument/rangeFormatting` + */ + RangeFormattingCapabilities rangeFormatting + + /** + * Capabilities specific to the `textDocument/onTypeFormatting` + */ + OnTypeFormattingCapabilities onTypeFormatting + + /** + * Capabilities specific to the `textDocument/definition` + */ + DefinitionCapabilities definition + + /** + * Capabilities specific to the `textDocument/typeDefinition` + * + * Since 3.6.0 + */ + TypeDefinitionCapabilities typeDefinition + + /** + * Capabilities specific to the `textDocument/implementation` + * + * Since 3.6.0 + */ + ImplementationCapabilities implementation + + /** + * Capabilities specific to the `textDocument/codeAction` + */ + CodeActionCapabilities codeAction + + /** + * Capabilities specific to the `textDocument/codeLens` + */ + CodeLensCapabilities codeLens + + /** + * Capabilities specific to the `textDocument/documentLink` + */ + DocumentLinkCapabilities documentLink + + /** + * Capabilities specific to the `textDocument/documentColor` and the + * `textDocument/colorPresentation` request. + * + * Since 3.6.0 + */ + ColorProviderCapabilities colorProvider + + /** + * Capabilities specific to the `textDocument/rename` + */ + RenameCapabilities rename + + /** * Capabilities specific to `textDocument/publishDiagnostics`. */ PublishDiagnosticsCapabilities publishDiagnostics - + /** * Capabilities specific to `textDocument/foldingRange` requests. * @@ -868,76 +882,76 @@ class TextDocumentClientCapabilities { @JsonRpcData class ClientCapabilities { /** - * Workspace specific client capabilities. - */ - WorkspaceClientCapabilities workspace - - /** - * Text document specific client capabilities. - */ - TextDocumentClientCapabilities textDocument - - /** - * Experimental client capabilities. - */ - @JsonAdapter(JsonElementTypeAdapter.Factory) - Object experimental - - new() { - } - - new(WorkspaceClientCapabilities workspace, TextDocumentClientCapabilities textDocument, Object experimental) { - this.workspace = workspace - this.textDocument = textDocument - this.experimental = experimental - } + * Workspace specific client capabilities. + */ + WorkspaceClientCapabilities workspace + + /** + * Text document specific client capabilities. + */ + TextDocumentClientCapabilities textDocument + + /** + * Experimental client capabilities. + */ + @JsonAdapter(JsonElementTypeAdapter.Factory) + Object experimental + + new() { + } + + new(WorkspaceClientCapabilities workspace, TextDocumentClientCapabilities textDocument, Object experimental) { + this.workspace = workspace + this.textDocument = textDocument + this.experimental = experimental + } } /** * A code action represents a change that can be performed in code, e.g. to fix a problem or * to refactor code. - * + * * A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed. */ - @JsonRpcData +@JsonRpcData class CodeAction { - /** - * A short, human-readable, title for this code action. - */ - @NonNull - String title - - /** - * The kind of the code action. - * - * Used to filter code actions. - */ - String kind - - /** - * The diagnostics that this code action resolves. - */ - List diagnostics - - /** - * The workspace edit this code action performs. - */ - WorkspaceEdit edit - - /** - * A command this code action executes. If a code action - * provides a edit and a command, first the edit is - * executed and then the command. - */ - Command command - - new() { - } - - new(@NonNull String title) { - this.title = title - } - + /** + * A short, human-readable, title for this code action. + */ + @NonNull + String title + + /** + * The kind of the code action. + * + * Used to filter code actions. + */ + String kind + + /** + * The diagnostics that this code action resolves. + */ + List diagnostics + + /** + * The workspace edit this code action performs. + */ + WorkspaceEdit edit + + /** + * A command this code action executes. If a code action + * provides a edit and a command, first the edit is + * executed and then the command. + */ + Command command + + new() { + } + + new(@NonNull String title) { + this.title = title + } + } /** @@ -950,28 +964,28 @@ class CodeActionContext { */ @NonNull List diagnostics - + /** * Requested kind of actions to return. - * + * * Actions not of this kind are filtered out by the client before being shown. So servers * can omit computing them. - * + * * See {@link CodeActionKind} for allowed values. */ List only - new() { - } - - new(@NonNull List diagnostics) { - this.diagnostics = diagnostics - } - - new(@NonNull List diagnostics, List only) { - this(diagnostics) - this.only = only - } + new() { + } + + new(@NonNull List diagnostics) { + this.diagnostics = diagnostics + } + + new(@NonNull List diagnostics, List only) { + this(diagnostics) + this.only = only + } } /** @@ -998,15 +1012,15 @@ class CodeActionParams { */ @NonNull CodeActionContext context - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument, @NonNull Range range, @NonNull CodeActionContext context) { - this.textDocument = textDocument - this.range = range - this.context = context - } + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Range range, @NonNull CodeActionContext context) { + this.textDocument = textDocument + this.range = range + this.context = context + } } /** @@ -1034,19 +1048,19 @@ class CodeLens { */ @JsonAdapter(JsonElementTypeAdapter.Factory) Object data - - new() { - } - - new(@NonNull Range range) { - this.range = range - } - - new(@NonNull Range range, Command command, Object data) { - this(range) - this.command = command - this.data = data - } + + new() { + } + + new(@NonNull Range range) { + this.range = range + } + + new(@NonNull Range range, Command command, Object data) { + this(range) + this.command = command + this.data = data + } } /** @@ -1056,15 +1070,15 @@ class CodeLens { class CodeActionOptions { /** * CodeActionKinds that this server may return. - * + * * The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server * may list out every specific kind they provide. */ List codeActionKinds - + new() { } - + new (List codeActionKinds) { this.codeActionKinds = codeActionKinds } @@ -1080,13 +1094,13 @@ class CodeLensOptions { * Code lens has a resolve provider as well. */ boolean resolveProvider - - new() { - } - - new(boolean resolveProvider) { - this.resolveProvider = resolveProvider - } + + new() { + } + + new(boolean resolveProvider) { + this.resolveProvider = resolveProvider + } } /** @@ -1099,13 +1113,13 @@ class CodeLensParams { */ @NonNull TextDocumentIdentifier textDocument - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument) { - this.textDocument = textDocument - } + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument) { + this.textDocument = textDocument + } } /** @@ -1130,19 +1144,19 @@ class Command { * Arguments that the command handler should be invoked with. */ List arguments - - new() { - } - - new(@NonNull String title, @NonNull String command) { - this.title = title - this.command = command - } - - new(@NonNull String title, @NonNull String command, List arguments) { - this(title, command) - this.arguments = arguments - } + + new() { + } + + new(@NonNull String title, @NonNull String command) { + this.title = title + this.command = command + } + + new(@NonNull String title, @NonNull String command, List arguments) { + this(title, command) + this.arguments = arguments + } } /** @@ -1173,7 +1187,7 @@ class CompletionItem { * A human-readable string that represents a doc-comment. */ Either documentation - + /** * Indicates if this item is deprecated. */ @@ -1181,7 +1195,7 @@ class CompletionItem { /** * Select this item when showing. - * + * * *Note* that only one completion item can be selected and that the * tool / client decides which item that is. The rule is that the *first* * item of those that match best is selected. @@ -1202,33 +1216,33 @@ class CompletionItem { * A string that should be inserted a document when selecting this completion. When `falsy` the label is used. */ String insertText - + /** - * The format of the insert text. The format applies to both the `insertText` property - * and the `newText` property of a provided `textEdit`. - */ - InsertTextFormat insertTextFormat + * The format of the insert text. The format applies to both the `insertText` property + * and the `newText` property of a provided `textEdit`. + */ + InsertTextFormat insertTextFormat - /** - * An edit which is applied to a document when selecting this completion. When an edit is provided the value of - * `insertText` is ignored. - * - * *Note:* The range of the edit must be a single line range and it must contain the position at which completion - * has been requested. - */ - TextEdit textEdit + /** + * An edit which is applied to a document when selecting this completion. When an edit is provided the value of + * `insertText` is ignored. + * + * *Note:* The range of the edit must be a single line range and it must contain the position at which completion + * has been requested. + */ + TextEdit textEdit /** * An optional array of additional text edits that are applied when * selecting this completion. Edits must not overlap (including the same insert position) * with the main edit nor with themselves. - * + * * Additional text edits should be used to change text unrelated to the current cursor position * (for example adding an import statement at the top of the file if the completion item will * insert an unqualified type). */ List additionalTextEdits - + /** * An optional set of characters that when pressed while this completion is active will accept it first and * then type that character. *Note* that all commit characters should have `length=1` and that superfluous @@ -1248,10 +1262,10 @@ class CompletionItem { */ @JsonAdapter(JsonElementTypeAdapter.Factory) Object data - + new() { } - + new(@NonNull String label) { this.label = label } @@ -1272,19 +1286,19 @@ class CompletionList { */ @NonNull List items - - new() { - this(new ArrayList) - } - - new(@NonNull List items) { - this.items = items - } - - new(boolean isIncomplete, @NonNull List items) { - this(items) - this.isIncomplete = isIncomplete - } + + new() { + this(new ArrayList) + } + + new(@NonNull List items) { + this.items = items + } + + new(boolean isIncomplete, @NonNull List items) { + this(items) + this.isIncomplete = isIncomplete + } } /** @@ -1301,14 +1315,14 @@ class CompletionOptions { * The characters that trigger completion automatically. */ List triggerCharacters - - new() { - } - - new(Boolean resolveProvider, List triggerCharacters) { - this.resolveProvider = resolveProvider - this.triggerCharacters = triggerCharacters - } + + new() { + } + + new(Boolean resolveProvider, List triggerCharacters) { + this.resolveProvider = resolveProvider + this.triggerCharacters = triggerCharacters + } } /** @@ -1343,7 +1357,7 @@ class Diagnostic { */ @NonNull String message - + /** * An array of related diagnostic information, e.g. when symbol-names within a scope collide * all definitions can be marked via this property. @@ -1351,21 +1365,21 @@ class Diagnostic { * Since 3.7.0 */ List relatedInformation - + new() { } - + new(@NonNull Range range, @NonNull String message) { this.range = range this.message = message } - + new(@NonNull Range range, @NonNull String message, DiagnosticSeverity severity, String source) { this(range, message) this.severity = severity this.source = source } - + new(@NonNull Range range, @NonNull String message, DiagnosticSeverity severity, String source, String code) { this(range, message, severity, source) this.code = code @@ -1392,10 +1406,10 @@ class DiagnosticRelatedInformation { */ @NonNull String message - + new() { } - + new(@NonNull Location location, @NonNull String message) { this.location = location this.message = message @@ -1413,13 +1427,13 @@ class DidChangeConfigurationParams { @NonNull @JsonAdapter(JsonElementTypeAdapter.Factory) Object settings - - new() { - } - - new(@NonNull Object settings) { - this.settings = settings - } + + new() { + } + + new(@NonNull Object settings) { + this.settings = settings + } } /** @@ -1445,20 +1459,20 @@ class DidChangeTextDocumentParams { */ @NonNull List contentChanges = new ArrayList - - new() { - } - - new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List contentChanges) { - this.textDocument = textDocument - this.contentChanges = contentChanges - } - - @Deprecated - new(@NonNull VersionedTextDocumentIdentifier textDocument, String uri, @NonNull List contentChanges) { - this(textDocument, contentChanges) - this.uri = uri - } + + new() { + } + + new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List contentChanges) { + this.textDocument = textDocument + this.contentChanges = contentChanges + } + + @Deprecated + new(@NonNull VersionedTextDocumentIdentifier textDocument, String uri, @NonNull List contentChanges) { + this(textDocument, contentChanges) + this.uri = uri + } } /** @@ -1472,14 +1486,14 @@ class DidChangeWatchedFilesParams { */ @NonNull List changes - - new() { - this(new ArrayList) - } - - new(@NonNull List changes) { - this.changes = changes - } + + new() { + this(new ArrayList) + } + + new(@NonNull List changes) { + this.changes = changes + } } @JsonRpcData @@ -1489,10 +1503,10 @@ class DidChangeWatchedFilesRegistrationOptions { */ @NonNull List watchers - + new() { } - + new(@NonNull List watchers) { this.watchers = watchers } @@ -1505,21 +1519,21 @@ class FileSystemWatcher { */ @NonNull String globPattern - + /** * The kind of events of interest. If omitted it defaults * to WatchKind.Create | WatchKind.Change | WatchKind.Delete * which is 7. */ Integer kind - + new() { } - + new(@NonNull String globPattern) { this.globPattern = globPattern } - + new(@NonNull String globPattern, Integer kind) { this.globPattern = globPattern this.kind = kind @@ -1538,13 +1552,13 @@ class DidCloseTextDocumentParams { */ @NonNull TextDocumentIdentifier textDocument - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument) { - this.textDocument = textDocument - } + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument) { + this.textDocument = textDocument + } } /** @@ -1565,19 +1579,19 @@ class DidOpenTextDocumentParams { */ @Deprecated String text - - new() { - } - - new(@NonNull TextDocumentItem textDocument) { - this.textDocument = textDocument - } - - @Deprecated + + new() { + } + + new(@NonNull TextDocumentItem textDocument) { + this.textDocument = textDocument + } + + @Deprecated new(@NonNull TextDocumentItem textDocument, String text) { - this(textDocument) - this.text = text - } + this(textDocument) + this.text = text + } } /** @@ -1590,24 +1604,24 @@ class DidSaveTextDocumentParams { */ @NonNull TextDocumentIdentifier textDocument - + /** - * Optional the content when saved. Depends on the includeText value - * when the save notification was requested. - */ - String text - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument) { - this.textDocument = textDocument - } - - new(@NonNull TextDocumentIdentifier textDocument, String text) { - this(textDocument) - this.text = text - } + * Optional the content when saved. Depends on the includeText value + * when the save notification was requested. + */ + String text + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument) { + this.textDocument = textDocument + } + + new(@NonNull TextDocumentIdentifier textDocument, String text) { + this(textDocument) + this.text = text + } } @@ -1618,20 +1632,20 @@ class WillSaveTextDocumentParams { */ @NonNull TextDocumentIdentifier textDocument - + /** * A reason why a text document is saved. */ @NonNull TextDocumentSaveReason reason - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument, @NonNull TextDocumentSaveReason reason) { - this.textDocument = textDocument - this.reason = reason - } + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull TextDocumentSaveReason reason) { + this.textDocument = textDocument + this.reason = reason + } } /** @@ -1650,14 +1664,14 @@ class DocumentFormattingParams { */ @NonNull FormattingOptions options - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument, @NonNull FormattingOptions options) { - this.textDocument = textDocument - this.options = options - } + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull FormattingOptions options) { + this.textDocument = textDocument + this.options = options + } } /** @@ -1676,18 +1690,18 @@ class DocumentHighlight { * The highlight kind, default is {@link DocumentHighlightKind#Text}. */ DocumentHighlightKind kind - - new() { - } - - new(@NonNull Range range) { - this.range = range - } - - new(@NonNull Range range, DocumentHighlightKind kind) { - this(range) - this.kind = kind - } + + new() { + } + + new(@NonNull Range range) { + this.range = range + } + + new(@NonNull Range range, DocumentHighlightKind kind) { + this(range) + this.kind = kind + } } /** @@ -1737,18 +1751,18 @@ class DocumentLink { */ @JsonRpcData class DocumentLinkParams { - /** - * The document to provide document links for. - */ - @NonNull - TextDocumentIdentifier textDocument - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument) { - this.textDocument = textDocument - } + /** + * The document to provide document links for. + */ + @NonNull + TextDocumentIdentifier textDocument + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument) { + this.textDocument = textDocument + } } /** @@ -1757,16 +1771,16 @@ class DocumentLinkParams { @JsonRpcData class DocumentLinkOptions { /** - * Document links have a resolve provider as well. - */ - Boolean resolveProvider - - new() { - } - - new(Boolean resolveProvider) { - this.resolveProvider = resolveProvider - } + * Document links have a resolve provider as well. + */ + Boolean resolveProvider + + new() { + } + + new(Boolean resolveProvider) { + this.resolveProvider = resolveProvider + } } /** @@ -1775,18 +1789,18 @@ class DocumentLinkOptions { @JsonRpcData class ExecuteCommandOptions { /** - * The commands to be executed on the server - */ - @NonNull - List commands - - new() { - this(new ArrayList) - } - - new(@NonNull List commands) { - this.commands = commands - } + * The commands to be executed on the server + */ + @NonNull + List commands + + new() { + this(new ArrayList) + } + + new(@NonNull List commands) { + this.commands = commands + } } /** @@ -1795,16 +1809,16 @@ class ExecuteCommandOptions { @JsonRpcData class SaveOptions { /** - * The client is supposed to include the content on save. - */ - Boolean includeText - - new() { - } - - new(Boolean includeText) { - this.includeText = includeText - } + * The client is supposed to include the content on save. + */ + Boolean includeText + + new() { + } + + new(Boolean includeText) { + this.includeText = includeText + } } /** @@ -1824,26 +1838,26 @@ class FoldingRangeProviderOptions extends StaticRegistrationOptions { @JsonRpcData class TextDocumentSyncOptions { /** - * Open and close notifications are sent to the server. - */ - Boolean openClose - /** - * Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full - * and TextDocumentSyncKind.Incremental. - */ - TextDocumentSyncKind change - /** - * Will save notifications are sent to the server. - */ - Boolean willSave - /** - * Will save wait until requests are sent to the server. - */ - Boolean willSaveWaitUntil - /** - * Save notifications are sent to the server. - */ - SaveOptions save + * Open and close notifications are sent to the server. + */ + Boolean openClose + /** + * Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full + * and TextDocumentSyncKind.Incremental. + */ + TextDocumentSyncKind change + /** + * Will save notifications are sent to the server. + */ + Boolean willSave + /** + * Will save wait until requests are sent to the server. + */ + Boolean willSaveWaitUntil + /** + * Save notifications are sent to the server. + */ + SaveOptions save } /** @@ -1856,10 +1870,10 @@ class StaticRegistrationOptions extends TextDocumentRegistrationOptions { * the request again. See also Registration#id. */ String id - + new() { } - + new(String id) { this.id = id } @@ -1880,18 +1894,18 @@ class DocumentOnTypeFormattingOptions { * More trigger characters. */ List moreTriggerCharacter - - new() { - } - - new(@NonNull String firstTriggerCharacter) { - this.firstTriggerCharacter = firstTriggerCharacter - } - - new(@NonNull String firstTriggerCharacter, List moreTriggerCharacter) { - this.firstTriggerCharacter = firstTriggerCharacter - this.moreTriggerCharacter = moreTriggerCharacter - } + + new() { + } + + new(@NonNull String firstTriggerCharacter) { + this.firstTriggerCharacter = firstTriggerCharacter + } + + new(@NonNull String firstTriggerCharacter, List moreTriggerCharacter) { + this.firstTriggerCharacter = firstTriggerCharacter + this.moreTriggerCharacter = moreTriggerCharacter + } } /** @@ -1910,14 +1924,14 @@ class DocumentOnTypeFormattingParams extends DocumentFormattingParams { */ @NonNull String ch - - new() { - } - - new(@NonNull Position position, @NonNull String ch) { - this.position = position - this.ch = ch - } + + new() { + } + + new(@NonNull Position position, @NonNull String ch) { + this.position = position + this.ch = ch + } } /** @@ -1930,13 +1944,13 @@ class DocumentRangeFormattingParams extends DocumentFormattingParams { */ @NonNull Range range - - new() { - } - - new(@NonNull Range range) { - this.range = range - } + + new() { + } + + new(@NonNull Range range) { + this.range = range + } } /** @@ -1949,13 +1963,13 @@ class DocumentSymbolParams { */ @NonNull TextDocumentIdentifier textDocument - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument) { - this.textDocument = textDocument - } + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument) { + this.textDocument = textDocument + } } /** @@ -1974,14 +1988,14 @@ class FileEvent { */ @NonNull FileChangeType type - - new() { - } - - new(@NonNull String uri, @NonNull FileChangeType type) { - this.uri = uri - this.type = type - } + + new() { + } + + new(@NonNull String uri, @NonNull FileChangeType type) { + this.uri = uri + this.type = type + } } /** @@ -1992,114 +2006,114 @@ class FormattingOptions extends LinkedHashMap properties) { - this(tabSize, insertSpaces) - setProperties(properties) - } - - def String getString(String key) { - get(key)?.getFirst - } - - def void putString(String key, String value) { - put(key, Either3.forFirst(value)) - } - - def Number getNumber(String key) { - get(key)?.getSecond - } - - def void putNumber(String key, Number value) { - put(key, Either3.forSecond(value)) - } - - def Boolean getBoolean(String key) { - get(key)?.getThird - } - - def void putBoolean(String key, Boolean value) { - put(key, Either3.forThird(value)) - } - + new() { + } + + new(int tabSize, boolean insertSpaces) { + this.tabSize = tabSize + this.insertSpaces = insertSpaces + } + + /** + * @deprecated See https://github.com/eclipse/lsp4j/issues/99 + */ + @Deprecated + new(int tabSize, boolean insertSpaces, Map properties) { + this(tabSize, insertSpaces) + setProperties(properties) + } + + def String getString(String key) { + get(key)?.getFirst + } + + def void putString(String key, String value) { + put(key, Either3.forFirst(value)) + } + + def Number getNumber(String key) { + get(key)?.getSecond + } + + def void putNumber(String key, Number value) { + put(key, Either3.forSecond(value)) + } + + def Boolean getBoolean(String key) { + get(key)?.getThird + } + + def void putBoolean(String key, Boolean value) { + put(key, Either3.forThird(value)) + } + /** * Size of a tab in spaces. */ - def int getTabSize() { - val value = getNumber(TAB_SIZE) - if (value !== null) - return value.intValue - else - return 0 - } - - def void setTabSize(int tabSize) { - putNumber(TAB_SIZE, tabSize) - } - - /** + def int getTabSize() { + val value = getNumber(TAB_SIZE) + if (value !== null) + return value.intValue + else + return 0 + } + + def void setTabSize(int tabSize) { + putNumber(TAB_SIZE, tabSize) + } + + /** * Prefer spaces over tabs. */ - def boolean isInsertSpaces() { - val value = getBoolean(INSERT_SPACES) - if (value !== null) - return value - else - return false - } - - def void setInsertSpaces(boolean insertSpaces) { - putBoolean(INSERT_SPACES, insertSpaces) - } - - /** - * @deprecated See https://github.com/eclipse/lsp4j/issues/99 - */ - @Deprecated - def Map getProperties() { - val properties = newLinkedHashMap - for (entry : entrySet) { - val value = switch it: entry.value { - case isFirst: getFirst - case isSecond: getSecond - case isThird: getThird - } - if (value !== null) - properties.put(entry.key, value.toString) - } - return properties.unmodifiableView - } - - /** - * @deprecated See https://github.com/eclipse/lsp4j/issues/99 - */ - @Deprecated - def void setProperties(Map properties) { - for (entry : properties.entrySet) { - putString(entry.key, entry.value) - } - } - + def boolean isInsertSpaces() { + val value = getBoolean(INSERT_SPACES) + if (value !== null) + return value + else + return false + } + + def void setInsertSpaces(boolean insertSpaces) { + putBoolean(INSERT_SPACES, insertSpaces) + } + + /** + * @deprecated See https://github.com/eclipse/lsp4j/issues/99 + */ + @Deprecated + def Map getProperties() { + val properties = newLinkedHashMap + for (entry : entrySet) { + val value = switch it: entry.value { + case isFirst: getFirst + case isSecond: getSecond + case isThird: getThird + } + if (value !== null) + properties.put(entry.key, value.toString) + } + return properties.unmodifiableView + } + + /** + * @deprecated See https://github.com/eclipse/lsp4j/issues/99 + */ + @Deprecated + def void setProperties(Map properties) { + for (entry : properties.entrySet) { + putString(entry.key, entry.value) + } + } + } /** * A MarkupContent literal represents a string value which content is interpreted based on its * kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds. - * + * * If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. * See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting - * + * * Please Note that clients might sanitize the return markdown. A client could decide to * remove HTML from the markdown to avoid script execution. */ @@ -2134,27 +2148,27 @@ class Hover { * An optional range */ Range range - - new() { - } - - new(@NonNull List> contents) { - this.contents = contents - } - - new(@NonNull List> contents, Range range) { - this.contents = contents - this.range = range - } - - new(@NonNull MarkupContent contents) { - this.contents = contents - } - - new(@NonNull MarkupContent contents, Range range) { - this.contents = contents - this.range = range - } + + new() { + } + + new(@NonNull List> contents) { + this.contents = contents + } + + new(@NonNull List> contents, Range range) { + this.contents = contents + this.range = range + } + + new(@NonNull MarkupContent contents) { + this.contents = contents + } + + new(@NonNull MarkupContent contents, Range range) { + this.contents = contents + this.range = range + } } /** @@ -2162,29 +2176,29 @@ class Hover { * or a code-block that provides a language and a code snippet. The language identifier * is sematically equal to the optional language identifier in fenced code blocks in GitHub * issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting - * + * * The pair of a language and a value is an equivalent to markdown: * ```${language} * ${value} * ``` - * + * * Note that markdown strings will be sanitized - that means html will be escaped. */ @JsonRpcData class MarkedString { @NonNull String language - + @NonNull String value - - new() { - } - - new(@NonNull String language, @NonNull String value) { - this.language = language - this.value = value - } + + new() { + } + + new(@NonNull String language, @NonNull String value) { + this.language = language + this.value = value + } } @JsonRpcData @@ -2196,13 +2210,13 @@ class InitializeError { * (3) if user selected retry the initialize method is sent again. */ boolean retry - - new() { - } - - new(boolean retry) { - this.retry = retry - } + + new() { + } + + new(boolean retry) { + this.retry = retry + } } /** @@ -2210,13 +2224,13 @@ class InitializeError { */ interface InitializeErrorCode { /** - * If the protocol version provided by the client can't be handled by the server. - * - * @deprecated This initialize error got replaced by client capabilities. - * There is no version handshake in version 3.0x - */ - @Deprecated - val unknownProtocolVersion = 1 + * If the protocol version provided by the client can't be handled by the server. + * + * @deprecated This initialize error got replaced by client capabilities. + * There is no version handshake in version 3.0x + */ + @Deprecated + val unknownProtocolVersion = 1 } /** @@ -2237,11 +2251,11 @@ class InitializeParams { */ @Deprecated String rootPath - + /** - * The rootUri of the workspace. Is null if no folder is open. - * If both `rootPath` and `rootUri` are set, `rootUri` wins. - */ + * The rootUri of the workspace. Is null if no folder is open. + * If both `rootPath` and `rootUri` are set, `rootUri` wins. + */ String rootUri /** @@ -2261,20 +2275,20 @@ class InitializeParams { */ @Deprecated String clientName - + /** - * The initial trace setting. If omitted trace is disabled ('off'). - * - * Legal values: 'off' | 'messages' | 'verbose' - */ - String trace - + * The initial trace setting. If omitted trace is disabled ('off'). + * + * Legal values: 'off' | 'messages' | 'verbose' + */ + String trace + /** * The workspace folders configured in the client when the server starts. * This property is only available if the client supports workspace folders. * It can be `null` if the client supports workspace folders but none are * configured. - * + * * Since 3.6.0 */ List workspaceFolders @@ -2287,18 +2301,18 @@ class InitializeResult { */ @NonNull ServerCapabilities capabilities - - new() { - } - - new(@NonNull ServerCapabilities capabilities) { - this.capabilities = capabilities - } + + new() { + } + + new(@NonNull ServerCapabilities capabilities) { + this.capabilities = capabilities + } } @JsonRpcData class InitializedParams { - + } /** @@ -2311,14 +2325,14 @@ class Location { @NonNull Range range - - new() { - } - - new(@NonNull String uri, @NonNull Range range) { - this.uri = uri - this.range = range - } + + new() { + } + + new(@NonNull String uri, @NonNull Range range) { + this.uri = uri + this.range = range + } } /** @@ -2333,13 +2347,13 @@ class MessageActionItem { */ @NonNull String title - - new() { - } - - new(@NonNull String title) { - this.title = title - } + + new() { + } + + new(@NonNull String title) { + this.title = title + } } /** @@ -2361,14 +2375,14 @@ class MessageParams { */ @NonNull String message - - new() { - } - - new(@NonNull MessageType type, @NonNull String message) { - this.type = type - this.message = message - } + + new() { + } + + new(@NonNull MessageType type, @NonNull String message) { + this.type = type + this.message = message + } } /** @@ -2386,23 +2400,23 @@ class ParameterInformation { * The human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. */ Either documentation - - new() { - } - - new(@NonNull String label) { - this.label = label - } - - new(@NonNull String label, String documentation) { - this.label = label - this.documentation = documentation - } - - new(@NonNull String label, MarkupContent documentation) { - this.label = label - this.documentation = documentation - } + + new() { + } + + new(@NonNull String label) { + this.label = label + } + + new(@NonNull String label, String documentation) { + this.label = label + this.documentation = documentation + } + + new(@NonNull String label, MarkupContent documentation) { + this.label = label + this.documentation = documentation + } } /** @@ -2419,14 +2433,14 @@ class Position { * Character offset on a line in a document (zero-based). */ int character - - new() { - } - - new(int line, int character) { - this.line = line - this.character = character - } + + new() { + } + + new(int line, int character) { + this.line = line + this.character = character + } } /** @@ -2445,15 +2459,15 @@ class PublishDiagnosticsParams { */ @NonNull List diagnostics - - new() { - this.diagnostics = new ArrayList - } - - new(@NonNull String uri, @NonNull List diagnostics) { - this.uri = uri - this.diagnostics = diagnostics - } + + new() { + this.diagnostics = new ArrayList + } + + new(@NonNull String uri, @NonNull List diagnostics) { + this.uri = uri + this.diagnostics = diagnostics + } } /** @@ -2472,14 +2486,14 @@ class Range { */ @NonNull Position end - - new() { - } - - new(@NonNull Position start, @NonNull Position end) { - this.start = start - this.end = end - } + + new() { + } + + new(@NonNull Position start, @NonNull Position end) { + this.start = start + this.end = end + } } /** @@ -2492,13 +2506,13 @@ class ReferenceContext { * Include the declaration of the current symbol. */ boolean includeDeclaration - - new() { - } - - new(boolean includeDeclaration) { - this.includeDeclaration = includeDeclaration - } + + new() { + } + + new(boolean includeDeclaration) { + this.includeDeclaration = includeDeclaration + } } /** @@ -2509,13 +2523,33 @@ class ReferenceContext { class ReferenceParams extends TextDocumentPositionParams { @NonNull ReferenceContext context - - new() { - } - - new(@NonNull ReferenceContext context) { - this.context = context - } + + new() { + } + + new(@NonNull ReferenceContext context) { + this.context = context + } +} + +@JsonRpcData +class PrepareRenameResult { + /** + * The capabilities the language server provides. + */ + @NonNull + Range range + + @NonNull + String placeholder + + new() { + } + + new(@NonNull Range range, @NonNull String placeholder) { + this.range = range + this.placeholder = placeholder + } } /** @@ -2530,26 +2564,44 @@ class RenameParams { TextDocumentIdentifier textDocument /** - * The position at which this request was send. + * The position at which this request was send. + */ + @NonNull + Position position + + /** + * The new name of the symbol. If the given name is not valid the request must return a + * ResponseError with an appropriate message set. + */ + @NonNull + String newName + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position, @NonNull String newName) { + this.textDocument = textDocument + this.position = position + this.newName = newName + } +} + +/** + * Rename options + */ +@JsonRpcData +class RenameOptions { + /** + * Renames should be checked and tested before being executed. */ - @NonNull - Position position + Boolean prepareProvider; - /** - * The new name of the symbol. If the given name is not valid the request must return a - * ResponseError with an appropriate message set. - */ - @NonNull - String newName - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position, @NonNull String newName) { - this.textDocument = textDocument - this.position = position - this.newName = newName - } + new() { + } + + new(Boolean prepareProvider) { + this.prepareProvider = prepareProvider + } } @JsonRpcData @@ -2644,7 +2696,7 @@ class ServerCapabilities { /** * The server provides rename support. */ - Boolean renameProvider + Either renameProvider /** * The server provides document link support. @@ -2660,7 +2712,7 @@ class ServerCapabilities { /** * The server provides folding provider support. - * + * * Since 3.10.0 */ Either foldingRangeProvider @@ -2674,11 +2726,11 @@ class ServerCapabilities { * Workspace specific server capabilities */ WorkspaceServerCapabilities workspace - + /** * Semantic highlighting server capabilities. */ - SemanticHighlightingServerCapabilities semanticHighlighting; + SemanticHighlightingServerCapabilities semanticHighlighting; /** * Experimental server capabilities. @@ -2695,14 +2747,14 @@ class ServerCapabilities { class WorkspaceServerCapabilities { /** * The server supports workspace folder. - * + * * Since 3.6.0 */ WorkspaceFoldersOptions workspaceFolders - + new() { } - + new(WorkspaceFoldersOptions workspaceFolders) { this.workspaceFolders = workspaceFolders } @@ -2722,10 +2774,10 @@ class SemanticHighlightingServerCapabilities { * the server. */ List> scopes; - + new() { } - + new(List> scopes) { this.scopes = scopes; } @@ -2743,13 +2795,13 @@ class ShowMessageRequestParams extends MessageParams { * The message action items to present. */ List actions - - new() { - } - - new(List actions) { - this.actions = actions - } + + new() { + } + + new(List actions) { + this.actions = actions + } } /** @@ -2785,16 +2837,16 @@ class SignatureHelp { * active signature does have any. */ Integer activeParameter - - new() { - this.signatures = new ArrayList - } - - new(@NonNull List signatures, Integer activeSignature, Integer activeParameter) { - this.signatures = signatures - this.activeSignature = activeSignature - this.activeParameter = activeParameter - } + + new() { + this.signatures = new ArrayList + } + + new(@NonNull List signatures, Integer activeSignature, Integer activeParameter) { + this.signatures = signatures + this.activeSignature = activeSignature + this.activeParameter = activeParameter + } } /** @@ -2806,13 +2858,13 @@ class SignatureHelpOptions { * The characters that trigger signature help automatically. */ List triggerCharacters - - new() { - } - - new(List triggerCharacters) { - this.triggerCharacters = triggerCharacters - } + + new() { + } + + new(List triggerCharacters) { + this.triggerCharacters = triggerCharacters + } } /** @@ -2836,25 +2888,25 @@ class SignatureInformation { * The parameters of this signature. */ List parameters - - new() { - } - - new(@NonNull String label) { - this.label = label - } - - new(@NonNull String label, String documentation, List parameters) { - this.label = label - this.documentation = documentation - this.parameters = parameters - } - - new(@NonNull String label, MarkupContent documentation, List parameters) { - this.label = label - this.documentation = documentation - this.parameters = parameters - } + + new() { + } + + new(@NonNull String label) { + this.label = label + } + + new(@NonNull String label, String documentation, List parameters) { + this.label = label + this.documentation = documentation + this.parameters = parameters + } + + new(@NonNull String label, MarkupContent documentation, List parameters) { + this.label = label + this.documentation = documentation + this.parameters = parameters + } } /** @@ -2862,7 +2914,7 @@ class SignatureInformation { * hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range, * e.g. the range of an identifier. */ - @JsonRpcData +@JsonRpcData class DocumentSymbol { /** @@ -2876,7 +2928,7 @@ class DocumentSymbol { */ @NonNull SymbolKind kind - + /** * The range enclosing this symbol not including leading/trailing whitespace but everything else * like comments. This information is typically used to determine if the the clients cursor is @@ -2907,33 +2959,33 @@ class DocumentSymbol { * Children of this symbol, e.g. properties of a class. */ List children - - new() { - } - - new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Range range, @NonNull Range selectionRange) { - this.name = name - this.kind = kind - this.range = range - this.selectionRange = selectionRange - } - - new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Range range, @NonNull Range selectionRange, String detail) { - this.name = name - this.kind = kind - this.range = range - this.selectionRange = selectionRange - this.detail = detail - } - - new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Range range, @NonNull Range selectionRange, String detail, List children) { - this.name = name - this.kind = kind - this.range = range - this.selectionRange = selectionRange - this.detail = detail - this.children = children - } + + new() { + } + + new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Range range, @NonNull Range selectionRange) { + this.name = name + this.kind = kind + this.range = range + this.selectionRange = selectionRange + } + + new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Range range, @NonNull Range selectionRange, String detail) { + this.name = name + this.kind = kind + this.range = range + this.selectionRange = selectionRange + this.detail = detail + } + + new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Range range, @NonNull Range selectionRange, String detail, List children) { + this.name = name + this.kind = kind + this.range = range + this.selectionRange = selectionRange + this.detail = detail + this.children = children + } } /** @@ -2952,7 +3004,7 @@ class SymbolInformation { */ @NonNull SymbolKind kind - + /** * Indicates if this symbol is deprecated. */ @@ -2964,7 +3016,7 @@ class SymbolInformation { * tool the range's start information is used to position the cursor. So * the range usually spans more then the actual symbol's name and does * normally include things like visibility modifiers. - * + * * The range doesn't have to denote a node range in the sense of a abstract * syntax tree. It can therefore not be used to re-construct a hierarchy of * the symbols. @@ -2979,22 +3031,22 @@ class SymbolInformation { * symbols. */ String containerName - - new() { - } - - new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Location location) { - this.name = name - this.kind = kind - this.location = location - } - - new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Location location, String containerName) { - this.name = name - this.kind = kind - this.location = location - this.containerName = containerName - } + + new() { + } + + new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Location location) { + this.name = name + this.kind = kind + this.location = location + } + + new(@NonNull String name, @NonNull SymbolKind kind, @NonNull Location location, String containerName) { + this.name = name + this.kind = kind + this.location = location + this.containerName = containerName + } } /** @@ -3018,19 +3070,19 @@ class TextDocumentContentChangeEvent { */ @NonNull String text - - new() { - } - - new(@NonNull String text) { - this.text = text - } - - new(Range range, Integer rangeLength, @NonNull String text) { - this.range = range - this.rangeLength = rangeLength - this.text = text - } + + new() { + } + + new(@NonNull String text) { + this.text = text + } + + new(Range range, Integer rangeLength, @NonNull String text) { + this.range = range + this.rangeLength = rangeLength + this.text = text + } } /** @@ -3043,13 +3095,13 @@ class TextDocumentIdentifier { */ @NonNull String uri - - new() { - } - - new(@NonNull String uri) { - this.uri = uri - } + + new() { + } + + new(@NonNull String uri) { + this.uri = uri + } } /** @@ -3079,16 +3131,16 @@ class TextDocumentItem { */ @NonNull String text - - new() { - } - - new(@NonNull String uri, @NonNull String languageId, int version, @NonNull String text) { - this.uri = uri - this.languageId = languageId - this.version = version - this.text = text - } + + new() { + } + + new(@NonNull String uri, @NonNull String languageId, int version, @NonNull String text) { + this.uri = uri + this.languageId = languageId + this.version = version + this.text = text + } } /** @@ -3113,21 +3165,21 @@ class TextDocumentPositionParams { */ @NonNull Position position - - new() { - } - - new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position) { - this.textDocument = textDocument - this.position = position - } - - @Deprecated + + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position) { + this.textDocument = textDocument + this.position = position + } + + @Deprecated new(@NonNull TextDocumentIdentifier textDocument, String uri, @NonNull Position position) { - this.textDocument = textDocument - this.uri = uri - this.position = position - } + this.textDocument = textDocument + this.uri = uri + this.position = position + } } @JsonRpcData @@ -3158,20 +3210,20 @@ class CompletionContext { */ @NonNull CompletionTriggerKind triggerKind - + /** * The trigger character (a single character) that has trigger code complete. * Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter` */ String triggerCharacter - + new() { } - + new(@NonNull CompletionTriggerKind triggerKind) { this.triggerKind = triggerKind } - + new(@NonNull CompletionTriggerKind triggerKind, String triggerCharacter) { this.triggerKind = triggerKind this.triggerCharacter = triggerCharacter @@ -3187,83 +3239,270 @@ class TextEdit { * The range of the text document to be manipulated. To insert text into a document create a range where start === end. */ @NonNull - Range range + Range range + + /** + * The string to be inserted. For delete operations use an empty string. + */ + @NonNull + String newText + + new() { + } + + new(@NonNull Range range, @NonNull String newText) { + this.range = range + this.newText = newText + } +} + +/** + * An identifier to denote a specific version of a text document. + */ +@JsonRpcData +@JsonAdapter(VersionedTextDocumentIdentifierTypeAdapter.Factory) +class VersionedTextDocumentIdentifier extends TextDocumentIdentifier { + /** + * The version number of this document. If a versioned text document identifier + * is sent from the server to the client and the file is not open in the editor + * (the server has not received an open notification before) the server can send + * `null` to indicate that the version is known and the content on disk is the + * truth (as specified with document content ownership). + */ + Integer version + + new() { + } + + new(@NonNull String uri, Integer version) { + super(uri) + this.version = version + } + + @Deprecated + new(Integer version) { + this.version = version + } +} + +/** + * Describes textual changes on a single text document. + * The text document is referred to as a `VersionedTextDocumentIdentifier` + * to allow clients to check the text document version before an edit is applied. + */ +@JsonRpcData +class TextDocumentEdit { + /** + * The text document to change. + */ + @NonNull + VersionedTextDocumentIdentifier textDocument + + /** + * The edits to be applied + */ + @NonNull + List edits + + new() { + } + + new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List edits) { + this.textDocument = textDocument + this.edits = edits + } +} + +@JsonRpcData +@JsonAdapter(ResourceOperationTypeAdapter) +class ResourceOperation { + + @NonNull + String kind; + + new() { + } + + new(@NonNull String kind) { + this.kind = kind; + } +} + +/** + * Options to create a file. + */ +@JsonRpcData +class CreateFileOptions { + /** + * Overwrite existing file. Overwrite wins over `ignoreIfExists` + */ + Boolean overwrite + + /** + * Ignore if exists. + */ + Boolean ignoreIfExists + + new() { + } + + new(Boolean overwrite, Boolean ignoreIfExists) { + this.overwrite = overwrite + this.ignoreIfExists = ignoreIfExists + } +} + +/** + * Create file operation + */ +@JsonRpcData +class CreateFile extends ResourceOperation { + + /** + * The resource to create. + */ + @NonNull + String uri + /** + * Additional options + */ + CreateFileOptions options + + new() { + super(ResourceOperationKind.Create) + } + + new(@NonNull String uri) { + super(ResourceOperationKind.Create) + this.uri = uri + } + + new(@NonNull String uri, CreateFileOptions options) { + super(ResourceOperationKind.Create) + this.uri = uri + this.options = options + } +} + +/** + * Rename file options + */ +@JsonRpcData +class RenameFileOptions { + /** + * Overwrite target if existing. Overwrite wins over `ignoreIfExists` + */ + Boolean overwrite + /** + * Ignores if target exists. + */ + Boolean ignoreIfExists + + new() { + } + + new(Boolean overwrite, Boolean ignoreIfExists) { + this.overwrite = overwrite + this.ignoreIfExists = ignoreIfExists + } +} + +/** + * Rename file operation + */ +@JsonRpcData +class RenameFile extends ResourceOperation { + /** + * The old (existing) location. + */ + @NonNull + String oldUri /** - * The string to be inserted. For delete operations use an empty string. + * The new location. */ @NonNull - String newText - - new() { - } - - new(@NonNull Range range, @NonNull String newText) { - this.range = range - this.newText = newText - } + String newUri + /** + * Rename options. + */ + RenameFileOptions options + + new() { + super(ResourceOperationKind.Rename) + } + + new(@NonNull String oldUri, @NonNull String newUri) { + super(ResourceOperationKind.Rename) + this.oldUri = oldUri + this.newUri = newUri + } + + new(@NonNull String oldUri, @NonNull String newUri, RenameFileOptions options) { + super(ResourceOperationKind.Rename) + this.oldUri = oldUri + this.newUri = newUri + this.options = options + } } /** - * An identifier to denote a specific version of a text document. + * Delete file options */ @JsonRpcData -@JsonAdapter(VersionedTextDocumentIdentifierTypeAdapter.Factory) -class VersionedTextDocumentIdentifier extends TextDocumentIdentifier { +class DeleteFileOptions { /** - * The version number of this document. If a versioned text document identifier - * is sent from the server to the client and the file is not open in the editor - * (the server has not received an open notification before) the server can send - * `null` to indicate that the version is known and the content on disk is the - * truth (as specified with document content ownership). + * Delete the content recursively if a folder is denoted. */ - Integer version - - new() { - } - - new(@NonNull String uri, Integer version) { - super(uri) - this.version = version - } - - @Deprecated - new(Integer version) { - this.version = version - } + Boolean recursive + /** + * Ignore the operation if the file doesn't exist. + */ + Boolean ignoreIfNotExists + + new() { + } + + new(Boolean recursive, Boolean ignoreIfNotExists) { + this.recursive = recursive + this.ignoreIfNotExists = ignoreIfNotExists + } } /** - * Describes textual changes on a single text document. - * The text document is referred to as a `VersionedTextDocumentIdentifier` - * to allow clients to check the text document version before an edit is applied. + * Delete file operation */ @JsonRpcData -class TextDocumentEdit { +class DeleteFile extends ResourceOperation { /** - * The text document to change. + * The file to delete. */ @NonNull - VersionedTextDocumentIdentifier textDocument - + String uri /** - * The edits to be applied + * Delete options. */ - @NonNull - List edits - - new() { - } - - new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List edits) { - this.textDocument = textDocument - this.edits = edits - } + DeleteFileOptions options + + new() { + super(ResourceOperationKind.Delete) + } + + new(@NonNull String uri) { + super(ResourceOperationKind.Delete) + this.uri = uri + } + + new(@NonNull String uri, DeleteFileOptions options) { + super(ResourceOperationKind.Delete) + this.uri = uri + this.options = options + } } /** * A resource change. - * + * * If both current and newUri has valid values this is considered to be a move operation. * If current has a valid value while newUri is null it is treated as a delete operation. * If current is null and newUri has a valid value a create operation is executed. @@ -3272,21 +3511,21 @@ class TextDocumentEdit { @Beta class ResourceChange { - /** - * The Uri for current resource. Required for delete and move operations - * otherwise it is null. - * - */ - String current + /** + * The Uri for current resource. Required for delete and move operations + * otherwise it is null. + * + */ + String current - /** - * The new uri for the resource. Required for create and move operations. - * otherwise null. - * - * Must be compatible with the current uri ie. must be a file - * uri if current is not null and is a file uri. - */ - String newUri + /** + * The new uri for the resource. Required for create and move operations. + * otherwise null. + * + * Must be compatible with the current uri ie. must be a file + * uri if current is not null and is a file uri. + */ + String newUri } @@ -3308,8 +3547,9 @@ class WorkspaceEdit { * version of a text document. Whether a client supports versioned document * edits is expressed via `WorkspaceClientCapabilities.versionedWorkspaceEdit`. */ - List documentChanges - + @JsonAdapter(DocumentChangeListAdapter) + List> documentChanges + /** * If resource changes are supported the `WorkspaceEdit` * uses the property `resourceChanges` which are either a @@ -3321,27 +3561,27 @@ class WorkspaceEdit { @JsonAdapter(ResourceChangeListAdapter) List> resourceChanges - new() { - this.changes = new LinkedHashMap - } - - new(Map> changes) { - this.changes = changes - } - - new(List documentChanges) { - this.documentChanges = documentChanges - } - - /** - * @deprecated According to the protocol documentation, it doesn't make sense to send both - * changes and documentChanges - */ - @Deprecated - new(Map> changes, List documentChanges) { - this.changes = changes - this.documentChanges = documentChanges - } + new() { + this.changes = new LinkedHashMap + } + + new(Map> changes) { + this.changes = changes + } + + new(List> documentChanges) { + this.documentChanges = documentChanges + } + + /** + * @deprecated According to the protocol documentation, it doesn't make sense to send both + * changes and documentChanges + */ + @Deprecated + new(Map> changes, List> documentChanges) { + this.changes = changes + this.documentChanges = documentChanges + } } /** @@ -3354,13 +3594,13 @@ class WorkspaceSymbolParams { */ @NonNull String query - - new() { - } - - new(@NonNull String query) { - this.query = query - } + + new() { + } + + new(@NonNull String query) { + this.query = query + } } /** @@ -3369,37 +3609,37 @@ class WorkspaceSymbolParams { @JsonRpcData class Registration { /** - * The id used to register the request. The id can be used to deregister - * the request again. - */ - @NonNull + * The id used to register the request. The id can be used to deregister + * the request again. + */ + @NonNull String id - + /** - * The method / capability to register for. - */ - @NonNull + * The method / capability to register for. + */ + @NonNull String method - - /** - * Options necessary for the registration. - */ - @JsonAdapter(JsonElementTypeAdapter.Factory) - Object registerOptions - - new() { - } - - new(@NonNull String id, @NonNull String method) { - this.id = id - this.method = method - } - - new(@NonNull String id, @NonNull String method, Object registerOptions) { - this.id = id - this.method = method - this.registerOptions = registerOptions - } + + /** + * Options necessary for the registration. + */ + @JsonAdapter(JsonElementTypeAdapter.Factory) + Object registerOptions + + new() { + } + + new(@NonNull String id, @NonNull String method) { + this.id = id + this.method = method + } + + new(@NonNull String id, @NonNull String method, Object registerOptions) { + this.id = id + this.method = method + this.registerOptions = registerOptions + } } /** @@ -3413,14 +3653,14 @@ class Registration { class RegistrationParams { @NonNull List registrations - - new() { - this(new ArrayList) - } - - new(@NonNull List registrations) { - this.registrations = registrations - } + + new() { + this(new ArrayList) + } + + new(@NonNull List registrations) { + this.registrations = registrations + } } /** @@ -3429,28 +3669,28 @@ class RegistrationParams { @JsonRpcData class DocumentFilter { /** - * A language id, like `typescript`. - */ - String language - + * A language id, like `typescript`. + */ + String language + /** - * A uri scheme, like `file` or `untitled`. - */ - String scheme - + * A uri scheme, like `file` or `untitled`. + */ + String scheme + /** - * A glob pattern, like `*.{ts,js}`. - */ - String pattern - - new() { - } - - new(String language, String scheme, String pattern) { - this.language = language - this.scheme = scheme - this.pattern = pattern - } + * A glob pattern, like `*.{ts,js}`. + */ + String pattern + + new() { + } + + new(String language, String scheme, String pattern) { + this.language = language + this.scheme = scheme + this.pattern = pattern + } } /** @@ -3460,17 +3700,17 @@ class DocumentFilter { @JsonRpcData class TextDocumentRegistrationOptions { /** - * A document selector to identify the scope of the registration. If set to null - * the document selector provided on the client side will be used. - */ - List documentSelector - - new() { - } - - new(List documentSelector) { - this.documentSelector = documentSelector - } + * A document selector to identify the scope of the registration. If set to null + * the document selector provided on the client side will be used. + */ + List documentSelector + + new() { + } + + new(List documentSelector) { + this.documentSelector = documentSelector + } } /** @@ -3479,25 +3719,25 @@ class TextDocumentRegistrationOptions { @JsonRpcData class Unregistration { /** - * The id used to unregister the request or notification. Usually an id - * provided during the register request. - */ - @NonNull + * The id used to unregister the request or notification. Usually an id + * provided during the register request. + */ + @NonNull String id - + /** - * The method / capability to unregister for. - */ - @NonNull + * The method / capability to unregister for. + */ + @NonNull String method - - new() { - } - - new(@NonNull String id, @NonNull String method) { - this.id = id - this.method = method - } + + new() { + } + + new(@NonNull String id, @NonNull String method) { + this.id = id + this.method = method + } } /** @@ -3508,14 +3748,14 @@ class Unregistration { class UnregistrationParams { @NonNull List unregisterations - - new() { - this(new ArrayList) - } - - new(@NonNull List unregisterations) { - this.unregisterations = unregisterations - } + + new() { + this(new ArrayList) + } + + new(@NonNull List unregisterations) { + this.unregisterations = unregisterations + } } /** @@ -3524,18 +3764,18 @@ class UnregistrationParams { @JsonRpcData class TextDocumentChangeRegistrationOptions extends TextDocumentRegistrationOptions { /** - * How documents are synced to the server. See TextDocumentSyncKind.Full - * and TextDocumentSyncKind.Incremental. - */ - @NonNull + * How documents are synced to the server. See TextDocumentSyncKind.Full + * and TextDocumentSyncKind.Incremental. + */ + @NonNull TextDocumentSyncKind syncKind - - new() { - } - - new(@NonNull TextDocumentSyncKind syncKind) { - this.syncKind = syncKind - } + + new() { + } + + new(@NonNull TextDocumentSyncKind syncKind) { + this.syncKind = syncKind + } } @JsonRpcData @@ -3544,13 +3784,13 @@ class TextDocumentSaveRegistrationOptions extends TextDocumentRegistrationOption * The client is supposed to include the content on save. */ Boolean includeText - - new() { - } - - new(Boolean includeText) { - this.includeText = includeText - } + + new() { + } + + new(Boolean includeText) { + this.includeText = includeText + } } @JsonRpcData @@ -3561,95 +3801,95 @@ class CompletionRegistrationOptions extends TextDocumentRegistrationOptions { * starts to type an identifier. For example if the user types `c` in a JavaScript file * code complete will automatically pop up present `console` besides others as a * completion item. Characters that make up identifiers don't need to be listed here. - * + * * If code complete should automatically be trigger on characters not being valid inside * an identifier (for example `.` in JavaScript) list them in `triggerCharacters`. */ List triggerCharacters - /** - * The server provides support to resolve additional information for a completion item. - */ - Boolean resolveProvider - - new() { - } - - new(List triggerCharacters, Boolean resolveProvider) { - this.triggerCharacters = triggerCharacters - this.resolveProvider = resolveProvider - } + /** + * The server provides support to resolve additional information for a completion item. + */ + Boolean resolveProvider + + new() { + } + + new(List triggerCharacters, Boolean resolveProvider) { + this.triggerCharacters = triggerCharacters + this.resolveProvider = resolveProvider + } } @JsonRpcData class SignatureHelpRegistrationOptions extends TextDocumentRegistrationOptions { /** - * The characters that trigger signature help automatically. - */ - List triggerCharacters - - new() { - } - - new(List triggerCharacters) { - this.triggerCharacters = triggerCharacters - } + * The characters that trigger signature help automatically. + */ + List triggerCharacters + + new() { + } + + new(List triggerCharacters) { + this.triggerCharacters = triggerCharacters + } } @JsonRpcData class CodeLensRegistrationOptions extends TextDocumentRegistrationOptions { /** - * Code lens has a resolve provider as well. - */ - Boolean resolveProvider - - new() { - } - - new(Boolean resolveProvider) { - this.resolveProvider = resolveProvider - } + * Code lens has a resolve provider as well. + */ + Boolean resolveProvider + + new() { + } + + new(Boolean resolveProvider) { + this.resolveProvider = resolveProvider + } } @JsonRpcData class DocumentLinkRegistrationOptions extends TextDocumentRegistrationOptions { /** - * Document links have a resolve provider as well. - */ - Boolean resolveProvider - - new() { - } - - new(Boolean resolveProvider) { - this.resolveProvider = resolveProvider - } + * Document links have a resolve provider as well. + */ + Boolean resolveProvider + + new() { + } + + new(Boolean resolveProvider) { + this.resolveProvider = resolveProvider + } } @JsonRpcData class DocumentOnTypeFormattingRegistrationOptions extends TextDocumentRegistrationOptions { /** - * A character on which formatting should be triggered, like `}`. - */ - @NonNull - String firstTriggerCharacter - - /** - * More trigger characters. - */ - List moreTriggerCharacter - - new() { - } - - new(@NonNull String firstTriggerCharacter) { - this.firstTriggerCharacter = firstTriggerCharacter - } - - new(@NonNull String firstTriggerCharacter, List moreTriggerCharacter) { - this.firstTriggerCharacter = firstTriggerCharacter - this.moreTriggerCharacter = moreTriggerCharacter - } + * A character on which formatting should be triggered, like `}`. + */ + @NonNull + String firstTriggerCharacter + + /** + * More trigger characters. + */ + List moreTriggerCharacter + + new() { + } + + new(@NonNull String firstTriggerCharacter) { + this.firstTriggerCharacter = firstTriggerCharacter + } + + new(@NonNull String firstTriggerCharacter, List moreTriggerCharacter) { + this.firstTriggerCharacter = firstTriggerCharacter + this.moreTriggerCharacter = moreTriggerCharacter + } } /** @@ -3661,25 +3901,25 @@ class DocumentOnTypeFormattingRegistrationOptions extends TextDocumentRegistrati @JsonRpcData class ExecuteCommandParams { /** - * The identifier of the actual command handler. - */ - @NonNull + * The identifier of the actual command handler. + */ + @NonNull String command - + /** - * Arguments that the command should be invoked with. - * The arguments are typically specified when a command is returned from the server to the client. - * Example requests that return a command are textDocument/codeAction or textDocument/codeLens. - */ - List arguments - - new() { - } - - new(@NonNull String command, List arguments) { - this.command = command - this.arguments = arguments - } + * Arguments that the command should be invoked with. + * The arguments are typically specified when a command is returned from the server to the client. + * Example requests that return a command are textDocument/codeAction or textDocument/codeLens. + */ + List arguments + + new() { + } + + new(@NonNull String command, List arguments) { + this.command = command + this.arguments = arguments + } } /** @@ -3688,17 +3928,17 @@ class ExecuteCommandParams { @JsonRpcData class ExecuteCommandRegistrationOptions { /** - * The commands to be executed on the server - */ - @NonNull - List commands - - new() { - } - - new(@NonNull List commands) { - this.commands = commands - } + * The commands to be executed on the server + */ + @NonNull + List commands + + new() { + } + + new(@NonNull List commands) { + this.commands = commands + } } /** @@ -3707,49 +3947,49 @@ class ExecuteCommandRegistrationOptions { @JsonRpcData class ApplyWorkspaceEditParams { /** - * The edits to apply. - */ - @NonNull - WorkspaceEdit edit + * The edits to apply. + */ + @NonNull + WorkspaceEdit edit /** - * An optional label of the workspace edit. This label is - * presented in the user interface for example on an undo - * stack to undo the workspace edit. - */ - String label - - new() { - } - - new(@NonNull WorkspaceEdit edit) { - this.edit = edit - } + * An optional label of the workspace edit. This label is + * presented in the user interface for example on an undo + * stack to undo the workspace edit. + */ + String label + + new() { + } + + new(@NonNull WorkspaceEdit edit) { + this.edit = edit + } - new(@NonNull WorkspaceEdit edit, String label) { - this.edit = edit; - this.label = label - } + new(@NonNull WorkspaceEdit edit, String label) { + this.edit = edit; + this.label = label + } } @JsonRpcData class ApplyWorkspaceEditResponse { /** - * Indicates whether the edit was applied or not. - */ - boolean applied - - new() { - } - - new(boolean applied) { - this.applied = applied - } + * Indicates whether the edit was applied or not. + */ + boolean applied + + new() { + } + + new(boolean applied) { + this.applied = applied + } } /** * The server supports workspace folder. - * + * * Since 3.6.0 */ @JsonRpcData @@ -3758,11 +3998,11 @@ class WorkspaceFoldersOptions { * The server has support for workspace folders */ Boolean supported - + /** * Whether the server wants to receive workspace folder * change notifications. - * + * * If a string is provided, the string is treated as an ID * under which the notification is registed on the client * side. The ID can be used to unregister for these events @@ -3788,14 +4028,14 @@ class WorkspaceFolder { * The name of the workspace folder. Defaults to the uri's basename. */ String name - + new() { } - + new(@NonNull String uri) { this.uri = uri } - + new(@NonNull String uri, String name) { this.uri = uri this.name = name @@ -3818,10 +4058,10 @@ class WorkspaceFoldersChangeEvent { */ @NonNull List removed = new ArrayList - + new() { } - + new(@NonNull List added, @NonNull List removed) { this.added = added this.removed = removed @@ -3842,10 +4082,10 @@ class DidChangeWorkspaceFoldersParams { */ @NonNull WorkspaceFoldersChangeEvent event - + new() { } - + new(@NonNull WorkspaceFoldersChangeEvent event) { this.event = event } @@ -3864,10 +4104,10 @@ class DidChangeWorkspaceFoldersParams { class ConfigurationParams { @NonNull List items - + new() { } - + new(@NonNull List items) { this.items = items } @@ -3892,7 +4132,7 @@ class ConfigurationItem { * The scope to get the configuration section for. */ String scopeUri - + /** * The configuration section asked for. */ @@ -3912,10 +4152,10 @@ class DocumentColorParams { */ @NonNull TextDocumentIdentifier textDocument - + new() { } - + new(@NonNull TextDocumentIdentifier textDocument) { this.textDocument = textDocument } @@ -3934,10 +4174,10 @@ class ColorInformation { */ @NonNull Color color - + new() { } - + new(@NonNull Range range, @NonNull Color color) { this.range = range this.color = color @@ -3968,10 +4208,10 @@ class Color { * The alpha component of this color in the range [0-1]. */ double alpha - + new() { } - + new(double red, double green, double blue, double alpha) { this.red = red this.green = green @@ -4005,10 +4245,10 @@ class ColorPresentationParams { */ @NonNull Range range - + new() { } - + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Color color, @NonNull Range range) { this.textDocument = textDocument this.color = color @@ -4025,31 +4265,31 @@ class ColorPresentation { */ @NonNull String label - + /** * An edit which is applied to a document when selecting * this presentation for the color. When `null` the label is used. */ TextEdit textEdit - + /** * An optional array of additional text edits that are applied when * selecting this color presentation. Edits must not overlap with the main edit nor with themselves. */ List additionalTextEdits - + new() { } - + new(@NonNull String label) { this.label = label } - + new(@NonNull String label, TextEdit textEdit) { this.label = label this.textEdit = textEdit } - + new(@NonNull String label, TextEdit textEdit, List additionalTextEdits) { this.label = label this.textEdit = textEdit @@ -4068,10 +4308,10 @@ class FoldingRangeRequestParams { */ @NonNull TextDocumentIdentifier textDocument - + new() { } - + new(TextDocumentIdentifier textDocument) { this.textDocument = textDocument } @@ -4111,10 +4351,10 @@ class FoldingRange { * FoldingRangeKind for an enumeration of standardized kinds. */ String kind - + new() { } - + new(int startLine, int endLine) { this.startLine = startLine this.endLine = endLine diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ResourceOperationKind.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ResourceOperationKind.java new file mode 100644 index 000000000..7de57ed83 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ResourceOperationKind.java @@ -0,0 +1,37 @@ +/****************************************************************************** + * Copyright (c) 2018 Microsoft Corporation and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + ******************************************************************************/ + +package org.eclipse.lsp4j; + +/** + * The kind of resource operations supported by the client. + */ +public final class ResourceOperationKind { + + private ResourceOperationKind() { + } + + /** + * Supports creating new files and folders. + */ + public static final String Create = "create"; + + /** + * Supports renaming existing files and folders. + */ + public static final String Rename = "rename"; + + /** + * Supports deleting existing files and folders. + */ + public static final String Delete = "delete"; +} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/DocumentChangeListAdapter.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/DocumentChangeListAdapter.java new file mode 100644 index 000000000..68d9474e9 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/DocumentChangeListAdapter.java @@ -0,0 +1,45 @@ +/****************************************************************************** + * Copyright (c) 2018 Microsoft Corporation and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + ******************************************************************************/ + +package org.eclipse.lsp4j.adapters; + +import java.util.ArrayList; +import java.util.function.Predicate; + +import org.eclipse.lsp4j.ResourceOperation; +import org.eclipse.lsp4j.TextDocumentEdit; +import org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter; +import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter; +import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.PropertyChecker; +import org.eclipse.lsp4j.jsonrpc.messages.Either; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +public class DocumentChangeListAdapter implements TypeAdapterFactory { + + private static final TypeToken> ELEMENT_TYPE + = new TypeToken>() {}; + + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + Predicate leftChecker = new PropertyChecker("textDocument").and(new PropertyChecker("edits")); + Predicate rightChecker = new PropertyChecker("kind"); + TypeAdapter> elementTypeAdapter = new EitherTypeAdapter<>(gson, + ELEMENT_TYPE, leftChecker, rightChecker); + return (TypeAdapter) new CollectionTypeAdapter<>(gson, ELEMENT_TYPE.getType(), elementTypeAdapter, ArrayList::new); + } +} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceOperationTypeAdapter.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceOperationTypeAdapter.java new file mode 100644 index 000000000..7901537f8 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceOperationTypeAdapter.java @@ -0,0 +1,90 @@ +/****************************************************************************** + * Copyright (c) 2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + ******************************************************************************/ + +package org.eclipse.lsp4j.adapters; + +import java.io.IOException; + +import org.eclipse.lsp4j.CreateFile; +import org.eclipse.lsp4j.DeleteFile; +import org.eclipse.lsp4j.RenameFile; +import org.eclipse.lsp4j.ResourceOperation; +import org.eclipse.lsp4j.ResourceOperationKind; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +public class ResourceOperationTypeAdapter implements TypeAdapterFactory { + + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + + if (!ResourceOperation.class.isAssignableFrom(type.getRawType())) { + return null; + } + + return (TypeAdapter) new InnerResourceOperationTypeAdapter(this, gson).nullSafe(); + } + + private static class InnerResourceOperationTypeAdapter extends TypeAdapter { + + TypeAdapter jsonElementAdapter; + TypeAdapter createFileAdapter; + TypeAdapter deleteFileAdapter; + TypeAdapter renameFileAdapter; + + InnerResourceOperationTypeAdapter(TypeAdapterFactory factory, Gson gson) { + jsonElementAdapter = gson.getAdapter(JsonElement.class); + createFileAdapter = gson.getDelegateAdapter(factory, TypeToken.get(CreateFile.class)); + deleteFileAdapter = gson.getDelegateAdapter(factory, TypeToken.get(DeleteFile.class)); + renameFileAdapter = gson.getDelegateAdapter(factory, TypeToken.get(RenameFile.class)); + } + + @Override + public void write(JsonWriter out, ResourceOperation value) throws IOException { + + if (value.getClass().isAssignableFrom(CreateFile.class)) { + createFileAdapter.write(out, (CreateFile) value); + } else if (value.getClass().isAssignableFrom(DeleteFile.class)) { + deleteFileAdapter.write(out, (DeleteFile) value); + } else if (value.getClass().isAssignableFrom(RenameFile.class)) { + renameFileAdapter.write(out, (RenameFile) value); + } + } + + @Override + public ResourceOperation read(JsonReader in) throws IOException { + JsonObject objectJson = jsonElementAdapter.read(in).getAsJsonObject(); + JsonElement value = objectJson.get("kind"); + if (value != null && value.isJsonPrimitive()) { + String kindValue = value.getAsString(); + + if (ResourceOperationKind.Create.equals(kindValue)) { + return createFileAdapter.fromJsonTree(objectJson); + } else if (ResourceOperationKind.Delete.equals(kindValue)) { + return deleteFileAdapter.fromJsonTree(objectJson); + } else if (ResourceOperationKind.Rename.equals(kindValue)) { + return renameFileAdapter.fromJsonTree(objectJson); + } + } + + return null; + } + } +} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/TextDocumentService.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/TextDocumentService.java index 40170bcb8..563fbaa82 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/TextDocumentService.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/TextDocumentService.java @@ -42,6 +42,8 @@ import org.eclipse.lsp4j.FoldingRangeRequestParams; import org.eclipse.lsp4j.Hover; import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.PrepareRenameResult; +import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.ReferenceParams; import org.eclipse.lsp4j.RenameParams; import org.eclipse.lsp4j.SignatureHelp; @@ -374,5 +376,16 @@ default CompletableFuture> colorPresentation(ColorPresen default CompletableFuture> foldingRange(FoldingRangeRequestParams params) { throw new UnsupportedOperationException(); } + + /** + * The prepare rename request is sent from the client to the server to setup and test the validity of a rename + * operation at a given location. + * + * Since version 3.12.0 + */ + @JsonRequest + default CompletableFuture> prepareRename(TextDocumentPositionParams params) { + throw new UnsupportedOperationException(); + } } diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFile.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFile.java new file mode 100644 index 000000000..e5e6c7dc5 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFile.java @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.lsp4j.CreateFileOptions; +import org.eclipse.lsp4j.ResourceOperation; +import org.eclipse.lsp4j.ResourceOperationKind; +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Create file operation + */ +@SuppressWarnings("all") +public class CreateFile extends ResourceOperation { + /** + * The resource to create. + */ + @NonNull + private String uri; + + /** + * Additional options + */ + private CreateFileOptions options; + + public CreateFile() { + super(ResourceOperationKind.Create); + } + + public CreateFile(@NonNull final String uri) { + super(ResourceOperationKind.Create); + this.uri = uri; + } + + public CreateFile(@NonNull final String uri, final CreateFileOptions options) { + super(ResourceOperationKind.Create); + this.uri = uri; + this.options = options; + } + + /** + * The resource to create. + */ + @Pure + @NonNull + public String getUri() { + return this.uri; + } + + /** + * The resource to create. + */ + public void setUri(@NonNull final String uri) { + this.uri = uri; + } + + /** + * Additional options + */ + @Pure + public CreateFileOptions getOptions() { + return this.options; + } + + /** + * Additional options + */ + public void setOptions(final CreateFileOptions options) { + this.options = options; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("uri", this.uri); + b.add("options", this.options); + b.add("kind", getKind()); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + if (!super.equals(obj)) + return false; + CreateFile other = (CreateFile) obj; + if (this.uri == null) { + if (other.uri != null) + return false; + } else if (!this.uri.equals(other.uri)) + return false; + if (this.options == null) { + if (other.options != null) + return false; + } else if (!this.options.equals(other.options)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((this.uri== null) ? 0 : this.uri.hashCode()); + return prime * result + ((this.options== null) ? 0 : this.options.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFileOptions.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFileOptions.java new file mode 100644 index 000000000..b9d56e1bb --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CreateFileOptions.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Options to create a file. + */ +@SuppressWarnings("all") +public class CreateFileOptions { + /** + * Overwrite existing file. Overwrite wins over `ignoreIfExists` + */ + private Boolean overwrite; + + /** + * Ignore if exists. + */ + private Boolean ignoreIfExists; + + public CreateFileOptions() { + } + + public CreateFileOptions(final Boolean overwrite, final Boolean ignoreIfExists) { + this.overwrite = overwrite; + this.ignoreIfExists = ignoreIfExists; + } + + /** + * Overwrite existing file. Overwrite wins over `ignoreIfExists` + */ + @Pure + public Boolean getOverwrite() { + return this.overwrite; + } + + /** + * Overwrite existing file. Overwrite wins over `ignoreIfExists` + */ + public void setOverwrite(final Boolean overwrite) { + this.overwrite = overwrite; + } + + /** + * Ignore if exists. + */ + @Pure + public Boolean getIgnoreIfExists() { + return this.ignoreIfExists; + } + + /** + * Ignore if exists. + */ + public void setIgnoreIfExists(final Boolean ignoreIfExists) { + this.ignoreIfExists = ignoreIfExists; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("overwrite", this.overwrite); + b.add("ignoreIfExists", this.ignoreIfExists); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CreateFileOptions other = (CreateFileOptions) obj; + if (this.overwrite == null) { + if (other.overwrite != null) + return false; + } else if (!this.overwrite.equals(other.overwrite)) + return false; + if (this.ignoreIfExists == null) { + if (other.ignoreIfExists != null) + return false; + } else if (!this.ignoreIfExists.equals(other.ignoreIfExists)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.overwrite== null) ? 0 : this.overwrite.hashCode()); + return prime * result + ((this.ignoreIfExists== null) ? 0 : this.ignoreIfExists.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFile.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFile.java new file mode 100644 index 000000000..6c9fd48a1 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFile.java @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.lsp4j.DeleteFileOptions; +import org.eclipse.lsp4j.ResourceOperation; +import org.eclipse.lsp4j.ResourceOperationKind; +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Delete file operation + */ +@SuppressWarnings("all") +public class DeleteFile extends ResourceOperation { + /** + * The file to delete. + */ + @NonNull + private String uri; + + /** + * Delete options. + */ + private DeleteFileOptions options; + + public DeleteFile() { + super(ResourceOperationKind.Delete); + } + + public DeleteFile(@NonNull final String uri) { + super(ResourceOperationKind.Delete); + this.uri = uri; + } + + public DeleteFile(@NonNull final String uri, final DeleteFileOptions options) { + super(ResourceOperationKind.Delete); + this.uri = uri; + this.options = options; + } + + /** + * The file to delete. + */ + @Pure + @NonNull + public String getUri() { + return this.uri; + } + + /** + * The file to delete. + */ + public void setUri(@NonNull final String uri) { + this.uri = uri; + } + + /** + * Delete options. + */ + @Pure + public DeleteFileOptions getOptions() { + return this.options; + } + + /** + * Delete options. + */ + public void setOptions(final DeleteFileOptions options) { + this.options = options; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("uri", this.uri); + b.add("options", this.options); + b.add("kind", getKind()); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + if (!super.equals(obj)) + return false; + DeleteFile other = (DeleteFile) obj; + if (this.uri == null) { + if (other.uri != null) + return false; + } else if (!this.uri.equals(other.uri)) + return false; + if (this.options == null) { + if (other.options != null) + return false; + } else if (!this.options.equals(other.options)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((this.uri== null) ? 0 : this.uri.hashCode()); + return prime * result + ((this.options== null) ? 0 : this.options.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFileOptions.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFileOptions.java new file mode 100644 index 000000000..2934b8401 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/DeleteFileOptions.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Delete file options + */ +@SuppressWarnings("all") +public class DeleteFileOptions { + /** + * Delete the content recursively if a folder is denoted. + */ + private Boolean recursive; + + /** + * Ignore the operation if the file doesn't exist. + */ + private Boolean ignoreIfNotExists; + + public DeleteFileOptions() { + } + + public DeleteFileOptions(final Boolean recursive, final Boolean ignoreIfNotExists) { + this.recursive = recursive; + this.ignoreIfNotExists = ignoreIfNotExists; + } + + /** + * Delete the content recursively if a folder is denoted. + */ + @Pure + public Boolean getRecursive() { + return this.recursive; + } + + /** + * Delete the content recursively if a folder is denoted. + */ + public void setRecursive(final Boolean recursive) { + this.recursive = recursive; + } + + /** + * Ignore the operation if the file doesn't exist. + */ + @Pure + public Boolean getIgnoreIfNotExists() { + return this.ignoreIfNotExists; + } + + /** + * Ignore the operation if the file doesn't exist. + */ + public void setIgnoreIfNotExists(final Boolean ignoreIfNotExists) { + this.ignoreIfNotExists = ignoreIfNotExists; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("recursive", this.recursive); + b.add("ignoreIfNotExists", this.ignoreIfNotExists); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeleteFileOptions other = (DeleteFileOptions) obj; + if (this.recursive == null) { + if (other.recursive != null) + return false; + } else if (!this.recursive.equals(other.recursive)) + return false; + if (this.ignoreIfNotExists == null) { + if (other.ignoreIfNotExists != null) + return false; + } else if (!this.ignoreIfNotExists.equals(other.ignoreIfNotExists)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.recursive== null) ? 0 : this.recursive.hashCode()); + return prime * result + ((this.ignoreIfNotExists== null) ? 0 : this.ignoreIfNotExists.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/PrepareRenameResult.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/PrepareRenameResult.java new file mode 100644 index 000000000..1a0f7915d --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/PrepareRenameResult.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +@SuppressWarnings("all") +public class PrepareRenameResult { + /** + * The capabilities the language server provides. + */ + @NonNull + private Range range; + + @NonNull + private String placeholder; + + public PrepareRenameResult() { + } + + public PrepareRenameResult(@NonNull final Range range, @NonNull final String placeholder) { + this.range = range; + this.placeholder = placeholder; + } + + /** + * The capabilities the language server provides. + */ + @Pure + @NonNull + public Range getRange() { + return this.range; + } + + /** + * The capabilities the language server provides. + */ + public void setRange(@NonNull final Range range) { + this.range = range; + } + + @Pure + @NonNull + public String getPlaceholder() { + return this.placeholder; + } + + public void setPlaceholder(@NonNull final String placeholder) { + this.placeholder = placeholder; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("range", this.range); + b.add("placeholder", this.placeholder); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PrepareRenameResult other = (PrepareRenameResult) obj; + if (this.range == null) { + if (other.range != null) + return false; + } else if (!this.range.equals(other.range)) + return false; + if (this.placeholder == null) { + if (other.placeholder != null) + return false; + } else if (!this.placeholder.equals(other.placeholder)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.range== null) ? 0 : this.range.hashCode()); + return prime * result + ((this.placeholder== null) ? 0 : this.placeholder.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFile.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFile.java new file mode 100644 index 000000000..f19ca23b9 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFile.java @@ -0,0 +1,157 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.lsp4j.RenameFileOptions; +import org.eclipse.lsp4j.ResourceOperation; +import org.eclipse.lsp4j.ResourceOperationKind; +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Rename file operation + */ +@SuppressWarnings("all") +public class RenameFile extends ResourceOperation { + /** + * The old (existing) location. + */ + @NonNull + private String oldUri; + + /** + * The new location. + */ + @NonNull + private String newUri; + + /** + * Rename options. + */ + private RenameFileOptions options; + + public RenameFile() { + super(ResourceOperationKind.Rename); + } + + public RenameFile(@NonNull final String oldUri, @NonNull final String newUri) { + super(ResourceOperationKind.Rename); + this.oldUri = oldUri; + this.newUri = newUri; + } + + public RenameFile(@NonNull final String oldUri, @NonNull final String newUri, final RenameFileOptions options) { + super(ResourceOperationKind.Rename); + this.oldUri = oldUri; + this.newUri = newUri; + this.options = options; + } + + /** + * The old (existing) location. + */ + @Pure + @NonNull + public String getOldUri() { + return this.oldUri; + } + + /** + * The old (existing) location. + */ + public void setOldUri(@NonNull final String oldUri) { + this.oldUri = oldUri; + } + + /** + * The new location. + */ + @Pure + @NonNull + public String getNewUri() { + return this.newUri; + } + + /** + * The new location. + */ + public void setNewUri(@NonNull final String newUri) { + this.newUri = newUri; + } + + /** + * Rename options. + */ + @Pure + public RenameFileOptions getOptions() { + return this.options; + } + + /** + * Rename options. + */ + public void setOptions(final RenameFileOptions options) { + this.options = options; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("oldUri", this.oldUri); + b.add("newUri", this.newUri); + b.add("options", this.options); + b.add("kind", getKind()); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + if (!super.equals(obj)) + return false; + RenameFile other = (RenameFile) obj; + if (this.oldUri == null) { + if (other.oldUri != null) + return false; + } else if (!this.oldUri.equals(other.oldUri)) + return false; + if (this.newUri == null) { + if (other.newUri != null) + return false; + } else if (!this.newUri.equals(other.newUri)) + return false; + if (this.options == null) { + if (other.options != null) + return false; + } else if (!this.options.equals(other.options)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((this.oldUri== null) ? 0 : this.oldUri.hashCode()); + result = prime * result + ((this.newUri== null) ? 0 : this.newUri.hashCode()); + return prime * result + ((this.options== null) ? 0 : this.options.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFileOptions.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFileOptions.java new file mode 100644 index 000000000..768464409 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameFileOptions.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Rename file options + */ +@SuppressWarnings("all") +public class RenameFileOptions { + /** + * Overwrite target if existing. Overwrite wins over `ignoreIfExists` + */ + private Boolean overwrite; + + /** + * Ignores if target exists. + */ + private Boolean ignoreIfExists; + + public RenameFileOptions() { + } + + public RenameFileOptions(final Boolean overwrite, final Boolean ignoreIfExists) { + this.overwrite = overwrite; + this.ignoreIfExists = ignoreIfExists; + } + + /** + * Overwrite target if existing. Overwrite wins over `ignoreIfExists` + */ + @Pure + public Boolean getOverwrite() { + return this.overwrite; + } + + /** + * Overwrite target if existing. Overwrite wins over `ignoreIfExists` + */ + public void setOverwrite(final Boolean overwrite) { + this.overwrite = overwrite; + } + + /** + * Ignores if target exists. + */ + @Pure + public Boolean getIgnoreIfExists() { + return this.ignoreIfExists; + } + + /** + * Ignores if target exists. + */ + public void setIgnoreIfExists(final Boolean ignoreIfExists) { + this.ignoreIfExists = ignoreIfExists; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("overwrite", this.overwrite); + b.add("ignoreIfExists", this.ignoreIfExists); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RenameFileOptions other = (RenameFileOptions) obj; + if (this.overwrite == null) { + if (other.overwrite != null) + return false; + } else if (!this.overwrite.equals(other.overwrite)) + return false; + if (this.ignoreIfExists == null) { + if (other.ignoreIfExists != null) + return false; + } else if (!this.ignoreIfExists.equals(other.ignoreIfExists)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.overwrite== null) ? 0 : this.overwrite.hashCode()); + return prime * result + ((this.ignoreIfExists== null) ? 0 : this.ignoreIfExists.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameOptions.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameOptions.java new file mode 100644 index 000000000..be05ce0c4 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/RenameOptions.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +/** + * Rename options + */ +@SuppressWarnings("all") +public class RenameOptions { + /** + * Renames should be checked and tested before being executed. + */ + private Boolean prepareProvider; + + public RenameOptions() { + } + + public RenameOptions(final Boolean prepareProvider) { + this.prepareProvider = prepareProvider; + } + + /** + * Renames should be checked and tested before being executed. + */ + @Pure + public Boolean getPrepareProvider() { + return this.prepareProvider; + } + + /** + * Renames should be checked and tested before being executed. + */ + public void setPrepareProvider(final Boolean prepareProvider) { + this.prepareProvider = prepareProvider; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("prepareProvider", this.prepareProvider); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RenameOptions other = (RenameOptions) obj; + if (this.prepareProvider == null) { + if (other.prepareProvider != null) + return false; + } else if (!this.prepareProvider.equals(other.prepareProvider)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + return 31 * 1 + ((this.prepareProvider== null) ? 0 : this.prepareProvider.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ResourceOperation.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ResourceOperation.java new file mode 100644 index 000000000..df67528a8 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ResourceOperation.java @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2016-2018 TypeFox and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lsp4j; + +import com.google.gson.annotations.JsonAdapter; +import org.eclipse.lsp4j.adapters.ResourceOperationTypeAdapter; +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; + +@JsonAdapter(ResourceOperationTypeAdapter.class) +@SuppressWarnings("all") +public class ResourceOperation { + @NonNull + private String kind; + + public ResourceOperation() { + } + + public ResourceOperation(@NonNull final String kind) { + this.kind = kind; + } + + @Pure + @NonNull + public String getKind() { + return this.kind; + } + + public void setKind(@NonNull final String kind) { + this.kind = kind; + } + + @Override + @Pure + public String toString() { + ToStringBuilder b = new ToStringBuilder(this); + b.add("kind", this.kind); + return b.toString(); + } + + @Override + @Pure + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ResourceOperation other = (ResourceOperation) obj; + if (this.kind == null) { + if (other.kind != null) + return false; + } else if (!this.kind.equals(other.kind)) + return false; + return true; + } + + @Override + @Pure + public int hashCode() { + return 31 * 1 + ((this.kind== null) ? 0 : this.kind.hashCode()); + } +} diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java index 0eba5a6f8..9441de846 100644 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/ServerCapabilities.java @@ -20,6 +20,7 @@ import org.eclipse.lsp4j.DocumentOnTypeFormattingOptions; import org.eclipse.lsp4j.ExecuteCommandOptions; import org.eclipse.lsp4j.FoldingRangeProviderOptions; +import org.eclipse.lsp4j.RenameOptions; import org.eclipse.lsp4j.SemanticHighlightingServerCapabilities; import org.eclipse.lsp4j.SignatureHelpOptions; import org.eclipse.lsp4j.StaticRegistrationOptions; @@ -123,7 +124,7 @@ public class ServerCapabilities { /** * The server provides rename support. */ - private Boolean renameProvider; + private Either renameProvider; /** * The server provides document link support. @@ -487,17 +488,33 @@ public void setDocumentOnTypeFormattingProvider(final DocumentOnTypeFormattingOp * The server provides rename support. */ @Pure - public Boolean getRenameProvider() { + public Either getRenameProvider() { return this.renameProvider; } /** * The server provides rename support. */ - public void setRenameProvider(final Boolean renameProvider) { + public void setRenameProvider(final Either renameProvider) { this.renameProvider = renameProvider; } + public void setRenameProvider(final Boolean renameProvider) { + if (renameProvider == null) { + this.renameProvider = null; + return; + } + this.renameProvider = Either.forLeft(renameProvider); + } + + public void setRenameProvider(final RenameOptions renameProvider) { + if (renameProvider == null) { + this.renameProvider = null; + return; + } + this.renameProvider = Either.forRight(renameProvider); + } + /** * The server provides document link support. */ diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEdit.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEdit.java index d44e15ca0..c873750ec 100644 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEdit.java +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEdit.java @@ -17,8 +17,10 @@ import java.util.List; import java.util.Map; import org.eclipse.lsp4j.ResourceChange; +import org.eclipse.lsp4j.ResourceOperation; import org.eclipse.lsp4j.TextDocumentEdit; import org.eclipse.lsp4j.TextEdit; +import org.eclipse.lsp4j.adapters.DocumentChangeListAdapter; import org.eclipse.lsp4j.adapters.ResourceChangeListAdapter; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.xtext.xbase.lib.Pure; @@ -42,7 +44,8 @@ public class WorkspaceEdit { * version of a text document. Whether a client supports versioned document * edits is expressed via `WorkspaceClientCapabilities.versionedWorkspaceEdit`. */ - private List documentChanges; + @JsonAdapter(DocumentChangeListAdapter.class) + private List> documentChanges; /** * If resource changes are supported the `WorkspaceEdit` @@ -64,7 +67,7 @@ public WorkspaceEdit(final Map> changes) { this.changes = changes; } - public WorkspaceEdit(final List documentChanges) { + public WorkspaceEdit(final List> documentChanges) { this.documentChanges = documentChanges; } @@ -73,7 +76,7 @@ public WorkspaceEdit(final List documentChanges) { * changes and documentChanges */ @Deprecated - public WorkspaceEdit(final Map> changes, final List documentChanges) { + public WorkspaceEdit(final Map> changes, final List> documentChanges) { this.changes = changes; this.documentChanges = documentChanges; } @@ -99,7 +102,7 @@ public void setChanges(final Map> changes) { * edits is expressed via `WorkspaceClientCapabilities.versionedWorkspaceEdit`. */ @Pure - public List getDocumentChanges() { + public List> getDocumentChanges() { return this.documentChanges; } @@ -108,7 +111,7 @@ public List getDocumentChanges() { * version of a text document. Whether a client supports versioned document * edits is expressed via `WorkspaceClientCapabilities.versionedWorkspaceEdit`. */ - public void setDocumentChanges(final List documentChanges) { + public void setDocumentChanges(final List> documentChanges) { this.documentChanges = documentChanges; } diff --git a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEditCapabilities.java b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEditCapabilities.java index eed35f761..c14a57eda 100644 --- a/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEditCapabilities.java +++ b/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/WorkspaceEditCapabilities.java @@ -12,6 +12,9 @@ package org.eclipse.lsp4j; import com.google.common.annotations.Beta; +import java.util.List; +import org.eclipse.lsp4j.FailureHandlingKind; +import org.eclipse.lsp4j.ResourceOperationKind; import org.eclipse.xtext.xbase.lib.Pure; import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; @@ -32,6 +35,18 @@ public class WorkspaceEditCapabilities { @Beta private Boolean resourceChanges; + /** + * The resource operations the client supports. Clients should at least + * support 'create', 'rename' and 'delete' files and folders. + */ + private List resourceOperations; + + /** + * The failure handling strategy of a client if applying the workspace edit + * fails. + */ + private FailureHandlingKind failureHandling; + public WorkspaceEditCapabilities() { } @@ -71,12 +86,48 @@ public void setResourceChanges(final Boolean resourceChanges) { this.resourceChanges = resourceChanges; } + /** + * The resource operations the client supports. Clients should at least + * support 'create', 'rename' and 'delete' files and folders. + */ + @Pure + public List getResourceOperations() { + return this.resourceOperations; + } + + /** + * The resource operations the client supports. Clients should at least + * support 'create', 'rename' and 'delete' files and folders. + */ + public void setResourceOperations(final List resourceOperations) { + this.resourceOperations = resourceOperations; + } + + /** + * The failure handling strategy of a client if applying the workspace edit + * fails. + */ + @Pure + public FailureHandlingKind getFailureHandling() { + return this.failureHandling; + } + + /** + * The failure handling strategy of a client if applying the workspace edit + * fails. + */ + public void setFailureHandling(final FailureHandlingKind failureHandling) { + this.failureHandling = failureHandling; + } + @Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("documentChanges", this.documentChanges); b.add("resourceChanges", this.resourceChanges); + b.add("resourceOperations", this.resourceOperations); + b.add("failureHandling", this.failureHandling); return b.toString(); } @@ -100,6 +151,16 @@ public boolean equals(final Object obj) { return false; } else if (!this.resourceChanges.equals(other.resourceChanges)) return false; + if (this.resourceOperations == null) { + if (other.resourceOperations != null) + return false; + } else if (!this.resourceOperations.equals(other.resourceOperations)) + return false; + if (this.failureHandling == null) { + if (other.failureHandling != null) + return false; + } else if (!this.failureHandling.equals(other.failureHandling)) + return false; return true; } @@ -109,6 +170,8 @@ public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.documentChanges== null) ? 0 : this.documentChanges.hashCode()); - return prime * result + ((this.resourceChanges== null) ? 0 : this.resourceChanges.hashCode()); + result = prime * result + ((this.resourceChanges== null) ? 0 : this.resourceChanges.hashCode()); + result = prime * result + ((this.resourceOperations== null) ? 0 : this.resourceOperations.hashCode()); + return prime * result + ((this.failureHandling== null) ? 0 : this.failureHandling.hashCode()); } } diff --git a/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/services/JsonParseTest.xtend b/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/services/JsonParseTest.xtend index 2b2e720a7..05edf4249 100644 --- a/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/services/JsonParseTest.xtend +++ b/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/services/JsonParseTest.xtend @@ -29,7 +29,10 @@ import org.eclipse.lsp4j.CompletionItemCapabilities import org.eclipse.lsp4j.CompletionItemKind import org.eclipse.lsp4j.CompletionItemKindCapabilities import org.eclipse.lsp4j.CompletionParams +import org.eclipse.lsp4j.CreateFile +import org.eclipse.lsp4j.CreateFileOptions import org.eclipse.lsp4j.DefinitionCapabilities +import org.eclipse.lsp4j.DeleteFile import org.eclipse.lsp4j.Diagnostic import org.eclipse.lsp4j.DiagnosticSeverity import org.eclipse.lsp4j.DidChangeTextDocumentParams @@ -55,7 +58,9 @@ import org.eclipse.lsp4j.Range import org.eclipse.lsp4j.RangeFormattingCapabilities import org.eclipse.lsp4j.ReferencesCapabilities import org.eclipse.lsp4j.RenameCapabilities +import org.eclipse.lsp4j.RenameFile import org.eclipse.lsp4j.ResourceChange +import org.eclipse.lsp4j.ResourceOperation import org.eclipse.lsp4j.SignatureHelpCapabilities import org.eclipse.lsp4j.SignatureInformationCapabilities import org.eclipse.lsp4j.SymbolInformation @@ -607,6 +612,96 @@ class JsonParseTest { ] ]) } + + @Test + def void testRenameResponse3() { + jsonHandler.methodProvider = [ id | + switch id { + case '12': MessageMethods.DOC_RENAME + } + ] + ''' + { + "jsonrpc": "2.0", + "id": "12", + "result": { + "documentChanges": [ + { + "kind": "create", + "uri": "file:/foo.txt", + "options": { + "overwrite": true, + "ignoreIfExists": true + } + }, + { + "kind": "delete", + "uri": "file:/foo.txt" + }, + { + "kind": "rename", + "oldUri": "file:/foo.txt", + "newUri": "file:/bar.txt" + }, + { + "textDocument": { + "uri": "file:/baz.txt", + "version": 17 + }, + "edits": [ + { + "range": { + "start": { + "character": 32, + "line": 3 + }, + "end": { + "character": 35, + "line": 3 + } + }, + "newText": "asdfqweryxcv" + } + ] + } + ] + } + } + '''.assertParse(new ResponseMessage => [ + jsonrpc = "2.0" + id = "12" + result = new WorkspaceEdit => [ + documentChanges = newArrayList( + Either.forRight((new CreateFile => [ + uri = "file:/foo.txt" + options = new CreateFileOptions => [ + overwrite = true + ignoreIfExists = true + ] + ]) as ResourceOperation), + Either.forRight((new DeleteFile => [ + uri = "file:/foo.txt" + ]) as ResourceOperation), + Either.forRight((new RenameFile => [ + oldUri = "file:/foo.txt" + newUri = "file:/bar.txt" + ]) as ResourceOperation), + Either.forLeft(new TextDocumentEdit => [ + textDocument = new VersionedTextDocumentIdentifier("file:/baz.txt", 17) + edits = newArrayList( + new TextEdit => [ + range = new Range => [ + start = new Position(3, 32) + end = new Position(3, 35) + ] + newText = "asdfqweryxcv" + ] + ) + ]) + ) + ] + ]) + } @Test def void testResponseError() { diff --git a/org.eclipse.lsp4j/src/test/xtend-gen/org/eclipse/lsp4j/test/services/JsonParseTest.java b/org.eclipse.lsp4j/src/test/xtend-gen/org/eclipse/lsp4j/test/services/JsonParseTest.java index d45e83b39..de43675fa 100644 --- a/org.eclipse.lsp4j/src/test/xtend-gen/org/eclipse/lsp4j/test/services/JsonParseTest.java +++ b/org.eclipse.lsp4j/src/test/xtend-gen/org/eclipse/lsp4j/test/services/JsonParseTest.java @@ -34,7 +34,10 @@ import org.eclipse.lsp4j.CompletionItemKind; import org.eclipse.lsp4j.CompletionItemKindCapabilities; import org.eclipse.lsp4j.CompletionParams; +import org.eclipse.lsp4j.CreateFile; +import org.eclipse.lsp4j.CreateFileOptions; import org.eclipse.lsp4j.DefinitionCapabilities; +import org.eclipse.lsp4j.DeleteFile; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.DiagnosticSeverity; import org.eclipse.lsp4j.DidChangeTextDocumentParams; @@ -60,7 +63,9 @@ import org.eclipse.lsp4j.RangeFormattingCapabilities; import org.eclipse.lsp4j.ReferencesCapabilities; import org.eclipse.lsp4j.RenameCapabilities; +import org.eclipse.lsp4j.RenameFile; import org.eclipse.lsp4j.ResourceChange; +import org.eclipse.lsp4j.ResourceOperation; import org.eclipse.lsp4j.SignatureHelpCapabilities; import org.eclipse.lsp4j.SignatureInformationCapabilities; import org.eclipse.lsp4j.SymbolInformation; @@ -1252,6 +1257,220 @@ public void testRenameResponse2() { this.assertParse(_builder, _doubleArrow); } + @Test + public void testRenameResponse3() { + final MethodProvider _function = (String id) -> { + String _switchResult = null; + if (id != null) { + switch (id) { + case "12": + _switchResult = MessageMethods.DOC_RENAME; + break; + } + } + return _switchResult; + }; + this.jsonHandler.setMethodProvider(_function); + StringConcatenation _builder = new StringConcatenation(); + _builder.append("{"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("\"jsonrpc\": \"2.0\","); + _builder.newLine(); + _builder.append("\t"); + _builder.append("\"id\": \"12\","); + _builder.newLine(); + _builder.append("\t"); + _builder.append("\"result\": {"); + _builder.newLine(); + _builder.append("\t\t"); + _builder.append("\"documentChanges\": ["); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("{"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"kind\": \"create\","); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"uri\": \"file:/foo.txt\","); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"options\": {"); + _builder.newLine(); + _builder.append("\t\t\t\t\t"); + _builder.append("\"overwrite\": true,"); + _builder.newLine(); + _builder.append("\t\t\t\t\t"); + _builder.append("\"ignoreIfExists\": true"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("}"); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("},"); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("{"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"kind\": \"delete\","); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"uri\": \"file:/foo.txt\""); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("},"); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("{"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"kind\": \"rename\","); + _builder.newLine(); + _builder.append("\t\t\t "); + _builder.append("\"oldUri\": \"file:/foo.txt\","); + _builder.newLine(); + _builder.append("\t\t\t "); + _builder.append("\"newUri\": \"file:/bar.txt\""); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("},"); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("{"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"textDocument\": {"); + _builder.newLine(); + _builder.append("\t\t\t\t\t"); + _builder.append("\"uri\": \"file:/baz.txt\","); + _builder.newLine(); + _builder.append("\t\t\t\t\t"); + _builder.append("\"version\": 17"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("},"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("\"edits\": ["); + _builder.newLine(); + _builder.append("\t\t\t\t\t"); + _builder.append("{"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t"); + _builder.append("\"range\": {"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t"); + _builder.append("\"start\": {"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t\t"); + _builder.append("\"character\": 32,"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t\t"); + _builder.append("\"line\": 3"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t"); + _builder.append("},"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t"); + _builder.append("\"end\": {"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t\t"); + _builder.append("\"character\": 35,"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t\t"); + _builder.append("\"line\": 3"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t\t"); + _builder.append("}"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t"); + _builder.append("},"); + _builder.newLine(); + _builder.append("\t\t\t\t\t\t"); + _builder.append("\"newText\": \"asdfqweryxcv\""); + _builder.newLine(); + _builder.append("\t\t\t\t\t"); + _builder.append("}"); + _builder.newLine(); + _builder.append("\t\t\t\t"); + _builder.append("]"); + _builder.newLine(); + _builder.append("\t\t\t"); + _builder.append("}"); + _builder.newLine(); + _builder.append("\t\t"); + _builder.append("]"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("}"); + _builder.newLine(); + _builder.append("}"); + _builder.newLine(); + ResponseMessage _responseMessage = new ResponseMessage(); + final Procedure1 _function_1 = (ResponseMessage it) -> { + it.setJsonrpc("2.0"); + it.setId("12"); + WorkspaceEdit _workspaceEdit = new WorkspaceEdit(); + final Procedure1 _function_2 = (WorkspaceEdit it_1) -> { + CreateFile _createFile = new CreateFile(); + final Procedure1 _function_3 = (CreateFile it_2) -> { + it_2.setUri("file:/foo.txt"); + CreateFileOptions _createFileOptions = new CreateFileOptions(); + final Procedure1 _function_4 = (CreateFileOptions it_3) -> { + it_3.setOverwrite(Boolean.valueOf(true)); + it_3.setIgnoreIfExists(Boolean.valueOf(true)); + }; + CreateFileOptions _doubleArrow = ObjectExtensions.operator_doubleArrow(_createFileOptions, _function_4); + it_2.setOptions(_doubleArrow); + }; + CreateFile _doubleArrow = ObjectExtensions.operator_doubleArrow(_createFile, _function_3); + DeleteFile _deleteFile = new DeleteFile(); + final Procedure1 _function_4 = (DeleteFile it_2) -> { + it_2.setUri("file:/foo.txt"); + }; + DeleteFile _doubleArrow_1 = ObjectExtensions.operator_doubleArrow(_deleteFile, _function_4); + RenameFile _renameFile = new RenameFile(); + final Procedure1 _function_5 = (RenameFile it_2) -> { + it_2.setOldUri("file:/foo.txt"); + it_2.setNewUri("file:/bar.txt"); + }; + RenameFile _doubleArrow_2 = ObjectExtensions.operator_doubleArrow(_renameFile, _function_5); + TextDocumentEdit _textDocumentEdit = new TextDocumentEdit(); + final Procedure1 _function_6 = (TextDocumentEdit it_2) -> { + VersionedTextDocumentIdentifier _versionedTextDocumentIdentifier = new VersionedTextDocumentIdentifier("file:/baz.txt", Integer.valueOf(17)); + it_2.setTextDocument(_versionedTextDocumentIdentifier); + TextEdit _textEdit = new TextEdit(); + final Procedure1 _function_7 = (TextEdit it_3) -> { + Range _range = new Range(); + final Procedure1 _function_8 = (Range it_4) -> { + Position _position = new Position(3, 32); + it_4.setStart(_position); + Position _position_1 = new Position(3, 35); + it_4.setEnd(_position_1); + }; + Range _doubleArrow_3 = ObjectExtensions.operator_doubleArrow(_range, _function_8); + it_3.setRange(_doubleArrow_3); + it_3.setNewText("asdfqweryxcv"); + }; + TextEdit _doubleArrow_3 = ObjectExtensions.operator_doubleArrow(_textEdit, _function_7); + it_2.setEdits(CollectionLiterals.newArrayList(_doubleArrow_3)); + }; + TextDocumentEdit _doubleArrow_3 = ObjectExtensions.operator_doubleArrow(_textDocumentEdit, _function_6); + it_1.setDocumentChanges(CollectionLiterals.>newArrayList( + Either.forRight(((ResourceOperation) _doubleArrow)), + Either.forRight(((ResourceOperation) _doubleArrow_1)), + Either.forRight(((ResourceOperation) _doubleArrow_2)), + Either.forLeft(_doubleArrow_3))); + }; + WorkspaceEdit _doubleArrow = ObjectExtensions.operator_doubleArrow(_workspaceEdit, _function_2); + it.setResult(_doubleArrow); + }; + ResponseMessage _doubleArrow = ObjectExtensions.operator_doubleArrow(_responseMessage, _function_1); + this.assertParse(_builder, _doubleArrow); + } + @Test public void testResponseError() { final MethodProvider _function = (String id) -> {