Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2025 Avaloq Group AG.
*
* 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.jsonrpc;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* An API using this annotation is part of an upcomming Language Server Protocol Specification and
* in a draft state. Therefore it is subject to incompatible changes (including even removal)
* in a future release.
*
*/
@Retention(RetentionPolicy.CLASS)
@Target({
ElementType.CONSTRUCTOR,
ElementType.FIELD,
ElementType.METHOD,
ElementType.TYPE
})
@Documented
public @interface Draft {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/******************************************************************************
* Copyright (c) 2025 Avaloq Group AG.
*
* 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;

/**
* Describes how an inline completion request was triggered.
* <p>
* @since 3.18.0
*/
@Draft
public enum InlineCompletionTriggerKind {
/**
* Completion was triggered explicitly by a user gesture. Return multiple
* completion items to enable cycling through them.
*/
Invoked(1),

/**
* Completion was triggered automatically while editing. It is sufficient to
* return a single completion item in this case.
*/
Automatic(2);

private final int value;

InlineCompletionTriggerKind(final int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static InlineCompletionTriggerKind forValue(final int value) {
InlineCompletionTriggerKind[] allValues = InlineCompletionTriggerKind.values();
if (value < 1 || value > allValues.length) {
throw new IllegalArgumentException("Illegal enum value: " + value);
}
return allValues[value - 1];
}
}
279 changes: 278 additions & 1 deletion org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.eclipse.lsp4j.adapters.VersionedTextDocumentIdentifierTypeAdapter
import org.eclipse.lsp4j.adapters.WorkspaceDocumentDiagnosticReportListAdapter
import org.eclipse.lsp4j.adapters.WorkspaceSymbolLocationTypeAdapter
import org.eclipse.lsp4j.generator.JsonRpcData
import org.eclipse.lsp4j.jsonrpc.Draft
import org.eclipse.lsp4j.jsonrpc.json.adapters.JsonElementTypeAdapter
import org.eclipse.lsp4j.jsonrpc.messages.Either
import org.eclipse.lsp4j.jsonrpc.messages.Either3
Expand Down Expand Up @@ -2241,6 +2242,14 @@ class TextDocumentClientCapabilities {
*/
DiagnosticCapabilities diagnostic

/**
* Capabilities specific to the `textDocument/inlineCompletion` request.
* <p>
* @since 3.18.0
*/
@Draft
InlineCompletionClientCapabilities inlineCompletion

new() {
}
}
Expand Down Expand Up @@ -3330,7 +3339,7 @@ class Diagnostic {
* <p>
* Since 3.15.0
*/
List<DiagnosticTag> tags
List<DiagnosticTag> tags

/**
* An array of related diagnostic information, e.g. when symbol-names within a scope collide
Expand Down Expand Up @@ -6061,6 +6070,14 @@ class ServerCapabilities {
*/
Either<Boolean, InlineValueRegistrationOptions> inlineValueProvider

/**
* The server provides inline completions.
* <p>
* @since 3.18.0
*/
@Draft
Either<Boolean, InlineCompletionRegistrationOptions> inlineCompletionProvider

/**
* The server has support for pull model diagnostics.
* <p>
Expand Down Expand Up @@ -11161,3 +11178,263 @@ class NotebookDocumentIdentifier {
this.uri = Preconditions.checkNotNull(uri, 'uri')
}
}

/**
* Describes kind of {@link StringValue}.
* <p>
* Since 3.18.0
*/
@Draft
final class StringValueKind {
/**
* Indicates a snippet {@link StringValue}.
*/
public static val SNIPPET = 'snippet'

private new() {
}
}

/**
* A string value used as a snippet is a template which allows to insert text
* and to control the editor cursor when insertion happens.
* <p>
* A snippet can define tab stops and placeholders with `$1`, `$2`
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
* the end of the snippet. Variables are defined with `$name` and
* `${name:default value}`.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class StringValue {
/**
* The kind of the string value.
* <p>
* See {@link StringValueKind} for allowed values.
*/
@NonNull
String kind

/**
* The string value.
*/
@NonNull
String value

new() {
}

new(@NonNull String kind, @NonNull String value) {
this.kind = Preconditions.checkNotNull(kind, 'kind')
this.value = Preconditions.checkNotNull(value, 'value')
}
}

/**
* Client capabilities specific to inline completions.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class InlineCompletionClientCapabilities extends DynamicRegistrationCapabilities {
new() {
}

new(Boolean dynamicRegistration) {
super(dynamicRegistration)
}
}

/**
* Inline completion options used during static or dynamic registration.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class InlineCompletionRegistrationOptions extends AbstractTextDocumentRegistrationAndWorkDoneProgressOptions {
/**
* The id used to register the request. The id can be used to deregister
* the request again. See also {@link Registration#id}.
*/
String id

new() {
}

new(String id) {
this.id = id
}
}

/**
* A parameter literal used in inline completion requests.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class InlineCompletionParams extends TextDocumentPositionAndWorkDoneProgressParams {
/**
* Additional information about the context in which inline completions
* were requested.
*/
@NonNull
InlineCompletionContext context

new() {
}

new(@NonNull TextDocumentIdentifier textDocument, @NonNull Position position, @NonNull InlineCompletionContext context) {
super(textDocument, position)
this.context = Preconditions.checkNotNull(context, 'context')
}
}

/**
* Provides information about the context in which an inline completion was
* requested.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class InlineCompletionContext {
/**
* Describes how the inline completion was triggered.
*/
@NonNull
InlineCompletionTriggerKind triggerKind

/**
* Provides information about the currently selected item in the
* autocomplete widget if it is visible.
*<p>
* If set, provided inline completions must extend the text of the
* selected item and use the same range, otherwise they are not shown as
* preview.
* As an example, if the document text is `console.` and the selected item
* is `.log` replacing the `.` in the document, the inline completion must
* also replace `.` and start with `.log`, for example `.log()`.
*<p>
* Inline completion providers are requested again whenever the selected
* item changes.
*/
SelectedCompletionInfo selectedCompletionInfo

new() {
}

new(@NonNull InlineCompletionTriggerKind triggerKind) {
this.triggerKind = Preconditions.checkNotNull(triggerKind, 'triggerKind')
}

new(@NonNull InlineCompletionTriggerKind triggerKind, SelectedCompletionInfo selectedCompletionInfo) {
this.triggerKind = Preconditions.checkNotNull(triggerKind, 'triggerKind')
this.selectedCompletionInfo = selectedCompletionInfo
}
}

/**
* Describes the currently selected completion item.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class SelectedCompletionInfo {
/**
* The range that will be replaced if this completion item is accepted.
*/
@NonNull
Range range

/**
* The text the range will be replaced with if this completion is
* accepted.
*/
@NonNull
String text

new() {
}

new(@NonNull Range range, @NonNull String text) {
this.range = Preconditions.checkNotNull(range, 'range')
this.text = Preconditions.checkNotNull(text, 'text')
}
}

/**
* Represents a collection of {@link InlineCompletionItem} to be presented in the editor.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class InlineCompletionList {
/**
* The inline completion items.
*/
@NonNull
List<InlineCompletionItem> items

new() {
}

new(@NonNull List<InlineCompletionItem> items) {
this.items = Preconditions.checkNotNull(items, 'items')
}
}

/**
* An inline completion item represents a text snippet that is proposed inline
* to complete text that is being typed.
* <p>
* @since 3.18.0
*/
@Draft
@JsonRpcData
class InlineCompletionItem {
/**
* The text to replace the range with. Must be set.
* Is used both for the preview and the accept operation.
*/
@NonNull
Either<String, StringValue> insertText

/**
* A text that is used to decide if this inline completion should be
* shown. When `falsy`, the {@link InlineCompletionItem#insertText} is
* used.
* <p>
* An inline completion is shown if the text to replace is a prefix of the
* filter text.
*/
String filterText

/**
* The range to replace.
* Must begin and end on the same line.
* <p>
* Prefer replacements over insertions to provide a better experience when
* the user deletes typed text.
*/
Range range

/**
* An optional {@link Command} that is executed *after* inserting this
* completion.
*/
Command command

new() {
}

new(@NonNull Either<String, StringValue> insertText) {
this.insertText = Preconditions.checkNotNull(insertText, 'insertText')
}
}
Loading
Loading