Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SnippetTextEdit #847

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
69 changes: 69 additions & 0 deletions org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ class WorkspaceEditCapabilities {
*/
WorkspaceEditChangeAnnotationSupportCapabilities changeAnnotationSupport

/**
* Whether the client supports snippets as text edits.
*
* Since 3.18.0
*/
Boolean snippetEditSupport

new() {
}

Expand Down Expand Up @@ -7122,6 +7129,65 @@ class AnnotatedTextEdit extends TextEdit {
}
}

/**
* 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
*/
@JsonRpcData
class StringValue {
/**
* The kind of string value.
*/
static val kind = 'snippet'

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

new() {
}

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

/**
* An interactive text edit.
* <p>
* Since 3.18.0
*/
@JsonRpcData
class SnippetTextEdit extends TextEdit {
/**
* 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) {
super(range, '')
this.snippet = Preconditions.checkNotNull(snippet, 'snippet')
}
}

/**
* A special text edit to provide an insert and a replace operation.
* <p>
Expand Down Expand Up @@ -7201,6 +7267,9 @@ class TextDocumentEdit {

/**
* The edits to be applied
*
* Since 3.18.0 - support for SnippetTextEdit. This is guarded by the
* client capability {@link WorkspaceEditCapabilities#snippetEditSupport}
*/
@NonNull
List<TextEdit> edits
Expand Down