From 2093bd81e9b7a1779faff0ef4d62b849bebb3e73 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 13:23:54 +0300 Subject: [PATCH 01/17] Clean up doc comments related to LSP 3.18 support --- .../lsp4j/InlineCompletionTriggerKind.java | 2 +- .../java/org/eclipse/lsp4j/Protocol.xtend | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/InlineCompletionTriggerKind.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/InlineCompletionTriggerKind.java index 05f5d2a8..1fd137ea 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/InlineCompletionTriggerKind.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/InlineCompletionTriggerKind.java @@ -16,7 +16,7 @@ /** * Describes how an inline completion request was triggered. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft public enum InlineCompletionTriggerKind { 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 8ea266bb..cc9b9674 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 @@ -2243,9 +2243,9 @@ class TextDocumentClientCapabilities { DiagnosticCapabilities diagnostic /** - * Capabilities specific to the `textDocument/inlineCompletion` request. + * Capabilities specific to the {@code textDocument/inlineCompletion} request. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft InlineCompletionClientCapabilities inlineCompletion @@ -6071,19 +6071,19 @@ class ServerCapabilities { Either inlineValueProvider /** - * The server provides inline completions. + * The server has support for pull model diagnostics. *

- * @since 3.18.0 + * Since 3.17.0 */ - @Draft - Either inlineCompletionProvider + DiagnosticRegistrationOptions diagnosticProvider /** - * The server has support for pull model diagnostics. + * The server provides inline completions. *

- * Since 3.17.0 + * Since 3.18.0 */ - DiagnosticRegistrationOptions diagnosticProvider + @Draft + Either inlineCompletionProvider /** * Experimental server capabilities. @@ -11204,7 +11204,7 @@ final class StringValueKind { * the end of the snippet. Variables are defined with `$name` and * `${name:default value}`. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11235,7 +11235,7 @@ class StringValue { /** * Client capabilities specific to inline completions. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11251,7 +11251,7 @@ class InlineCompletionClientCapabilities extends DynamicRegistrationCapabilities /** * Inline completion options used during static or dynamic registration. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11273,7 +11273,7 @@ class InlineCompletionRegistrationOptions extends AbstractTextDocumentRegistrati /** * A parameter literal used in inline completion requests. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11298,7 +11298,7 @@ class InlineCompletionParams extends TextDocumentPositionAndWorkDoneProgressPara * Provides information about the context in which an inline completion was * requested. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11341,7 +11341,7 @@ class InlineCompletionContext { /** * Describes the currently selected completion item. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11371,7 +11371,7 @@ class SelectedCompletionInfo { /** * Represents a collection of {@link InlineCompletionItem} to be presented in the editor. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData @@ -11394,7 +11394,7 @@ class InlineCompletionList { * An inline completion item represents a text snippet that is proposed inline * to complete text that is being typed. *

- * @since 3.18.0 + * Since 3.18.0 */ @Draft @JsonRpcData From c873a50897f0c3caec2b35a94f88f5b67b11a395 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 14:27:46 +0300 Subject: [PATCH 02/17] Rename InlineCompletionClientCapabilities Renames `InlineCompletionClientCapabilities` to `InlineCompletionCapabilities` to match existing naming conventions for property types in `TextDocumentClientCapabilities`. --- .../src/main/java/org/eclipse/lsp4j/Protocol.xtend | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 cc9b9674..af8a3483 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 @@ -2248,7 +2248,7 @@ class TextDocumentClientCapabilities { * Since 3.18.0 */ @Draft - InlineCompletionClientCapabilities inlineCompletion + InlineCompletionCapabilities inlineCompletion new() { } @@ -11239,7 +11239,7 @@ class StringValue { */ @Draft @JsonRpcData -class InlineCompletionClientCapabilities extends DynamicRegistrationCapabilities { +class InlineCompletionCapabilities extends DynamicRegistrationCapabilities { new() { } From 037165233c1b9ef72cf52fd81a6ab8a29333b1ad Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Fri, 25 Jul 2025 20:07:55 +0300 Subject: [PATCH 03/17] Add beta support for SnippetTextEdit Closes #810. --- CHANGELOG.md | 2 + .../java/org/eclipse/lsp4j/Protocol.xtend | 61 ++++++++++++++++++- .../lsp4j/adapters/TextEditListAdapter.java | 40 ++++++++++++ .../lsp4j/test/services/JsonParseTest.xtend | 32 +++++++++- 4 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/TextEditListAdapter.java diff --git a/CHANGELOG.md b/CHANGELOG.md index c5fbf947..be700e1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Fixed issues: Breaking API changes: + * Type of `TextDocumentEdit.edits` changed from `List` to `List>` + japicmp report: ### [v0.24.0 (Jan 2025)](https://github.com/eclipse-lsp4j/lsp4j/releases/tag/v0.24.0) 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 af8a3483..9f433792 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 @@ -25,6 +25,7 @@ import org.eclipse.lsp4j.adapters.InitializeParamsTypeAdapter import org.eclipse.lsp4j.adapters.ProgressNotificationAdapter import org.eclipse.lsp4j.adapters.ResourceOperationTypeAdapter import org.eclipse.lsp4j.adapters.SymbolInformationTypeAdapter +import org.eclipse.lsp4j.adapters.TextEditListAdapter import org.eclipse.lsp4j.adapters.VersionedTextDocumentIdentifierTypeAdapter import org.eclipse.lsp4j.adapters.WorkspaceDocumentDiagnosticReportListAdapter import org.eclipse.lsp4j.adapters.WorkspaceSymbolLocationTypeAdapter @@ -102,6 +103,14 @@ class WorkspaceEditCapabilities { */ WorkspaceEditChangeAnnotationSupportCapabilities changeAnnotationSupport + /** + * Whether the client supports snippets as text edits. + *

+ * Since 3.18.0 + */ + @Draft + Boolean snippetEditSupport + new() { } @@ -7217,15 +7226,21 @@ class TextDocumentEdit { VersionedTextDocumentIdentifier textDocument /** - * The edits to be applied + * The edits to be applied. + *

+ * Since 3.18 - support for {@link SnippetTextEdit}. This is guarded by the + * client capability {@link WorkspaceEditCapabilities#snippetEditSupport}. + * If a client does not signal this capability, servers should not send + * {@link SnippetTextEdit} snippets back to the client. */ @NonNull - List edits + @JsonAdapter(TextEditListAdapter) + List> edits new() { } - new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List edits) { + new(@NonNull VersionedTextDocumentIdentifier textDocument, @NonNull List> edits) { this.textDocument = Preconditions.checkNotNull(textDocument, 'textDocument') this.edits = Preconditions.checkNotNull(edits, 'edits') } @@ -11438,3 +11453,43 @@ class InlineCompletionItem { this.insertText = Preconditions.checkNotNull(insertText, 'insertText') } } + +/** + * An interactive text edit. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class SnippetTextEdit { + + /** + * The range of the text document to be manipulated. + */ + @NonNull + Range range + + /** + * The snippet to be inserted. + */ + @NonNull + StringValue snippet + + /** + * The actual identifier of the snippet edit. + */ + String annotationId + + new() { + } + + new(@NonNull Range range, @NonNull StringValue snippet) { + this.range = Preconditions.checkNotNull(range, 'range') + this.snippet = Preconditions.checkNotNull(snippet, 'snippet') + } + + new(@NonNull Range range, @NonNull StringValue snippet, String annotationId) { + this(range, snippet) + this.annotationId = annotationId + } +} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/TextEditListAdapter.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/TextEditListAdapter.java new file mode 100644 index 00000000..cfc606f0 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/TextEditListAdapter.java @@ -0,0 +1,40 @@ +/****************************************************************************** + * Copyright (c) 2025 1C-Soft LLC 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 org.eclipse.lsp4j.SnippetTextEdit; +import org.eclipse.lsp4j.TextEdit; +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.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +public class TextEditListAdapter implements TypeAdapterFactory { + + private static final TypeToken> ELEMENT_TYPE = new TypeToken<>() {}; + + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + final var leftChecker = new PropertyChecker("newText"); + final var rightChecker = new PropertyChecker("snippet"); + final var 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/test/java/org/eclipse/lsp4j/test/services/JsonParseTest.xtend b/org.eclipse.lsp4j/src/test/java/org/eclipse/lsp4j/test/services/JsonParseTest.xtend index 3c8d8e53..5d260da5 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 @@ -76,6 +76,8 @@ import org.eclipse.lsp4j.SignatureHelp import org.eclipse.lsp4j.SignatureHelpCapabilities import org.eclipse.lsp4j.SignatureInformation import org.eclipse.lsp4j.SignatureInformationCapabilities +import org.eclipse.lsp4j.SnippetTextEdit +import org.eclipse.lsp4j.StringValue import org.eclipse.lsp4j.SymbolInformation import org.eclipse.lsp4j.SymbolKind import org.eclipse.lsp4j.SymbolKindCapabilities @@ -855,6 +857,22 @@ class JsonParseTest { } }, "newText": "asdfqweryxcv" + }, + { + "range": { + "start": { + "character": 33, + "line": 5 + }, + "end": { + "character": 37, + "line": 5 + } + }, + "snippet": { + "kind": "snippet", + "value": "abra$0cadabra" + } } ] } @@ -883,13 +901,23 @@ class JsonParseTest { Either.forLeft(new TextDocumentEdit => [ textDocument = new VersionedTextDocumentIdentifier("file:/baz.txt", 17) edits = newArrayList( - new TextEdit => [ + Either.forLeft(new TextEdit => [ range = new Range => [ start = new Position(3, 32) end = new Position(3, 35) ] newText = "asdfqweryxcv" - ] + ]), + Either.forRight(new SnippetTextEdit => [ + range = new Range => [ + start = new Position(5, 33) + end = new Position(5, 37) + ] + snippet = new StringValue => [ + kind = "snippet" + value = "abra$0cadabra" + ] + ]) ) ]) ) From 9658eee56ee95d5ab1eb1ab67698f612a30c38ef Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 13:34:37 +0300 Subject: [PATCH 04/17] Add beta support for markup content in diagnostic messages --- CHANGELOG.md | 1 + .../java/org/eclipse/lsp4j/Protocol.xtend | 71 ++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be700e1f..0e39108a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Fixed issues: Breaking API changes: * Type of `TextDocumentEdit.edits` changed from `List` to `List>` + * Type of `Diagnostic.message` changed from `String` to `Either` japicmp report: 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 9f433792..0a5bd83f 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 @@ -2656,7 +2656,17 @@ class CodeActionDisabled { @JsonRpcData class CodeActionContext { /** - * An array of diagnostics. + * An array of diagnostics known on the client side overlapping the range + * provided to the {@code textDocument/codeAction} request. They are provided + * so that the server knows which errors are currently presented to the user + * for the given range. There is no guarantee that these accurately reflect the + * error state of the resource. The primary parameter to compute code actions + * is the provided range. + *

+ * Note that the client should check the {@link DiagnosticServerCapabilities#markupMessageSupport} + * server capability before sending diagnostics with markup messages to a server. + * Diagnostics with markup messages should be excluded for servers that do not + * support them. */ @NonNull List diagnostics @@ -3339,9 +3349,14 @@ class Diagnostic { /** * The diagnostic's message. + *

+ * Since 3.18.0 - support for {@link MarkupContent}. This is guarded by the client + * capability {@link DiagnosticCapabilities#markupMessageSupport}. If a client does not + * signal this capability, servers should not send {@link MarkupContent} diagnostic messages + * back to the client. */ @NonNull - String message + Either message /** * Additional metadata about the diagnostic. @@ -6094,6 +6109,14 @@ class ServerCapabilities { @Draft Either inlineCompletionProvider + /** + * Text document specific server capabilities. + *

+ * Since 3.18.0 + */ + @Draft + TextDocumentServerCapabilities textDocument + /** * Experimental server capabilities. */ @@ -6128,6 +6151,24 @@ class WorkspaceServerCapabilities { } } +/** + * Text document specific server capabilities. + *

+ * Since 3.18.0. + */ +@Draft +@JsonRpcData +class TextDocumentServerCapabilities { + + /** + * Capabilities specific to the diagnostic pull model. + */ + DiagnosticServerCapabilities diagnostic + + new() { + } +} + /** * The show message request is sent from a server to a client to ask the client to display a particular message in the * user class. In addition to the show message notification the request allows to pass actions and to wait for an @@ -10032,6 +10073,14 @@ class DiagnosticCapabilities extends DynamicRegistrationCapabilities { */ Boolean relatedDocumentSupport + /** + * Whether the client supports {@link MarkupContent} in diagnostic messages. + *

+ * Since 3.18.0 + */ + @Draft + Boolean markupMessageSupport + new() { } @@ -10045,6 +10094,24 @@ class DiagnosticCapabilities extends DynamicRegistrationCapabilities { } } +/** + * Server capabilities specific to the diagnostic pull model. + *

+ * Since 3.18.0. + */ +@Draft +@JsonRpcData +class DiagnosticServerCapabilities { + + /** + * Whether the server supports {@link MarkupContent} in diagnostic messages. + */ + Boolean markupMessageSupport + + new() { + } +} + /** * Diagnostic registration options. *

From ac12d19a9e10fa9842d14102384f9ed3275b88e7 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 15:43:45 +0300 Subject: [PATCH 05/17] Add beta support for relative patterns in document filters --- CHANGELOG.md | 2 + .../java/org/eclipse/lsp4j/Protocol.xtend | 48 ++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e39108a..86a8154c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Breaking API changes: * Type of `TextDocumentEdit.edits` changed from `List` to `List>` * Type of `Diagnostic.message` changed from `String` to `Either` + * Type of `DocumentFilter.pattern` changed from `String` to `Either` + * Type of `NotebookDocumentFilter.pattern` changed from `String` to `Either` japicmp report: 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 0a5bd83f..05b27868 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 @@ -404,6 +404,9 @@ class WorkspaceClientCapabilities { } } +/** + * Defines which synchronization capabilities the client supports. + */ @JsonRpcData class SynchronizationCapabilities extends DynamicRegistrationCapabilities { /** @@ -440,6 +443,23 @@ class SynchronizationCapabilities extends DynamicRegistrationCapabilities { } } +/** + * Defines which filters the client supports. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class FiltersCapabilities { + /** + * The client supports relative patterns in document filters. + */ + Boolean relativePatternSupport + + new() { + } +} + /** * The client supports the following {@link CompletionItem} specific capabilities. */ @@ -2073,8 +2093,19 @@ class WorkspaceEditChangeAnnotationSupportCapabilities { */ @JsonRpcData class TextDocumentClientCapabilities { + /** + * Defines which synchronization capabilities the client supports. + */ SynchronizationCapabilities synchronization + /** + * Defines which filters the client supports. + *

+ * Since 3.18.0 + */ + @Draft + FiltersCapabilities filters + /** * Capabilities specific to the {@code textDocument/completion} */ @@ -7659,28 +7690,33 @@ class RegistrationParams { /** * A document filter denotes a document through properties like language, schema or pattern. + *

+ * At least one of the properties {@link #language}, {@link #scheme}, or {@link #pattern} must be set. */ @JsonRpcData class DocumentFilter { /** - * A language id, like `typescript`. + * A language id, like {@code typescript}. */ String language /** - * A uri scheme, like `file` or `untitled`. + * A uri scheme, like {@code file} or {@code untitled}. */ String scheme /** - * A glob pattern, like `*.{ts,js}`. + * A glob pattern, like *.{ts,js}. + *

+ * Since 3.18 - support for relative patterns, which depends on the + * client capability {@link FiltersCapabilities#relativePatternSupport}. */ - String pattern + Either pattern new() { } - new(String language, String scheme, String pattern) { + new(String language, String scheme, Either pattern) { this.language = language this.scheme = scheme this.pattern = pattern @@ -10791,7 +10827,7 @@ class NotebookDocumentFilter { /** * A glob pattern. */ - String pattern + Either pattern new() { } From 8dcaae8f75d14ab19895281222e26eb1567fc4c1 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 16:07:02 +0300 Subject: [PATCH 06/17] Add beta support for properties that can be resolved for code lenses --- .../java/org/eclipse/lsp4j/Protocol.xtend | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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 05b27868..3381b70c 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 @@ -1270,10 +1270,44 @@ class CodeActionCapabilities extends DynamicRegistrationCapabilities { } /** - * Capabilities specific to the `textDocument/codeLens` + * Whether the client supports resolving additional code lens + * properties via a separate {@code codeLens/resolve} request. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class CodeLensResolveSupportCapabilities { + /** + * The properties that a client can resolve lazily. + */ + @NonNull + List properties + + new() { + this.properties = new ArrayList + } + + new(@NonNull List properties) { + this.properties = Preconditions.checkNotNull(properties, 'properties') + } +} + +/** + * Capabilities specific to the {@code textDocument/codeLens} */ @JsonRpcData class CodeLensCapabilities extends DynamicRegistrationCapabilities { + + /** + * Whether the client supports resolving additional code lens + * properties via a separate {@code codeLens/resolve} request. + *

+ * Since 3.18.0 + */ + @Draft + CodeLensResolveSupportCapabilities resolveSupport + new() { } From 753434d4410a7323578b80f895c3f97f1f3bb5cd Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 16:37:02 +0300 Subject: [PATCH 07/17] Add beta support for folding range refresh request --- .../java/org/eclipse/lsp4j/Protocol.xtend | 35 +++++++++++++++++++ .../lsp4j/services/LanguageClient.java | 17 +++++++++ 2 files changed, 52 insertions(+) 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 3381b70c..34a925c5 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 @@ -400,6 +400,14 @@ class WorkspaceClientCapabilities { */ DiagnosticWorkspaceCapabilities diagnostics + /** + * Client workspace capabilities specific to folding ranges. + *

+ * Since 3.18.0 + */ + @Draft + FoldingRangeWorkspaceCapabilities foldingRange + new() { } } @@ -1636,6 +1644,33 @@ class FoldingRangeCapabilities extends DynamicRegistrationCapabilities { } } +/** + * Client workspace capabilities specific to folding ranges. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class FoldingRangeWorkspaceCapabilities { + /** + * Whether the client implementation supports a refresh request sent from the + * server to the client. + *

+ * Note that this event is global and will force the client to refresh all + * folding ranges currently shown. It should be used with absolute care and is + * useful for situations where a server, for example, detects a project-wide + * change that requires such a calculation. + */ + Boolean refreshSupport + + new() { + } + + new(Boolean refreshSupport) { + this.refreshSupport = refreshSupport + } +} + /** * Capabilities specific to the {@code textDocument/prepareTypeHierarchy}. *

diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java index ee907cc9..3eb2e462 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java @@ -29,6 +29,7 @@ import org.eclipse.lsp4j.UnregistrationParams; import org.eclipse.lsp4j.WorkDoneProgressCreateParams; import org.eclipse.lsp4j.WorkspaceFolder; +import org.eclipse.lsp4j.jsonrpc.Draft; import org.eclipse.lsp4j.jsonrpc.services.JsonNotification; import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; @@ -250,4 +251,20 @@ default CompletableFuture refreshInlineValues() { default CompletableFuture refreshDiagnostics() { throw new UnsupportedOperationException(); } + + /** + * The {@code workspace/foldingRange/refresh} request is sent from the server to the client. + * Servers can use it to ask clients to refresh the folding ranges currently shown in editors. + * As a result the client should ask the server to recompute the folding ranges for these editors. + * This is useful if a server detects a configuration change which requires a re-calculation of + * all folding ranges. Note that the client still has the freedom to delay the re-calculation of + * the folding ranges if, for example, an editor is currently not visible. + *

+ * Since 3.18.0 + */ + @Draft + @JsonRequest("workspace/foldingRange/refresh") + default CompletableFuture refreshFoldingRanges() { + throw new UnsupportedOperationException(); + } } From 6e3552f87d103d8150c9e12052434a819829e810 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 16:43:02 +0300 Subject: [PATCH 08/17] Add beta support for the 'label' semantic token type --- .../src/main/java/org/eclipse/lsp4j/Protocol.xtend | 6 ++++++ 1 file changed, 6 insertions(+) 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 34a925c5..51021dac 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 @@ -5823,6 +5823,12 @@ final class SemanticTokenTypes { */ public static val Decorator = 'decorator' + /** + * Since 3.18.0 + */ + @Draft + public static val Label = 'label' + private new() { } } From 51a2bb76942ed1522f25acdba7e1783410d457d9 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Sun, 27 Jul 2025 18:01:04 +0300 Subject: [PATCH 09/17] Add beta support for `CompletionList.applyKind` --- .../java/org/eclipse/lsp4j/ApplyKind.java | 54 ++++++++ .../java/org/eclipse/lsp4j/Protocol.xtend | 115 +++++++++++++++++- 2 files changed, 165 insertions(+), 4 deletions(-) create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ApplyKind.java diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ApplyKind.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ApplyKind.java new file mode 100644 index 00000000..6dbdad78 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/ApplyKind.java @@ -0,0 +1,54 @@ +/****************************************************************************** + * Copyright (c) 2025 1C-Soft LLC 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.jsonrpc.Draft; + +/** + * Defines how values from a set of defaults and an individual item will be merged. + *

+ * Since 3.18.0 + */ +@Draft +public enum ApplyKind { + /** + * The value from the individual item (if provided and not {@code null}) will be + * used instead of the default. + */ + Replace(1), + + /** + * The value from the item will be merged with the default. + *

+ * The specific rules for merging values are defined against each field + * that supports merging. + */ + Merge(2); + + private final int value; + + ApplyKind(final int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static ApplyKind forValue(final int value) { + ApplyKind[] allValues = ApplyKind.values(); + if (value < 1 || value > allValues.length) { + throw new IllegalArgumentException("Illegal enum value: " + value); + } + return allValues[value - 1]; + } +} 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 51021dac..f16acf1a 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 @@ -681,6 +681,22 @@ class CompletionListCapabilities { */ List itemDefaults + /** + * Specifies whether the client supports {@link CompletionList#applyKind} to + * indicate how supported values from {@link CompletionList#itemDefaults} + * and a completion will be combined. + *

+ * If a client supports {@link CompletionList#applyKind} it must support it + * for all fields that it supports that are listed in {@link CompletionApplyKind}. + * This means when clients add support for new/future fields in completion items + * they MUST also support merge for them if those fields are defined in + * {@link CompletionApplyKind}. + *

+ * Since 3.18.0 + */ + @Draft + Boolean applyKindSupport + new() { } @@ -3248,13 +3264,15 @@ class InsertReplaceRange { } /** - * In many cases the items of an actual completion result share the same + * In many cases, the items of an actual completion result share the same * value for properties like {@link CompletionItem#commitCharacters} or the range of a text * edit. A completion list can therefore define item defaults which will * be used if a completion item itself doesn't specify the value. *

* If a completion list specifies a default value and a completion item - * also specifies a corresponding value the one from the item is used. + * also specifies a corresponding value, the rules for combining these are + * defined by {@link CompletionList#applyKind} (if the client supports it), + * defaulting to {@link ApplyKind#Replace}. *

* Servers are only allowed to return default values if the client * signals support for this via the {@link CompletionListCapabilities#itemDefaults} @@ -3295,6 +3313,71 @@ class CompletionItemDefaults { } } +/** + * Specifies how fields from a completion item should be combined with those + * from {@link CompletionList#itemDefaults}. + *

+ * If unspecified, all fields will be treated as {@link ApplyKind#Replace}. + *

+ * If a field's value is {@link ApplyKind#Replace}, the value from a completion item + * (if provided and not {@code null}) will always be used instead of the value + * from {@link CompletionList#itemDefaults}. + *

+ * If a field's value is {@link ApplyKind#Merge}, the values will be merged using + * the rules defined against each field in {@link CompletionApplyKind}. + *

+ * Servers are only allowed to return {@link CompletionList#applyKind} if the client + * signals support for this via the {@link CompletionListCapabilities#applyKindSupport} + * capability. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class CompletionApplyKind { + /** + * Specifies whether {@link CompletionItem#commitCharacters commitCharacters} + * on a completion will replace or be merged with those in + * {@link CompletionItemDefaults#commitCharacters}. + *

+ * If {@link ApplyKind#Replace}, the commit characters from the completion item + * will always be used unless not provided, in which case those from + * {@link CompletionItemDefaults#commitCharacters} will be used. An + * empty list can be used if a completion item does not have any commit + * characters and also should not use those from + * {@link CompletionItemDefaults#commitCharacters}. + *

+ * If {@link ApplyKind#Merge}, the commit characters for the completion will be + * the union of all values in both {@link CompletionItemDefaults#commitCharacters} + * and the completion's own {@link CompletionItem#commitCharacters commitCharacters}. + */ + ApplyKind commitCharacters + + /** + * Specifies whether the {@link CompletionItem#data data} field on a completion + * will replace or be merged with data from {@link CompletionItemDefaults#data}. + *

+ * If {@link ApplyKind#Replace}, the data from the completion item will be used + * if provided (and not {@code null}), otherwise {@link CompletionItemDefaults#data} + * will be used. An empty object can be used if a completion item does not have + * any data but also should not use the value from {@link CompletionItemDefaults#data}. + *

+ * If {@link ApplyKind#Merge}, a shallow merge will be performed between + * {@link CompletionItemDefaults#data} and the completion's own data + * using the following rules: + *

+ */ + ApplyKind data +} + /** * Represents a collection of completion items to be presented in the editor. */ @@ -3312,13 +3395,15 @@ class CompletionList { List items /** - * In many cases the items of an actual completion result share the same + * In many cases, the items of an actual completion result share the same * value for properties like {@link CompletionItem#commitCharacters} or the range of a text * edit. A completion list can therefore define item defaults which will * be used if a completion item itself doesn't specify the value. *

* If a completion list specifies a default value and a completion item - * also specifies a corresponding value the one from the item is used. + * also specifies a corresponding value, the rules for combining these are + * defined by {@link CompletionList#applyKind} (if the client supports it), + * defaulting to {@link ApplyKind#Replace}. *

* Servers are only allowed to return default values if the client * signals support for this via the {@link CompletionListCapabilities#itemDefaults} @@ -3328,6 +3413,28 @@ class CompletionList { */ CompletionItemDefaults itemDefaults + /** + * Specifies how fields from a completion item should be combined with those + * from {@link CompletionList#itemDefaults}. + *

+ * If unspecified, all fields will be treated as {@link ApplyKind#Replace}. + *

+ * If a field's value is {@link ApplyKind#Replace}, the value from a completion item + * (if provided and not {@code null}) will always be used instead of the value + * from {@link CompletionList#itemDefaults}. + *

+ * If a field's value is {@link ApplyKind#Merge}, the values will be merged using + * the rules defined against each field in {@link CompletionApplyKind}. + *

+ * Servers are only allowed to return {@link CompletionList#applyKind} if the client + * signals support for this via the {@link CompletionListCapabilities#applyKindSupport} + * capability. + *

+ * Since 3.18.0 + */ + @Draft + CompletionApplyKind applyKind + new() { this(new ArrayList) } From a7b4a27de32e56336f6434a347297c5b91aa73a1 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Mon, 28 Jul 2025 17:00:21 +0300 Subject: [PATCH 10/17] Add beta support for code action kind documentation --- .../java/org/eclipse/lsp4j/Protocol.xtend | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) 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 f16acf1a..818e16a4 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 @@ -1275,6 +1275,14 @@ class CodeActionCapabilities extends DynamicRegistrationCapabilities { */ Boolean honorsChangeAnnotations + /** + * Whether the client supports documentation for a class of code actions. + *

+ * Since 3.18.0 + */ + @Draft + Boolean documentationSupport + new() { } @@ -2891,6 +2899,36 @@ class CodeLens { } } +/** + * Documentation for a class of code actions. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class CodeActionKindDocumentation { + /** + * The kind of the code action being documented. + *

+ * If the kind is generic, such as {@link CodeActionKind#Refactor}, the + * documentation will be shown whenever any refactorings are returned. If + * the kind is more specific, such as {@link CodeActionKind#RefactorExtract}, + * the documentation will only be shown when extract refactoring code actions + * are returned. + */ + @NonNull + String kind + + /** + * Command that is used to display the documentation to the user. + *

+ * The title of this documentation code action is taken + * from {@link Command#title}. + */ + @NonNull + Command command +} + /** * Code Action options. */ @@ -2906,6 +2944,29 @@ class CodeActionOptions extends AbstractWorkDoneProgressOptions { */ List codeActionKinds + /** + * Static documentation for a class of code actions. + *

+ * Documentation from the provider should be shown in the code actions + * menu if either: + *

+ * At most one documentation entry should be shown per provider. + *

+ * Since 3.18.0 + */ + @Draft + List documentation + /** * The server provides support to resolve additional * information for a code action. From b197e6809cbba29c67d95e7a0e9edf9c92539a47 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Mon, 28 Jul 2025 17:12:38 +0300 Subject: [PATCH 11/17] Add beta support for new predefined code action kinds --- .../java/org/eclipse/lsp4j/Protocol.xtend | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 818e16a4..f2515ba5 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 @@ -2616,6 +2616,21 @@ final class CodeActionKind { */ public static val RefactorInline = 'refactor.inline' + /** + * Base kind for refactoring move actions: "refactor.move" + *

+ * Example move actions: + *

+ * Since 3.18.0 + */ + @Draft + public static val RefactorMove = 'refactor.move' + /** * Base kind for refactoring rewrite actions: "refactor.rewrite" *

@@ -2652,6 +2667,15 @@ final class CodeActionKind { */ public static val SourceFixAll = 'source.fixAll' + /** + * Base kind for all code actions applying to the entire notebook's scope. + * Code action kinds using this should always begin with "notebook." + *

+ * Since 3.18.0 + */ + @Draft + public static val Notebook = 'notebook' + private new() {} } From 4f1b992167fd703dce9e5973cc8d320a931030e8 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Mon, 28 Jul 2025 17:40:59 +0300 Subject: [PATCH 12/17] Add beta support for code action tags --- .../java/org/eclipse/lsp4j/CodeActionTag.java | 45 +++++++++++++++++++ .../java/org/eclipse/lsp4j/Protocol.xtend | 41 +++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionTag.java diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionTag.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionTag.java new file mode 100644 index 00000000..47e94114 --- /dev/null +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/CodeActionTag.java @@ -0,0 +1,45 @@ +/****************************************************************************** + * Copyright (c) 2025 1C-Soft LLC 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.jsonrpc.Draft; + +/** + * Code action tags are extra annotations that tweak the behavior of a code action. + *

+ * Since 3.18.0 + */ +@Draft +public enum CodeActionTag { + /** + * Marks the code action as LLM-generated. + */ + LLMGenerated(1); + + private final int value; + + CodeActionTag(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static CodeActionTag forValue(int value) { + CodeActionTag[] allValues = CodeActionTag.values(); + if (value < 1 || value > allValues.length) { + throw new IllegalArgumentException("Illegal enum value: " + value); + } + return allValues[value - 1]; + } +} 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 f2515ba5..f0032818 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 @@ -1222,6 +1222,30 @@ class CodeActionResolveSupportCapabilities { } } +/** + * Client supports the tag property on a code action. Clients + * supporting tags have to handle unknown tags gracefully. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class CodeActionTagSupportCapabilities { + /** + * The tags supported by the client. + */ + @NonNull + List valueSet + + new() { + this.valueSet = new ArrayList + } + + new(@NonNull List valueSet) { + this.valueSet = Preconditions.checkNotNull(valueSet, 'valueSet') + } +} + /** * Capabilities specific to the `textDocument/codeAction` */ @@ -1283,6 +1307,15 @@ class CodeActionCapabilities extends DynamicRegistrationCapabilities { @Draft Boolean documentationSupport + /** + * Client supports the tag property on a code action. Clients + * supporting tags have to handle unknown tags gracefully. + *

+ * Since 3.18.0 + */ + @Draft + CodeActionTagSupportCapabilities tagSupport + new() { } @@ -2757,6 +2790,14 @@ class CodeAction { @JsonAdapter(JsonElementTypeAdapter.Factory) Object data + /** + * Tags for this code action. + *

+ * Since 3.18.0 + */ + @Draft + List tags + new() { } From e4d931b5717e6ad27cce9f9d82632cda1de67ca5 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Tue, 29 Jul 2025 13:49:21 +0300 Subject: [PATCH 13/17] Add beta support for metadata information on workspace edits --- .../java/org/eclipse/lsp4j/Protocol.xtend | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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 f0032818..c23107a5 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 @@ -111,6 +111,14 @@ class WorkspaceEditCapabilities { @Draft Boolean snippetEditSupport + /** + * Whether the client supports {@link WorkspaceEditMetadata} in workspace edits. + *

+ * Since 3.18.0 + */ + @Draft + Boolean metadataSupport + new() { } @@ -8312,6 +8320,23 @@ class ExecuteCommandParams implements WorkDoneProgressParams { class ExecuteCommandRegistrationOptions extends ExecuteCommandOptions { } +/** + * Additional data about a workspace edit. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class WorkspaceEditMetadata { + /** + * Signal to the editor that this edit is a refactoring. + */ + Boolean isRefactoring + + new() { + } +} + /** * The workspace/applyEdit request is sent from the server to the client to modify resource on the client side. */ @@ -8330,6 +8355,14 @@ class ApplyWorkspaceEditParams { */ String label + /** + * Additional data about the edit. + *

+ * Since 3.18.0 + */ + @Draft + WorkspaceEditMetadata metadata + new() { } From 80558de174abfc26d4aa551ab4f765a05ac7fbc2 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Tue, 29 Jul 2025 14:09:25 +0300 Subject: [PATCH 14/17] Add beta support for debug message kind --- .../src/main/java/org/eclipse/lsp4j/MessageType.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/MessageType.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/MessageType.java index 1db3ac10..bf9967f1 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/MessageType.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/MessageType.java @@ -11,6 +11,8 @@ ******************************************************************************/ package org.eclipse.lsp4j; +import org.eclipse.lsp4j.jsonrpc.Draft; + public enum MessageType { /** @@ -31,7 +33,15 @@ public enum MessageType { /** * A log message. */ - Log(4); + Log(4), + + /** + * A debug message. + *

+ * Since 3.18.0 + */ + @Draft + Debug(5); private final int value; From 207aea4e13078e9201c85734e78b83d4a88f0db5 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Tue, 29 Jul 2025 14:18:08 +0300 Subject: [PATCH 15/17] Add beta support for command tooltip --- .../src/main/java/org/eclipse/lsp4j/Protocol.xtend | 8 ++++++++ 1 file changed, 8 insertions(+) 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 c23107a5..c0aecfac 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 @@ -3136,6 +3136,14 @@ class Command { @NonNull String title + /** + * An optional tooltip. + *

+ * Since 3.18.0 + */ + @Draft + String tooltip + /** * The identifier of the actual command handler. */ From 02535688f7ce962c146bc0038da3fd5434463484 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Tue, 29 Jul 2025 14:53:14 +0300 Subject: [PATCH 16/17] Add beta support for formatting multiple ranges at once --- .../java/org/eclipse/lsp4j/Protocol.xtend | 67 +++++++++++++++++++ .../lsp4j/services/TextDocumentService.java | 15 +++++ 2 files changed, 82 insertions(+) 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 c0aecfac..15a611c0 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 @@ -1041,9 +1041,18 @@ class FormattingCapabilities extends DynamicRegistrationCapabilities { /** * Capabilities specific to the `textDocument/rangeFormatting` + * and `textDocument/rangesFormatting` */ @JsonRpcData class RangeFormattingCapabilities extends DynamicRegistrationCapabilities { + /** + * Whether the client supports formatting multiple ranges at once. + *

+ * Since 3.18.0 + */ + @Draft + Boolean rangesSupport + new() { } @@ -2277,6 +2286,7 @@ class TextDocumentClientCapabilities { /** * Capabilities specific to the {@code textDocument/rangeFormatting} + * and {@code textDocument/rangesFormatting} */ RangeFormattingCapabilities rangeFormatting @@ -4494,11 +4504,61 @@ class DocumentRangeFormattingParams implements WorkDoneProgressParams { } } +/** + * The document ranges formatting request is sent from the client to the server to format + * multiple ranges at once in a document. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class DocumentRangesFormattingParams implements WorkDoneProgressParams { + /** + * An optional token that a server can use to report work done progress. + */ + Either workDoneToken + + /** + * The document to format. + */ + @NonNull + TextDocumentIdentifier textDocument + + /** + * The format options. + */ + @NonNull + FormattingOptions options + + /** + * The ranges to format. + */ + @NonNull + List ranges + + new() { + this.ranges = new ArrayList + } + + new(@NonNull TextDocumentIdentifier textDocument, @NonNull FormattingOptions options, @NonNull List ranges) { + this.textDocument = Preconditions.checkNotNull(textDocument, 'textDocument') + this.options = Preconditions.checkNotNull(options, 'options') + this.ranges = Preconditions.checkNotNull(ranges, 'ranges') + } +} + /** * Document range formatting options. */ @JsonRpcData class DocumentRangeFormattingOptions extends AbstractWorkDoneProgressOptions { + /** + * Whether the server supports formatting multiple ranges at once. + *

+ * Since 3.18.0 + */ + @Draft + Boolean rangesSupport } /** @@ -4506,6 +4566,13 @@ class DocumentRangeFormattingOptions extends AbstractWorkDoneProgressOptions { */ @JsonRpcData class DocumentRangeFormattingRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions { + /** + * Whether the server supports formatting multiple ranges at once. + *

+ * Since 3.18.0 + */ + @Draft + Boolean rangesSupport } /** 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 6086787e..2f876426 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 @@ -47,6 +47,7 @@ import org.eclipse.lsp4j.DocumentLinkParams; import org.eclipse.lsp4j.DocumentOnTypeFormattingParams; import org.eclipse.lsp4j.DocumentRangeFormattingParams; +import org.eclipse.lsp4j.DocumentRangesFormattingParams; import org.eclipse.lsp4j.DocumentSymbol; import org.eclipse.lsp4j.DocumentSymbolCapabilities; import org.eclipse.lsp4j.DocumentSymbolParams; @@ -322,6 +323,20 @@ default CompletableFuture> rangeFormatting(DocumentRang throw new UnsupportedOperationException(); } + /** + * The document ranges formatting request is sent from the client to the + * server to format multiple ranges at once in a document. + *

+ * Registration Options: {@link org.eclipse.lsp4j.DocumentRangeFormattingRegistrationOptions} + *

+ * Since 3.18.0 + */ + @Draft + @JsonRequest + default CompletableFuture> rangesFormatting(DocumentRangesFormattingParams params) { + throw new UnsupportedOperationException(); + } + /** * The document on type formatting request is sent from the client to the * server to format parts of the document during typing. From b569a412d81ad620f1e83a04d598fc1280f95c85 Mon Sep 17 00:00:00 2001 From: Vladimir Piskarev Date: Tue, 29 Jul 2025 17:32:02 +0300 Subject: [PATCH 17/17] Add beta support for dynamic text document content --- .../java/org/eclipse/lsp4j/Protocol.xtend | 127 ++++++++++++++++++ .../lsp4j/services/LanguageClient.java | 13 ++ .../lsp4j/services/WorkspaceService.java | 17 +++ 3 files changed, 157 insertions(+) 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 15a611c0..59c9dc28 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 @@ -416,6 +416,14 @@ class WorkspaceClientCapabilities { @Draft FoldingRangeWorkspaceCapabilities foldingRange + /** + * Client capabilities for a text document content provider. + *

+ * Since 3.18.0 + */ + @Draft + TextDocumentContentCapabilities textDocumentContent + new() { } } @@ -6565,6 +6573,14 @@ class WorkspaceServerCapabilities { */ FileOperationsServerCapabilities fileOperations + /** + * Text document content provider options. + *

+ * Since 3.18.0 + */ + @Draft + TextDocumentContentRegistrationOptions textDocumentContent + new() { } @@ -12012,3 +12028,114 @@ class SnippetTextEdit { this.annotationId = annotationId } } + +/** + * Client capabilities for a text document content provider. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class TextDocumentContentCapabilities extends DynamicRegistrationCapabilities { + new() { + } + + new(Boolean dynamicRegistration) { + super(dynamicRegistration) + } +} + +/** + * Text document content provider registration options. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class TextDocumentContentRegistrationOptions { + /** + * The id used to register the request. The id can be used to deregister + * the request again. See also {@link Registration#id}. + */ + String id + + @NonNull + List schemes + + new() { + this.schemes = new ArrayList + } + + new(@NonNull List schemes) { + this.schemes = Preconditions.checkNotNull(schemes, 'schemes') + } +} + +/** + * Parameters for the {@code workspace/textDocumentContent} request. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class TextDocumentContentParams { + /** + * The uri of the text document. + */ + @NonNull + String uri + + new() { + } + + new(@NonNull String uri) { + this.uri = Preconditions.checkNotNull(uri, 'uri') + } +} + +/** + * Result of the {@code workspace/textDocumentContent} request. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class TextDocumentContentResult { + /** + * The text content of the text document. Please note, that the content of + * any subsequent open notifications for the text document might differ + * from the returned content due to whitespace and line ending + * normalizations done on the client. + */ + @NonNull + String text + + new() { + } + + new(@NonNull String text) { + this.text = Preconditions.checkNotNull(text, 'text') + } +} + +/** + * Parameters for the {@code workspace/textDocumentContent/refresh} request. + *

+ * Since 3.18.0 + */ +@Draft +@JsonRpcData +class TextDocumentContentRefreshParams { + /** + * The uri of the text document to refresh. + */ + @NonNull + String uri + + new() { + } + + new(@NonNull String uri) { + this.uri = Preconditions.checkNotNull(uri, 'uri') + } +} diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java index 3eb2e462..de0e97e2 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java @@ -26,6 +26,7 @@ import org.eclipse.lsp4j.ShowDocumentParams; import org.eclipse.lsp4j.ShowDocumentResult; import org.eclipse.lsp4j.ShowMessageRequestParams; +import org.eclipse.lsp4j.TextDocumentContentRefreshParams; import org.eclipse.lsp4j.UnregistrationParams; import org.eclipse.lsp4j.WorkDoneProgressCreateParams; import org.eclipse.lsp4j.WorkspaceFolder; @@ -267,4 +268,16 @@ default CompletableFuture refreshDiagnostics() { default CompletableFuture refreshFoldingRanges() { throw new UnsupportedOperationException(); } + + /** + * The {@code workspace/textDocumentContent/refresh} request is sent from the server to the client + * to refresh the content of a specific text document. + *

+ * Since 3.18.0 + */ + @Draft + @JsonRequest("workspace/textDocumentContent/refresh") + default CompletableFuture refreshTextDocumentContent(TextDocumentContentRefreshParams params) { + throw new UnsupportedOperationException(); + } } diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/WorkspaceService.java b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/WorkspaceService.java index 34dba7e1..fb92a645 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/WorkspaceService.java +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/WorkspaceService.java @@ -22,12 +22,15 @@ import org.eclipse.lsp4j.ExecuteCommandParams; import org.eclipse.lsp4j.RenameFilesParams; import org.eclipse.lsp4j.SymbolInformation; +import org.eclipse.lsp4j.TextDocumentContentParams; +import org.eclipse.lsp4j.TextDocumentContentResult; import org.eclipse.lsp4j.WorkspaceDiagnosticParams; import org.eclipse.lsp4j.WorkspaceDiagnosticReport; import org.eclipse.lsp4j.WorkspaceEdit; import org.eclipse.lsp4j.WorkspaceSymbol; import org.eclipse.lsp4j.WorkspaceSymbolParams; import org.eclipse.lsp4j.adapters.WorkspaceSymbolResponseAdapter; +import org.eclipse.lsp4j.jsonrpc.Draft; import org.eclipse.lsp4j.jsonrpc.json.ResponseJsonAdapter; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.lsp4j.jsonrpc.services.JsonNotification; @@ -193,4 +196,18 @@ default void didDeleteFiles(DeleteFilesParams params) { default CompletableFuture diagnostic(WorkspaceDiagnosticParams params) { throw new UnsupportedOperationException(); } + + /** + * The {@code workspace/textDocumentContent} request is sent from the client to the server to dynamically fetch + * the content of a text document. Clients should treat the content returned from this request as read-only. + *

+ * Registration Options: {@link org.eclipse.lsp4j.TextDocumentContentRegistrationOptions} + *

+ * Since 3.18.0 + */ + @Draft + @JsonRequest + default CompletableFuture textDocumentContent(TextDocumentContentParams params) { + throw new UnsupportedOperationException(); + } }