-
Notifications
You must be signed in to change notification settings - Fork 327
/
protocol.semanticTokens.ts
292 lines (250 loc) · 8.88 KB
/
protocol.semanticTokens.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { TextDocumentIdentifier, Range, uinteger, SemanticTokensEdit, SemanticTokensLegend, SemanticTokens, SemanticTokensDelta } from 'vscode-languageserver-types';
import { RequestHandler0, RequestHandler } from 'vscode-jsonrpc';
import { MessageDirection, ProtocolRequestType, ProtocolRequestType0, RegistrationType } from './messages';
import type {
PartialResultParams, WorkDoneProgressParams, WorkDoneProgressOptions, TextDocumentRegistrationOptions, StaticRegistrationOptions
} from './protocol';
/**
* @since 3.16.0
*/
export interface SemanticTokensPartialResult {
data: uinteger[];
}
/**
* @since 3.16.0
*/
export interface SemanticTokensDeltaPartialResult {
edits: SemanticTokensEdit[];
}
//------- 'textDocument/semanticTokens' -----
export namespace TokenFormat {
export const Relative: 'relative' = 'relative';
}
export type TokenFormat = 'relative';
/**
* @since 3.18.0
*/
export type ClientSemanticTokensRequestFullDelta = {
/**
* The client will send the `textDocument/semanticTokens/full/delta` request if
* the server provides a corresponding handler.
*/
delta?: boolean;
};
/**
* @since 3.18.0
*/
export type ClientSemanticTokensRequestOptions = {
/**
* The client will send the `textDocument/semanticTokens/range` request if
* the server provides a corresponding handler.
*/
range?: boolean | {
};
/**
* The client will send the `textDocument/semanticTokens/full` request if
* the server provides a corresponding handler.
*/
full?: boolean | ClientSemanticTokensRequestFullDelta;
};
/**
* @since 3.16.0
*/
export interface SemanticTokensClientCapabilities {
/**
* Whether implementation supports dynamic registration. If this is set to `true`
* the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
* return value for the corresponding server capability as well.
*/
dynamicRegistration?: boolean;
/**
* Which requests the client supports and might send to the server
* depending on the server's capability. Please note that clients might not
* show semantic tokens or degrade some of the user experience if a range
* or full request is advertised by the client but not provided by the
* server. If for example the client capability `requests.full` and
* `request.range` are both set to true but the server only provides a
* range provider the client might not render a minimap correctly or might
* even decide to not show any semantic tokens at all.
*/
requests: ClientSemanticTokensRequestOptions;
/**
* The token types that the client supports.
*/
tokenTypes: string[];
/**
* The token modifiers that the client supports.
*/
tokenModifiers: string[];
/**
* The token formats the clients supports.
*/
formats: TokenFormat[];
/**
* Whether the client supports tokens that can overlap each other.
*/
overlappingTokenSupport?: boolean;
/**
* Whether the client supports tokens that can span multiple lines.
*/
multilineTokenSupport?: boolean;
/**
* Whether the client allows the server to actively cancel a
* semantic token request, e.g. supports returning
* LSPErrorCodes.ServerCancelled. If a server does the client
* needs to retrigger the request.
*
* @since 3.17.0
*/
serverCancelSupport?: boolean;
/**
* Whether the client uses semantic tokens to augment existing
* syntax tokens. If set to `true` client side created syntax
* tokens and semantic tokens are both used for colorization. If
* set to `false` the client only uses the returned semantic tokens
* for colorization.
*
* If the value is `undefined` then the client behavior is not
* specified.
*
* @since 3.17.0
*/
augmentsSyntaxTokens?: boolean;
}
/**
* Semantic tokens options to support deltas for full documents
*
* @since 3.18.0
*/
export type SemanticTokensFullDelta = {
/**
* The server supports deltas for full documents.
*/
delta?: boolean;
};
/**
* @since 3.16.0
*/
export interface SemanticTokensOptions extends WorkDoneProgressOptions {
/**
* The legend used by the server
*/
legend: SemanticTokensLegend;
/**
* Server supports providing semantic tokens for a specific range
* of a document.
*/
range?: boolean | {
};
/**
* Server supports providing semantic tokens for a full document.
*/
full?: boolean | SemanticTokensFullDelta;
}
/**
* @since 3.16.0
*/
export interface SemanticTokensRegistrationOptions extends TextDocumentRegistrationOptions, SemanticTokensOptions, StaticRegistrationOptions {
}
export namespace SemanticTokensRegistrationType {
export const method: 'textDocument/semanticTokens' = 'textDocument/semanticTokens';
export const type = new RegistrationType<SemanticTokensRegistrationOptions>(method);
}
//------- 'textDocument/semanticTokens' -----
/**
* @since 3.16.0
*/
export interface SemanticTokensParams extends WorkDoneProgressParams, PartialResultParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
/**
* @since 3.16.0
*/
export namespace SemanticTokensRequest {
export const method: 'textDocument/semanticTokens/full' = 'textDocument/semanticTokens/full';
export const messageDirection: MessageDirection = MessageDirection.clientToServer;
export const type = new ProtocolRequestType<SemanticTokensParams, SemanticTokens | null, SemanticTokensPartialResult, void, SemanticTokensRegistrationOptions>(method);
export const registrationMethod: typeof SemanticTokensRegistrationType.method = SemanticTokensRegistrationType.method;
export type HandlerSignature = RequestHandler<SemanticTokensDeltaParams, SemanticTokens | null, void>;
}
//------- 'textDocument/semanticTokens/edits' -----
/**
* @since 3.16.0
*/
export interface SemanticTokensDeltaParams extends WorkDoneProgressParams, PartialResultParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The result id of a previous response. The result Id can either point to a full response
* or a delta response depending on what was received last.
*/
previousResultId: string;
}
/**
* @since 3.16.0
*/
export namespace SemanticTokensDeltaRequest {
export const method: 'textDocument/semanticTokens/full/delta' = 'textDocument/semanticTokens/full/delta';
export const messageDirection: MessageDirection = MessageDirection.clientToServer;
export const type = new ProtocolRequestType<SemanticTokensDeltaParams, SemanticTokens | SemanticTokensDelta | null, SemanticTokensPartialResult | SemanticTokensDeltaPartialResult, void, SemanticTokensRegistrationOptions>(method);
export const registrationMethod: typeof SemanticTokensRegistrationType.method = SemanticTokensRegistrationType.method;
export type HandlerSignature = RequestHandler<SemanticTokensDeltaParams, SemanticTokens | SemanticTokensDelta | null, void>;
}
//------- 'textDocument/semanticTokens/range' -----
/**
* @since 3.16.0
*/
export interface SemanticTokensRangeParams extends WorkDoneProgressParams, PartialResultParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The range the semantic tokens are requested for.
*/
range: Range;
}
/**
* @since 3.16.0
*/
export namespace SemanticTokensRangeRequest {
export const method: 'textDocument/semanticTokens/range' = 'textDocument/semanticTokens/range';
export const messageDirection: MessageDirection = MessageDirection.clientToServer;
export const type = new ProtocolRequestType<SemanticTokensRangeParams, SemanticTokens | null, SemanticTokensPartialResult, void, void>(method);
export const registrationMethod: typeof SemanticTokensRegistrationType.method = SemanticTokensRegistrationType.method;
export type HandlerSignature = RequestHandler<SemanticTokensRangeParams, SemanticTokens | null, void>;
}
//------- 'workspace/semanticTokens/refresh' -----
/**
* @since 3.16.0
*/
export interface SemanticTokensWorkspaceClientCapabilities {
/**
* 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
* semantic tokens currently shown. It should be used with absolute care
* and is useful for situation where a server for example detects a project
* wide change that requires such a calculation.
*/
refreshSupport?: boolean;
}
/**
* @since 3.16.0
*/
export namespace SemanticTokensRefreshRequest {
export const method: `workspace/semanticTokens/refresh` = `workspace/semanticTokens/refresh`;
export const messageDirection: MessageDirection = MessageDirection.serverToClient;
export const type = new ProtocolRequestType0<void, void, void, void>(method);
export type HandlerSignature = RequestHandler0<void, void>;
}