Skip to content

Commit daeeb3a

Browse files
committed
Add beta support for dynamic text document content
1 parent 3dfc004 commit daeeb3a

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed

org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,14 @@ class WorkspaceClientCapabilities {
407407
@Draft
408408
FoldingRangeWorkspaceCapabilities foldingRange
409409

410+
/**
411+
* Client capabilities for a text document content provider.
412+
* <p>
413+
* Since 3.18.0
414+
*/
415+
@Draft
416+
TextDocumentContentCapabilities textDocumentContent
417+
410418
new() {
411419
}
412420
}
@@ -6503,6 +6511,14 @@ class WorkspaceServerCapabilities {
65036511
*/
65046512
FileOperationsServerCapabilities fileOperations
65056513

6514+
/**
6515+
* Text document content provider options.
6516+
* <p>
6517+
* Since 3.18.0
6518+
*/
6519+
@Draft
6520+
TextDocumentContentRegistrationOptions textDocumentContent
6521+
65066522
new() {
65076523
}
65086524

@@ -11935,3 +11951,114 @@ class SnippetTextEdit {
1193511951
this.annotationId = annotationId
1193611952
}
1193711953
}
11954+
11955+
/**
11956+
* Client capabilities for a text document content provider.
11957+
* <p>
11958+
* Since 3.18.0
11959+
*/
11960+
@Draft
11961+
@JsonRpcData
11962+
class TextDocumentContentCapabilities extends DynamicRegistrationCapabilities {
11963+
new() {
11964+
}
11965+
11966+
new(Boolean dynamicRegistration) {
11967+
super(dynamicRegistration)
11968+
}
11969+
}
11970+
11971+
/**
11972+
* Text document content provider registration options.
11973+
* <p>
11974+
* Since 3.18.0
11975+
*/
11976+
@Draft
11977+
@JsonRpcData
11978+
class TextDocumentContentRegistrationOptions {
11979+
/**
11980+
* The id used to register the request. The id can be used to deregister
11981+
* the request again. See also {@link Registration#id}.
11982+
*/
11983+
String id
11984+
11985+
@NonNull
11986+
List<String> schemes
11987+
11988+
new() {
11989+
this.schemes = new ArrayList
11990+
}
11991+
11992+
new(@NonNull List<String> schemes) {
11993+
this.schemes = Preconditions.checkNotNull(schemes, 'schemes')
11994+
}
11995+
}
11996+
11997+
/**
11998+
* Parameters for the {@code workspace/textDocumentContent} request.
11999+
* <p>
12000+
* Since 3.18.0
12001+
*/
12002+
@Draft
12003+
@JsonRpcData
12004+
class TextDocumentContentParams {
12005+
/**
12006+
* The uri of the text document.
12007+
*/
12008+
@NonNull
12009+
String uri
12010+
12011+
new() {
12012+
}
12013+
12014+
new(@NonNull String uri) {
12015+
this.uri = Preconditions.checkNotNull(uri, 'uri')
12016+
}
12017+
}
12018+
12019+
/**
12020+
* Result of the {@code workspace/textDocumentContent} request.
12021+
* <p>
12022+
* Since 3.18.0
12023+
*/
12024+
@Draft
12025+
@JsonRpcData
12026+
class TextDocumentContentResult {
12027+
/**
12028+
* The text content of the text document. Please note, that the content of
12029+
* any subsequent open notifications for the text document might differ
12030+
* from the returned content due to whitespace and line ending
12031+
* normalizations done on the client.
12032+
*/
12033+
@NonNull
12034+
String text
12035+
12036+
new() {
12037+
}
12038+
12039+
new(@NonNull String text) {
12040+
this.text = Preconditions.checkNotNull(text, 'text')
12041+
}
12042+
}
12043+
12044+
/**
12045+
* Parameters for the {@code workspace/textDocumentContent/refresh} request.
12046+
* <p>
12047+
* Since 3.18.0
12048+
*/
12049+
@Draft
12050+
@JsonRpcData
12051+
class TextDocumentContentRefreshParams {
12052+
/**
12053+
* The uri of the text document to refresh.
12054+
*/
12055+
@NonNull
12056+
String uri
12057+
12058+
new() {
12059+
}
12060+
12061+
new(@NonNull String uri) {
12062+
this.uri = Preconditions.checkNotNull(uri, 'uri')
12063+
}
12064+
}

org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/LanguageClient.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.lsp4j.ShowDocumentParams;
2727
import org.eclipse.lsp4j.ShowDocumentResult;
2828
import org.eclipse.lsp4j.ShowMessageRequestParams;
29+
import org.eclipse.lsp4j.TextDocumentContentRefreshParams;
2930
import org.eclipse.lsp4j.UnregistrationParams;
3031
import org.eclipse.lsp4j.WorkDoneProgressCreateParams;
3132
import org.eclipse.lsp4j.WorkspaceFolder;
@@ -267,4 +268,16 @@ default CompletableFuture<Void> refreshDiagnostics() {
267268
default CompletableFuture<Void> refreshFoldingRanges() {
268269
throw new UnsupportedOperationException();
269270
}
271+
272+
/**
273+
* The {@code workspace/textDocumentContent/refresh} request is sent from the server to the client
274+
* to refresh the content of a specific text document.
275+
* <p>
276+
* Since 3.18.0
277+
*/
278+
@Draft
279+
@JsonRequest("workspace/textDocumentContent/refresh")
280+
default CompletableFuture<Void> refreshTextDocumentContent(TextDocumentContentRefreshParams params) {
281+
throw new UnsupportedOperationException();
282+
}
270283
}

org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/WorkspaceService.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222
import org.eclipse.lsp4j.ExecuteCommandParams;
2323
import org.eclipse.lsp4j.RenameFilesParams;
2424
import org.eclipse.lsp4j.SymbolInformation;
25+
import org.eclipse.lsp4j.TextDocumentContentParams;
26+
import org.eclipse.lsp4j.TextDocumentContentResult;
2527
import org.eclipse.lsp4j.WorkspaceDiagnosticParams;
2628
import org.eclipse.lsp4j.WorkspaceDiagnosticReport;
2729
import org.eclipse.lsp4j.WorkspaceEdit;
2830
import org.eclipse.lsp4j.WorkspaceSymbol;
2931
import org.eclipse.lsp4j.WorkspaceSymbolParams;
3032
import org.eclipse.lsp4j.adapters.WorkspaceSymbolResponseAdapter;
33+
import org.eclipse.lsp4j.jsonrpc.Draft;
3134
import org.eclipse.lsp4j.jsonrpc.json.ResponseJsonAdapter;
3235
import org.eclipse.lsp4j.jsonrpc.messages.Either;
3336
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
@@ -193,4 +196,18 @@ default void didDeleteFiles(DeleteFilesParams params) {
193196
default CompletableFuture<WorkspaceDiagnosticReport> diagnostic(WorkspaceDiagnosticParams params) {
194197
throw new UnsupportedOperationException();
195198
}
199+
200+
/**
201+
* The {@code workspace/textDocumentContent} request is sent from the client to the server to dynamically fetch
202+
* the content of a text document. Clients should treat the content returned from this request as read-only.
203+
* <p>
204+
* Registration Options: {@link org.eclipse.lsp4j.TextDocumentContentRegistrationOptions}
205+
* <p>
206+
* Since 3.18.0
207+
*/
208+
@Draft
209+
@JsonRequest
210+
default CompletableFuture<TextDocumentContentResult> textDocumentContent(TextDocumentContentParams params) {
211+
throw new UnsupportedOperationException();
212+
}
196213
}

0 commit comments

Comments
 (0)