-
Notifications
You must be signed in to change notification settings - Fork 328
/
Copy pathprotocol.sematicTokens.proposed.ts
285 lines (253 loc) · 7.4 KB
/
protocol.sematicTokens.proposed.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
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import { TextDocumentIdentifier, Range } from 'vscode-languageserver-types';
import { PartialResultParams, WorkDoneProgressParams, WorkDoneProgressOptions, TextDocumentRegistrationOptions, StaticRegistrationOptions } from './protocol';
import { ProtocolRequestType } from './messages';
/**
* A set of predefined token types. This set is not fixed
* an clients can specify additional token types via the
* corresponding client capabilities.
*
* @since 3.16.0 - Proposed state
*/
export enum SemanticTokenTypes {
comment = 'comment',
keyword = 'keyword',
string = 'string',
number = 'number',
regexp = 'regexp',
operator = 'operator',
namespace = 'namespace',
type = 'type',
struct = 'struct',
class = 'class',
interface = 'interface',
enum = 'enum',
typeParameter = 'typeParameter',
function = 'function',
member = 'member',
property = 'property',
macro = 'macro',
variable = 'variable',
parameter = 'parameter',
label = 'label'
}
/**
* A set of predefined token modifiers. This set is not fixed
* an clients can specify additional token types via the
* corresponding client capabilities.
*
* @since 3.16.0 - Proposed state
*/
export enum SemanticTokenModifiers {
documentation = 'documentation',
declaration = 'declaration',
definition = 'definition',
reference = 'reference',
static = 'static',
abstract = 'abstract',
deprecated = 'deprecated',
async = 'async',
volatile = 'volatile',
readonly = 'readonly'
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensLegend {
/**
* The token types a server uses.
*/
tokenTypes: string[];
/**
* The token modifiers a server uses.
*/
tokenModifiers: string[];
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokens {
/**
* An optional result id. If provided and clients support delta updating
* the client will include the result id in the next semantic token request.
* A server can then instead of computing all sematic tokens again simply
* send a delta.
*/
resultId?: string;
/**
* The actual tokens. For a detailed description about how the data is
* structured pls see
* https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L71
*/
data: number[];
}
/**
* @since 3.16.0 - Proposed state
*/
export namespace SemanticTokens {
export function is(value: any): value is SemanticTokens {
const candidate = value as SemanticTokens;
return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
}
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensPartialResult {
data: number[];
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensEdit {
start: number;
deleteCount: number;
data?: number[];
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensEdits {
readonly resultId?: string;
/**
* For a detailed description how these edits are structured pls see
* https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L131
*/
edits: SemanticTokensEdit[];
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensEditsPartialResult {
edits: SemanticTokensEdit[]
}
//------- 'textDocument/semanticTokens' -----
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensClientCapabilities {
/**
* The text document client capabilities
*/
textDocument?: {
/**
* Capabilities specific to the `textDocument/semanticTokens`
*
* @since 3.16.0 - Proposed state
*/
semanticTokens?: {
/**
* 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;
/**
* The token types know by the client.
*/
tokenTypes: string[];
/**
* The token modifiers know by the client.
*/
tokenModifiers: string[]
};
}
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensOptions extends WorkDoneProgressOptions {
/**
* The legend used by the server
*/
legend: SemanticTokensLegend;
/**
* Server supports providing semantic tokens for a sepcific range
* of a document.
*/
rangeProvider?: boolean;
/**
* Server supports providing semantic tokens for a full document.
*/
documentProvider?: boolean | {
/**
* The server supports deltas for full documents.
*/
edits?: boolean;
}
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensRegistrationOptions extends TextDocumentRegistrationOptions, SemanticTokensOptions, StaticRegistrationOptions {
}
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensServerCapabilities {
semanticTokensProvider: SemanticTokensOptions | SemanticTokensRegistrationOptions;
}
//------- 'textDocument/semanticTokens' -----
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensParams extends WorkDoneProgressParams, PartialResultParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
/**
* @since 3.16.0 - Proposed state
*/
export namespace SemanticTokensRequest {
export const method: 'textDocument/semanticTokens' = 'textDocument/semanticTokens';
export const type = new ProtocolRequestType<SemanticTokensParams, SemanticTokens | null, SemanticTokensPartialResult, void, SemanticTokensRegistrationOptions>(method);
}
//------- 'textDocument/semanticTokens/edits' -----
/**
* @since 3.16.0 - Proposed state
*/
export interface SemanticTokensEditsParams extends WorkDoneProgressParams, PartialResultParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The previous result id.
*/
previousResultId: string;
}
/**
* @since 3.16.0 - Proposed state
*/
export namespace SemanticTokensEditsRequest {
export const method: 'textDocument/semanticTokens/edits' = 'textDocument/semanticTokens/edits';
export const type = new ProtocolRequestType<SemanticTokensEditsParams, SemanticTokens | SemanticTokensEdits | null, SemanticTokensPartialResult | SemanticTokensEditsPartialResult, void, SemanticTokensRegistrationOptions>(method);
}
//------- 'textDocument/semanticTokens/range' -----
/**
* @since 3.16.0 - Proposed state
*/
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 - Proposed state
*/
export namespace SemanticTokensRangeRequest {
export const method: 'textDocument/semanticTokens/range' = 'textDocument/semanticTokens/range';
export const type = new ProtocolRequestType<SemanticTokensRangeParams, SemanticTokens | null, SemanticTokensPartialResult, void, void>(method);
}