From e294e81d17466eddae1914e3b40c591e9436ca09 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Thu, 5 May 2022 11:37:06 -0400 Subject: [PATCH] Smaller 3.17 changes and various others Signed-off-by: Matthew Brown --- CHANGELOG.md | 4 + .../org/eclipse/lsp4j/CodeActionKind.java | 105 --- .../org/eclipse/lsp4j/FoldingRangeKind.java | 35 - .../java/org/eclipse/lsp4j/Protocol.xtend | 613 ++++++++++++++---- .../adapters/ResourceChangeListAdapter.java | 46 -- 5 files changed, 495 insertions(+), 308 deletions(-) delete mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionKind.java delete mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FoldingRangeKind.java delete mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceChangeListAdapter.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 791a271c..75a58d55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,13 +10,17 @@ Breaking API changes: * Method `LanguageClient.setTrace` moved to `LanguageServer`, where it should have been according to the specification + * Removed `RenameOptions.id` as it was never specified for `StaticRegistrationOptions` * Return type of `workspace/symbol` changed from `List` to `Either, List>` + * Type of `FileSystemWatcher.globPattern` changed from `String` to `Either` * In DAP, return type of `IDebugProtocolServer.setExceptionBreakpoints` changed from `Void` to `SetExceptionBreakpointsResponse` Breaking Beta API changes: * Significant updates were made to the `TypeHierarchy` features to replace the non-standard implementation + * Removed `WorkspaceEdit.resourceChanges`, `WorkspaceEditCapabilities.resourceChanges`, and `ResourceChange` as they have been deprecated + for numerous versions and are not specified Deprecated API changes: diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionKind.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionKind.java deleted file mode 100644 index 5eb88477..00000000 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionKind.java +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************** - * 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 a code action. - *

- * Kinds are a hierarchical list of identifiers separated by {@code .}, - * e.g. {@code "refactor.extract.function"}. - *

- * The set of kinds is open and client needs to announce the kinds it supports - * to the server during initialization. - */ -public final class CodeActionKind { - - private CodeActionKind() { - } - - /** - * Empty kind. - */ - public static final String Empty = ""; - - /** - * Base kind for quickfix actions: 'quickfix' - */ - public static final String QuickFix = "quickfix"; - - /** - * Base kind for refactoring actions: 'refactor' - */ - public static final String Refactor = "refactor"; - - /** - * Base kind for refactoring extraction actions: 'refactor.extract' - *

- * Example extract actions: - *

    - *
  • Extract method - *
  • Extract function - *
  • Extract variable - *
  • Extract interface from class - *
  • ... - *
- */ - public static final String RefactorExtract = "refactor.extract"; - - /** - * Base kind for refactoring inline actions: 'refactor.inline' - *

- * Example inline actions: - *

    - *
  • Inline function - *
  • Inline variable - *
  • Inline constant - *
  • ... - *
- */ - public static final String RefactorInline = "refactor.inline"; - - /** - * Base kind for refactoring rewrite actions: 'refactor.rewrite' - *

- * Example rewrite actions: - *

    - *
  • Convert function to class - *
  • Add or remove parameter - *
  • Encapsulate field - *
  • Make method static - *
  • Move method to base class - *
  • ... - *
- */ - public static final String RefactorRewrite = "refactor.rewrite"; - - /** - * Base kind for source actions: 'source' - *

- * Source code actions apply to the entire file. - */ - public static final String Source = "source"; - - /** - * Base kind for an organize imports source action: 'source.organizeImports' - */ - public static final String SourceOrganizeImports = "source.organizeImports"; - - /** - * Base kind for a 'fix all' source action: 'source.fixAll'. - *

- * 'Fix all' actions automatically fix errors that have a clear fix that - * do not require user input. They should not suppress errors or perform - * unsafe fixes such as generating new types or classes. - */ - public static final String SourceFixAll = "source.fixAll"; -} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FoldingRangeKind.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FoldingRangeKind.java deleted file mode 100644 index 1838c38e..00000000 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/FoldingRangeKind.java +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * 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; - -/** - * Enum of known range kinds - */ -public final class FoldingRangeKind { - private FoldingRangeKind() {} - - /** - * Folding range for a comment - */ - public static final String Comment = "comment"; - - /** - * Folding range for a imports or includes - */ - public static final String Imports = "imports"; - - /** - * Folding range for a region (e.g. `#region`) - */ - public static final String Region = "region"; - -} 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 2d39c5ba..011e3fd0 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 @@ -23,7 +23,6 @@ import org.eclipse.lsp4j.adapters.DocumentChangeListAdapter import org.eclipse.lsp4j.adapters.HoverTypeAdapter import org.eclipse.lsp4j.adapters.InitializeParamsTypeAdapter import org.eclipse.lsp4j.adapters.ProgressNotificationAdapter -import org.eclipse.lsp4j.adapters.ResourceChangeListAdapter import org.eclipse.lsp4j.adapters.ResourceOperationTypeAdapter import org.eclipse.lsp4j.adapters.SymbolInformationTypeAdapter import org.eclipse.lsp4j.adapters.VersionedTextDocumentIdentifierTypeAdapter @@ -61,16 +60,6 @@ class WorkspaceEditCapabilities { */ Boolean documentChanges - /** - * The client supports resource changes - * in {@link WorkspaceEdit}s. - * - * @deprecated Since LSP introduced resource operations, use {@link #resourceOperations} - */ - @Deprecated - @Beta - Boolean resourceChanges - /** * The resource operations the client supports. Clients should at least * support 'create', 'rename' and 'delete' files and folders. @@ -137,6 +126,15 @@ class DidChangeConfigurationCapabilities extends DynamicRegistrationCapabilities */ @JsonRpcData class DidChangeWatchedFilesCapabilities extends DynamicRegistrationCapabilities { + /** + * Whether the client has support for relative patterns + * or not. + *

+ * Since 3.17.0 + */ + @Beta + Boolean relativePatternSupport + new() { } @@ -327,6 +325,9 @@ class WorkspaceClientCapabilities { */ @Beta DiagnosticWorkspaceCapabilities diagnostics + + new() { + } } @JsonRpcData @@ -1026,7 +1027,7 @@ class CodeActionKindCapabilities { * handle values outside its set gracefully and falls back * to a default value when unknown. *

- * See {@link CodeActionKind} for allowed values. + * See {@link CodeActionKind} for some predefined code action kinds. */ @NonNull List valueSet @@ -1171,7 +1172,6 @@ class CodeLensCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class CodeLensWorkspaceCapabilities { - /** * Whether the client implementation supports a refresh request sent from the * server to the client. @@ -1237,7 +1237,6 @@ class FileOperationsWorkspaceCapabilities extends DynamicRegistrationCapabilitie */ @JsonRpcData class DocumentLinkCapabilities extends DynamicRegistrationCapabilities { - /** * Whether the client supports the {@link DocumentLink#tooltip} property. *

@@ -1279,7 +1278,6 @@ class ColorProviderCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class RenameCapabilities extends DynamicRegistrationCapabilities { - /** * Client supports testing for validity of rename operations * before execution. @@ -1403,6 +1401,54 @@ class DiagnosticsTagSupport { } } +/** + * Specific options for the folding range kind. + *

+ * Since 3.17.0 + */ +@Beta +@JsonRpcData +class FoldingRangeKindSupportCapabilities { + /** + * The folding range 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. + *

+ * See {@link FoldingRangeKind} for some predefined folding range kinds. + */ + List valueSet + + new() { + } + + new(List valueSet) { + this.valueSet = valueSet + } +} + +/** + * Specific options for the folding range. + *

+ * Since 3.17.0 + */ +@Beta +@JsonRpcData +class FoldingRangeSupportCapabilities { + /** + * If set, the client signals that it supports setting {@link FoldingRange#collapsedText} on + * folding ranges to display custom labels instead of the default text. + */ + Boolean collapsedText + + new() { + } + + new(Boolean collapsedText) { + this.collapsedText = collapsedText + } +} + /** * Capabilities specific to `textDocument/foldingRange` requests. *

@@ -1421,6 +1467,25 @@ class FoldingRangeCapabilities extends DynamicRegistrationCapabilities { * ignore specified {@link FoldingRange#startCharacter} and {@link FoldingRange#endCharacter} properties. */ Boolean lineFoldingOnly + + /** + * Specific options for the folding range kind. + *

+ * Since 3.17.0 + */ + @Beta + FoldingRangeKindSupportCapabilities foldingRangeKind + + /** + * Specific options for the folding range. + *

+ * Since 3.17.0 + */ + @Beta + FoldingRangeSupportCapabilities foldingRange + + new() { + } } /** @@ -1431,18 +1496,18 @@ class FoldingRangeCapabilities extends DynamicRegistrationCapabilities { @Beta @JsonRpcData class TypeHierarchyCapabilities extends DynamicRegistrationCapabilities { - new() { } new(Boolean dynamicRegistration) { super(dynamicRegistration) } - } /** + * Type hierarchy registration options. + *

* Since 3.17.0 */ @Beta @@ -1450,7 +1515,7 @@ class TypeHierarchyCapabilities extends DynamicRegistrationCapabilities { class TypeHierarchyRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -1469,14 +1534,12 @@ class TypeHierarchyRegistrationOptions extends AbstractTextDocumentRegistrationA */ @JsonRpcData class CallHierarchyCapabilities extends DynamicRegistrationCapabilities { - new() { } new(Boolean dynamicRegistration) { super(dynamicRegistration) } - } /** @@ -1493,7 +1556,7 @@ class CallHierarchyOptions extends AbstractWorkDoneProgressOptions { class CallHierarchyRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -1512,7 +1575,6 @@ class CallHierarchyRegistrationOptions extends AbstractTextDocumentRegistrationA */ @JsonRpcData class SelectionRangeCapabilities extends DynamicRegistrationCapabilities { - new() { } @@ -1526,7 +1588,6 @@ class SelectionRangeCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class SemanticTokensClientCapabilitiesRequestsFull { - /** * The client will send the `textDocument/semanticTokens/full/delta` request if * the server provides a corresponding handler. @@ -1546,7 +1607,6 @@ class SemanticTokensClientCapabilitiesRequestsFull { */ @JsonRpcData class SemanticTokensClientCapabilitiesRequests { - /** * The client will send the `textDocument/semanticTokens/range` request if * the server provides a corresponding handler. @@ -1579,7 +1639,6 @@ class SemanticTokensClientCapabilitiesRequests { this.full = full this.range = range } - } /** @@ -1587,7 +1646,6 @@ class SemanticTokensClientCapabilitiesRequests { */ @JsonRpcData class SemanticTokensCapabilities extends DynamicRegistrationCapabilities { - /** * Which requests the client supports and might send to the server. */ @@ -1654,6 +1712,9 @@ class SemanticTokensCapabilities extends DynamicRegistrationCapabilities { @Beta Boolean augmentsSyntaxTokens + new() { + } + new(Boolean dynamicRegistration) { super(dynamicRegistration) } @@ -1665,7 +1726,6 @@ class SemanticTokensCapabilities extends DynamicRegistrationCapabilities { this.formats = Preconditions.checkNotNull(formats, 'formats') } - new(Boolean dynamicRegistration, @NonNull SemanticTokensClientCapabilitiesRequests requests, @NonNull List tokenTypes, @NonNull List tokenModifiers, @NonNull List formats) { super(dynamicRegistration) this.requests = Preconditions.checkNotNull(requests, 'requests') @@ -1673,7 +1733,6 @@ class SemanticTokensCapabilities extends DynamicRegistrationCapabilities { this.tokenModifiers = Preconditions.checkNotNull(tokenModifiers, 'tokenModifiers') this.formats = Preconditions.checkNotNull(formats, 'formats') } - } /** @@ -1683,6 +1742,12 @@ class SemanticTokensCapabilities extends DynamicRegistrationCapabilities { */ @JsonRpcData class LinkedEditingRangeCapabilities extends DynamicRegistrationCapabilities { + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -1719,6 +1784,12 @@ class SemanticTokensWorkspaceCapabilities { */ @JsonRpcData class MonikerCapabilities extends DynamicRegistrationCapabilities { + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -2092,6 +2163,9 @@ class TextDocumentClientCapabilities { */ @Beta DiagnosticCapabilities diagnostic + + new() { + } } /** @@ -2120,6 +2194,9 @@ class WindowClientCapabilities { * Since 3.16.0 */ ShowDocumentCapabilities showDocument + + new() { + } } /** @@ -2152,6 +2229,34 @@ class GeneralClientCapabilities { */ @Beta StaleRequestCapabilities staleRequestSupport + + /** + * The position encodings supported by the client. Client and server + * have to agree on the same position encoding to ensure that offsets + * (e.g. character position in a line) are interpreted the same on both + * side. + *

+ * To keep the protocol backwards compatible the following applies: if + * the value 'utf-16' is missing from the array of position encodings + * servers can assume that the client supports UTF-16. UTF-16 is + * therefore a mandatory encoding. + *

+ * If omitted it defaults to [{@link PositionEncodingKind#UTF16}]. + *

+ * Implementation considerations: since the conversion from one encoding + * into another requires the content of the file / line the conversion + * is best done where the file is read which is usually on the server + * side. + *

+ * See {@link PositionEncodingKind} for some predefined position encoding kinds. + *

+ * Since 3.17.0 + */ + @Beta + List positionEncodings + + new() { + } } /** @@ -2214,6 +2319,97 @@ class ClientCapabilities { } } +/** + * The kind of a code action. + *

+ * Kinds are a hierarchical list of identifiers separated by {@code .}, + * e.g. {@code "refactor.extract.function"}. + *

+ * The set of kinds is open and client needs to announce the kinds it supports + * to the server during initialization. + */ +final class CodeActionKind { + /** + * Empty kind. + */ + public static val Empty = '' + + /** + * Base kind for quickfix actions: "quickfix" + */ + public static val QuickFix = 'quickfix' + + /** + * Base kind for refactoring actions: "refactor" + */ + public static val Refactor = 'refactor' + + /** + * Base kind for refactoring extraction actions: "refactor.extract" + *

+ * Example extract actions: + *

    + *
  • Extract method + *
  • Extract function + *
  • Extract variable + *
  • Extract interface from class + *
  • ... + *
+ */ + public static val RefactorExtract = 'refactor.extract' + + /** + * Base kind for refactoring inline actions: "refactor.inline" + *

+ * Example inline actions: + *

    + *
  • Inline function + *
  • Inline variable + *
  • Inline constant + *
  • ... + *
+ */ + public static val RefactorInline = 'refactor.inline' + + /** + * Base kind for refactoring rewrite actions: "refactor.rewrite" + *

+ * Example rewrite actions: + *

    + *
  • Convert function to class + *
  • Add or remove parameter + *
  • Encapsulate field + *
  • Make method static + *
  • Move method to base class + *
  • ... + *
+ */ + public static val RefactorRewrite = 'refactor.rewrite' + + /** + * Base kind for source actions: "source" + *

+ * Source code actions apply to the entire file. + */ + public static val Source = 'source' + + /** + * Base kind for an organize imports source action: "source.organizeImports" + */ + public static val SourceOrganizeImports = 'source.organizeImports' + + /** + * Base kind for a 'fix all' source action: "source.fixAll". + *

+ * 'Fix all' actions automatically fix errors that have a clear fix that + * do not require user input. They should not suppress errors or perform + * unsafe fixes such as generating new types or classes. + */ + public static val SourceFixAll = 'source.fixAll' + + private new() {} +} + /** * A code action represents a change that can be performed in code, e.g. to fix a problem or * to refactor code. @@ -2233,6 +2429,8 @@ class CodeAction { * The kind of the code action. *

* Used to filter code actions. + *

+ * See {@link CodeActionKind} for some predefined code action kinds. */ String kind @@ -2348,7 +2546,7 @@ class CodeActionContext { * 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. + * See {@link CodeActionKind} for some predefined code action kinds. */ List only @@ -2732,6 +2930,21 @@ class CompletionItem { @JsonAdapter(CompletionItemTextEditTypeAdapter) Either textEdit + /** + * The edit text used if the completion item is part of a CompletionList and + * CompletionList defines an item default for the text edit range. + *

+ * Clients will only honor this property if they opt into completion list + * item defaults using the capability {@link CompletionListCapabilities#itemDefaults}. + *

+ * If not provided and a list's default range is provided the label + * property is used as a text. + *

+ * Since 3.17.0 + */ + @Beta + String textEditText + /** * An optional array of additional text edits that are applied when * selecting this completion. Edits must not overlap (including the same insert position) @@ -3198,31 +3411,63 @@ class DidChangeWatchedFilesRegistrationOptions { @JsonRpcData class FileSystemWatcher { /** - * The glob pattern to watch + * The glob pattern to watch. Either a string pattern relative to the base path or a relative pattern. */ @NonNull - String globPattern + Either globPattern /** * The kind of events of interest. If omitted it defaults - * to WatchKind.Create | WatchKind.Change | WatchKind.Delete - * which is 7. + * to {@link WatchKind#Create} | {@link WatchKind#Change} | {@link WatchKind#Delete} + * which is {@code 7}. */ Integer kind new() { } - new(@NonNull String globPattern) { + new(@NonNull Either globPattern) { this.globPattern = Preconditions.checkNotNull(globPattern, 'globPattern') } - new(@NonNull String globPattern, Integer kind) { + new(@NonNull Either globPattern, Integer kind) { this(globPattern) this.kind = kind } } +/** + * A relative pattern is a helper to construct glob patterns that are matched + * relatively to a base URI. The common value for a {@link #baseUri} is a workspace + * folder root, but it can be another absolute URI as well. + *

+ * Since 3.17 + */ +@Beta +@JsonRpcData +class RelativePattern { + /** + * A workspace folder or a base URI as a string to which this pattern will be matched + * against relatively. + */ + @NonNull + Either baseUri + + /** + * The actual glob pattern. + */ + @NonNull + String pattern + + new() { + } + + new(@NonNull Either baseUri, @NonNull String pattern) { + this.baseUri = Preconditions.checkNotNull(baseUri, 'baseUri') + this.pattern = Preconditions.checkNotNull(pattern, 'pattern') + } +} + /** * The document close notification is sent from the client to the server when the document got closed in the client. * The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the @@ -3505,7 +3750,6 @@ class DocumentLinkOptions extends AbstractWorkDoneProgressOptions { */ @JsonRpcData class ExecuteCommandOptions extends AbstractWorkDoneProgressOptions { - /** * The commands to be executed on the server */ @@ -3540,19 +3784,12 @@ class SaveOptions { } /** - * Rename options + * Rename options. + *

+ * Referred to as {@code RenameRegistrationOptions} in the LSP spec. */ @JsonRpcData class RenameOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { - /** - * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. - * - * @deprecated This options object is not specified for StaticRegistrationOptions - */ - @Deprecated - String id - /** * Renames should be checked and tested before being executed. */ @@ -3561,24 +3798,21 @@ class RenameOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressO new() { } - @Deprecated - new(String id) { - this.id = id - } - new(Boolean prepareProvider) { this.prepareProvider = prepareProvider } } /** - * Document color options + * Document color options. + *

+ * Referred to as {@code DocumentColorRegistrationOptions} in the LSP spec. */ @JsonRpcData class ColorProviderOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -3592,12 +3826,16 @@ class ColorProviderOptions extends AbstractTextDocumentRegistrationAndWorkDonePr /** * Folding range options. + *

+ * Since 3.10.0 + *

+ * Referred to as {@code FoldingRangeRegistrationOptions} in the LSP spec. */ @JsonRpcData class FoldingRangeProviderOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -3615,23 +3853,30 @@ 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. */ Either save + + new() { + } } /** @@ -3782,6 +4027,12 @@ class DocumentRangeFormattingRegistrationOptions extends AbstractTextDocumentReg @Beta @JsonRpcData class TypeHierarchyPrepareParams extends TextDocumentPositionAndWorkDoneProgressParams { + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position) { + super(textDocument, position) + } } /** @@ -3799,7 +4050,15 @@ class TypeHierarchySupertypesParams extends WorkDoneProgressAndPartialResultPara /** * Representation of an item that carries type information. */ + @NonNull TypeHierarchyItem item + + new() { + } + + new(@NonNull TypeHierarchyItem item) { + this.item = Preconditions.checkNotNull(item, 'item') + } } /** @@ -3817,7 +4076,15 @@ class TypeHierarchySubtypesParams extends WorkDoneProgressAndPartialResultParams /** * Representation of an item that carries type information. */ + @NonNull TypeHierarchyItem item + + new() { + } + + new(@NonNull TypeHierarchyItem item) { + this.item = Preconditions.checkNotNull(item, 'item') + } } @JsonRpcData @@ -3905,7 +4172,6 @@ class FileEvent { * Value-object describing what options formatting should use. */ class FormattingOptions extends LinkedHashMap> { - static val TAB_SIZE = 'tabSize' static val INSERT_SPACES = 'insertSpaces' static val TRIM_TRAILING_WHITESPACE = 'trimTrailingWhitespace' @@ -4552,8 +4818,9 @@ class InitializeParams implements WorkDoneProgressParams { Object initializationOptions /** - * The capabilities provided by the client (editor) + * The capabilities provided by the client (editor or tool) */ + @NonNull ClientCapabilities capabilities /** @@ -4562,6 +4829,7 @@ class InitializeParams implements WorkDoneProgressParams { * * @deprecated Use {@link #clientInfo} instead. */ + @Beta @Deprecated String clientName @@ -4599,6 +4867,9 @@ class InitializeParams implements WorkDoneProgressParams { * Since 3.6.0 */ List workspaceFolders + + new() { + } } @JsonRpcData @@ -5106,6 +5377,12 @@ class RenameParams extends TextDocumentPositionAndWorkDoneProgressParams { */ @JsonRpcData class LinkedEditingRangeParams extends TextDocumentPositionAndWorkDoneProgressParams { + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position) { + super(textDocument, position) + } } /** @@ -5126,7 +5403,7 @@ class LinkedEditingRangeOptions extends AbstractWorkDoneProgressOptions { class LinkedEditingRangeRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -5183,7 +5460,6 @@ class LinkedEditingRanges { */ @JsonRpcData class SemanticTokensLegend { - /** * The token types that the client supports. */ @@ -5196,6 +5472,9 @@ class SemanticTokensLegend { @NonNull List tokenModifiers + new() { + } + new(@NonNull List tokenTypes, @NonNull List tokenModifiers) { this.tokenTypes = Preconditions.checkNotNull(tokenTypes, 'tokenTypes') this.tokenModifiers = Preconditions.checkNotNull(tokenModifiers, 'tokenModifiers') @@ -5210,7 +5489,6 @@ class SemanticTokensLegend { */ @JsonRpcData class SemanticTokensServerFull { - /** * The server supports deltas for full documents. */ @@ -5498,12 +5776,27 @@ class ServerCapabilities { @Beta DiagnosticRegistrationOptions diagnosticProvider + /** + * The position encoding the server picked from the encodings offered + * by the client via the client capability {@link GeneralClientCapabilities.positionEncodings}. + *

+ * If the client didn't provide any position encodings the only valid + * value that a server can return is {@link PositionEncodingKind#UTF16}. + *

+ * If omitted it defaults to {@link PositionEncodingKind#UTF16}. + *

+ * See {@link PositionEncodingKind} for some predefined position encoding kinds. + *

+ * Since 3.17.0 + */ + @Beta + String positionEncoding + /** * Experimental server capabilities. */ @JsonAdapter(JsonElementTypeAdapter.Factory) Object experimental - } /** @@ -5592,6 +5885,9 @@ class SemanticTokensParams extends WorkDoneProgressAndPartialResultParams { @NonNull TextDocumentIdentifier textDocument + new() { + } + new(@NonNull TextDocumentIdentifier textDocument) { this.textDocument = Preconditions.checkNotNull(textDocument, 'textDocument') } @@ -5602,7 +5898,6 @@ class SemanticTokensParams extends WorkDoneProgressAndPartialResultParams { */ @JsonRpcData class SemanticTokens { - /** * An optional result id. If provided and clients support delta updating * the client will include the result id in the next semantic token request. @@ -5617,6 +5912,9 @@ class SemanticTokens { @NonNull List data + new() { + } + new(@NonNull List data) { this.data = Preconditions.checkNotNull(data, 'data') } @@ -5632,10 +5930,12 @@ class SemanticTokens { */ @JsonRpcData class SemanticTokensPartialResult { - @NonNull List data + new() { + } + new(@NonNull List data) { this.data = Preconditions.checkNotNull(data, 'data') } @@ -5661,6 +5961,9 @@ class SemanticTokensDeltaParams extends WorkDoneProgressAndPartialResultParams { @NonNull String previousResultId + new() { + } + new(@NonNull TextDocumentIdentifier textDocument, @NonNull String previousResultId) { this.textDocument = Preconditions.checkNotNull(textDocument, 'textDocument') this.previousResultId = Preconditions.checkNotNull(previousResultId, 'previousResultId') @@ -5672,7 +5975,6 @@ class SemanticTokensDeltaParams extends WorkDoneProgressAndPartialResultParams { */ @JsonRpcData class SemanticTokensEdit { - /** * The start offset of the edit. */ @@ -5688,6 +5990,9 @@ class SemanticTokensEdit { */ List data + new() { + } + new(int start, int deleteCount, List data) { this.start = start this.deleteCount = deleteCount @@ -5700,7 +6005,6 @@ class SemanticTokensEdit { */ @JsonRpcData class SemanticTokensDelta { - String resultId /** @@ -5709,6 +6013,9 @@ class SemanticTokensDelta { @NonNull List edits + new() { + } + new(@NonNull List edits) { this.edits = Preconditions.checkNotNull(edits, 'edits') } @@ -5724,10 +6031,12 @@ class SemanticTokensDelta { */ @JsonRpcData class SemanticTokensDeltaPartialResult { - @NonNull List edits + new() { + } + new(@NonNull List edits) { this.edits = Preconditions.checkNotNull(edits, 'edits') } @@ -5752,6 +6061,9 @@ class SemanticTokensRangeParams extends WorkDoneProgressAndPartialResultParams { @NonNull Range range + new() { + } + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Range range) { this.textDocument = Preconditions.checkNotNull(textDocument, 'textDocument') this.range = Preconditions.checkNotNull(range, 'range') @@ -6260,7 +6572,7 @@ class TextDocumentContentChangeEvent { /** * The length of the range that got replaced. * - * @deprecated Use range instead. + * @deprecated Use {@link #range} instead. */ @Deprecated Integer rangeLength @@ -6278,6 +6590,12 @@ class TextDocumentContentChangeEvent { this.text = Preconditions.checkNotNull(text, 'text') } + new(Range range, @NonNull String text) { + this(text) + this.range = range + } + + @Deprecated new(Range range, Integer rangeLength, @NonNull String text) { this(text) this.range = range @@ -6804,38 +7122,6 @@ class DeleteFile extends ResourceOperation { } } -/** - * 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. - *
- * - * @deprecated As LSP introduces resource operation, use the {@link ResourceOperation} instead. - */ -@JsonRpcData -@Beta -@Deprecated -class ResourceChange { - - /** - * 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 - -} - /** * A workspace edit represents changes to many resources managed in the workspace. * The edit should either provide {@link #changes} or {@link #documentChanges}. @@ -6867,21 +7153,6 @@ class WorkspaceEdit { @JsonAdapter(DocumentChangeListAdapter) List> documentChanges - /** - * If resource changes are supported the `WorkspaceEdit` - * uses the property `resourceChanges` which are either a - * rename, move, delete or content change. - *

- * These changes are applied in the order that they are supplied, - * however clients may group the changes for optimization - * - * @deprecated Since LSP introduces resource operations, use the {@link #documentChanges} instead - */ - @Beta - @JsonAdapter(ResourceChangeListAdapter) - @Deprecated - List> resourceChanges - /** * A map of change annotations that can be referenced in * {@link AnnotatedTextEdit}s or {@link ResourceOperation}s. @@ -7362,7 +7633,7 @@ class ApplyWorkspaceEditParams { /** * The result of the `workspace/applyEdit` request. *

- * Referred to as {@code ApplyWorkspaceEditResult} in the spec. + * Referred to as {@code ApplyWorkspaceEditResult} in the LSP spec. */ @JsonRpcData class ApplyWorkspaceEditResponse { @@ -8006,6 +8277,8 @@ class ColorPresentation { /** * The folding range request is sent from the client to the server to return all folding * ranges found in a given text document. + *

+ * Since 3.10.0 */ @JsonRpcData class FoldingRangeRequestParams extends WorkDoneProgressAndPartialResultParams { @@ -8023,12 +8296,37 @@ class FoldingRangeRequestParams extends WorkDoneProgressAndPartialResultParams { } } +/** + * A set of predefined range kinds. + *

+ * Since 3.10.0 + */ +final class FoldingRangeKind { + /** + * Folding range for a comment + */ + public static val Comment = 'comment' + + /** + * Folding range for a imports or includes + */ + public static val Imports = 'imports' + + /** + * Folding range for a region + */ + public static val Region = 'region' + + private new() {} +} + /** * Represents a folding range. + *

+ * Since 3.10.0 */ @JsonRpcData class FoldingRange { - /** * The zero-based line number from where the folded range starts. */ @@ -8058,6 +8356,16 @@ class FoldingRange { */ String kind + /** + * The text that the client should show when the specified range is + * collapsed. If not defined or not supported by the client, a default + * will be chosen by the client. + *

+ * Since 3.17.0 + */ + @Beta + String collapsedText + new() { } @@ -8074,7 +8382,12 @@ class FoldingRange { */ @JsonRpcData class CallHierarchyPrepareParams extends TextDocumentPositionAndWorkDoneProgressParams { + new() { + } + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position) { + super(textDocument, position) + } } /** @@ -8226,6 +8539,17 @@ class CallHierarchyItem { */ @JsonAdapter(JsonElementTypeAdapter.Factory) Object data + + new() { + } + + new(@NonNull String name, @NonNull SymbolKind kind, @NonNull String uri, @NonNull Range range, @NonNull Range selectionRange) { + this.name = Preconditions.checkNotNull(name, 'name') + this.kind = Preconditions.checkNotNull(kind, 'kind') + this.uri = Preconditions.checkNotNull(uri, 'uri') + this.range = Preconditions.checkNotNull(range, 'range') + this.selectionRange = Preconditions.checkNotNull(selectionRange, 'selectionRange') + } } /** @@ -8274,7 +8598,7 @@ class SelectionRangeOptions extends AbstractWorkDoneProgressOptions { class SelectionRangeRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -8294,7 +8618,6 @@ class SelectionRangeRegistrationOptions extends AbstractTextDocumentRegistration */ @JsonRpcData class SelectionRange { - /** * The range of this selection range. */ @@ -8351,7 +8674,7 @@ class DeclarationOptions extends AbstractWorkDoneProgressOptions { class DeclarationRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -8407,7 +8730,7 @@ class TypeDefinitionOptions extends AbstractWorkDoneProgressOptions { class TypeDefinitionRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -8441,7 +8764,7 @@ class ImplementationOptions extends AbstractWorkDoneProgressOptions { class ImplementationRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { /** * The id used to register the request. The id can be used to deregister - * the request again. See also Registration#id. + * the request again. See also {@link Registration#id}. */ String id @@ -8528,6 +8851,12 @@ class MonikerRegistrationOptions extends AbstractTextDocumentRegistrationAndWork */ @JsonRpcData class MonikerParams extends TextDocumentPositionAndWorkDoneProgressAndPartialResultParams { + new() { + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position) { + super(textDocument, position) + } } /** @@ -8692,6 +9021,13 @@ class InlayHintCapabilities extends DynamicRegistrationCapabilities { * Indicates which properties a client can resolve lazily on a inlay hint. */ InlayHintResolveSupportCapabilities resolveSupport + + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } } /** @@ -8929,7 +9265,7 @@ class InlayHintWorkspaceCapabilities { *

* Note that this event is global and will force the client to refresh all * inlay hints currently shown. It should be used with absolute care and - * is useful for situation where a server for example detects a project wide + * is useful for situations where a server for example detects a project wide * change that requires such a calculation. */ Boolean refreshSupport @@ -9223,7 +9559,7 @@ class InlineValueWorkspaceCapabilities { *

* Note that this event is global and will force the client to refresh all * inline values currently shown. It should be used with absolute care and - * is useful for situation where a server for example detect a project wide + * is useful for situations where a server for example detect a project wide * change that requires such a calculation. */ Boolean refreshSupport @@ -9236,6 +9572,39 @@ class InlineValueWorkspaceCapabilities { } } +/** + * A set of predefined position encoding kinds indicating how + * positions are encoded, specifically what column offsets mean. + *

+ * Since 3.17.0 + */ +@Beta +final class PositionEncodingKind { + /** + * Character offsets count UTF-8 code units. + */ + public static val UTF8 = 'utf-8' + + /** + * Character offsets count UTF-16 code units. + *

+ * This is the default and must always be supported + * by servers. + */ + public static val UTF16 = 'utf-16' + + /** + * Character offsets count UTF-32 code units. + *

+ * Implementation note: these are the same as Unicode code points, + * so this kind may also be used for an encoding-agnostic + * representation of character offsets. + */ + public static val UTF32 = 'utf-32' + + private new() {} +} + /** * Client capabilities specific to diagnostic pull requests. *

diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceChangeListAdapter.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceChangeListAdapter.java deleted file mode 100644 index 7c61961a..00000000 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/ResourceChangeListAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************** - * 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.util.ArrayList; -import java.util.function.Predicate; - -import org.eclipse.lsp4j.ResourceChange; -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; - -@SuppressWarnings("deprecation") -public class ResourceChangeListAdapter implements TypeAdapterFactory { - - private static final TypeToken> ELEMENT_TYPE - = new TypeToken>() {}; - - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - Predicate leftChecker = new PropertyChecker("current").or(new PropertyChecker("newUri")); - Predicate rightChecker = new PropertyChecker("textDocument").and(new PropertyChecker("edits")); - TypeAdapter> elementTypeAdapter = new EitherTypeAdapter<>(gson, - ELEMENT_TYPE, leftChecker, rightChecker); - return (TypeAdapter) new CollectionTypeAdapter<>(gson, ELEMENT_TYPE.getType(), elementTypeAdapter, ArrayList::new); - } - -} \ No newline at end of file