UNPKG

7.99 kBTypeScriptView Raw
1import { TextDocumentIdentifier, Range, uinteger, SemanticTokensEdit, SemanticTokensLegend, SemanticTokens, SemanticTokensDelta } from 'vscode-languageserver-types';
2import { RequestHandler0, RequestHandler } from 'vscode-jsonrpc';
3import { MessageDirection, ProtocolRequestType, ProtocolRequestType0, RegistrationType } from './messages';
4import type { PartialResultParams, WorkDoneProgressParams, WorkDoneProgressOptions, TextDocumentRegistrationOptions, StaticRegistrationOptions } from './protocol';
5/**
6 * @since 3.16.0
7 */
8export interface SemanticTokensPartialResult {
9 data: uinteger[];
10}
11/**
12 * @since 3.16.0
13 */
14export interface SemanticTokensDeltaPartialResult {
15 edits: SemanticTokensEdit[];
16}
17export declare namespace TokenFormat {
18 const Relative: 'relative';
19}
20export type TokenFormat = 'relative';
21/**
22 * @since 3.16.0
23 */
24export interface SemanticTokensClientCapabilities {
25 /**
26 * Whether implementation supports dynamic registration. If this is set to `true`
27 * the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
28 * return value for the corresponding server capability as well.
29 */
30 dynamicRegistration?: boolean;
31 /**
32 * Which requests the client supports and might send to the server
33 * depending on the server's capability. Please note that clients might not
34 * show semantic tokens or degrade some of the user experience if a range
35 * or full request is advertised by the client but not provided by the
36 * server. If for example the client capability `requests.full` and
37 * `request.range` are both set to true but the server only provides a
38 * range provider the client might not render a minimap correctly or might
39 * even decide to not show any semantic tokens at all.
40 */
41 requests: {
42 /**
43 * The client will send the `textDocument/semanticTokens/range` request if
44 * the server provides a corresponding handler.
45 */
46 range?: boolean | {};
47 /**
48 * The client will send the `textDocument/semanticTokens/full` request if
49 * the server provides a corresponding handler.
50 */
51 full?: boolean | {
52 /**
53 * The client will send the `textDocument/semanticTokens/full/delta` request if
54 * the server provides a corresponding handler.
55 */
56 delta?: boolean;
57 };
58 };
59 /**
60 * The token types that the client supports.
61 */
62 tokenTypes: string[];
63 /**
64 * The token modifiers that the client supports.
65 */
66 tokenModifiers: string[];
67 /**
68 * The token formats the clients supports.
69 */
70 formats: TokenFormat[];
71 /**
72 * Whether the client supports tokens that can overlap each other.
73 */
74 overlappingTokenSupport?: boolean;
75 /**
76 * Whether the client supports tokens that can span multiple lines.
77 */
78 multilineTokenSupport?: boolean;
79 /**
80 * Whether the client allows the server to actively cancel a
81 * semantic token request, e.g. supports returning
82 * LSPErrorCodes.ServerCancelled. If a server does the client
83 * needs to retrigger the request.
84 *
85 * @since 3.17.0
86 */
87 serverCancelSupport?: boolean;
88 /**
89 * Whether the client uses semantic tokens to augment existing
90 * syntax tokens. If set to `true` client side created syntax
91 * tokens and semantic tokens are both used for colorization. If
92 * set to `false` the client only uses the returned semantic tokens
93 * for colorization.
94 *
95 * If the value is `undefined` then the client behavior is not
96 * specified.
97 *
98 * @since 3.17.0
99 */
100 augmentsSyntaxTokens?: boolean;
101}
102/**
103 * @since 3.16.0
104 */
105export interface SemanticTokensOptions extends WorkDoneProgressOptions {
106 /**
107 * The legend used by the server
108 */
109 legend: SemanticTokensLegend;
110 /**
111 * Server supports providing semantic tokens for a specific range
112 * of a document.
113 */
114 range?: boolean | {};
115 /**
116 * Server supports providing semantic tokens for a full document.
117 */
118 full?: boolean | {
119 /**
120 * The server supports deltas for full documents.
121 */
122 delta?: boolean;
123 };
124}
125/**
126 * @since 3.16.0
127 */
128export interface SemanticTokensRegistrationOptions extends TextDocumentRegistrationOptions, SemanticTokensOptions, StaticRegistrationOptions {
129}
130export declare namespace SemanticTokensRegistrationType {
131 const method: 'textDocument/semanticTokens';
132 const type: RegistrationType<SemanticTokensRegistrationOptions>;
133}
134/**
135 * @since 3.16.0
136 */
137export interface SemanticTokensParams extends WorkDoneProgressParams, PartialResultParams {
138 /**
139 * The text document.
140 */
141 textDocument: TextDocumentIdentifier;
142}
143/**
144 * @since 3.16.0
145 */
146export declare namespace SemanticTokensRequest {
147 const method: 'textDocument/semanticTokens/full';
148 const messageDirection: MessageDirection;
149 const type: ProtocolRequestType<SemanticTokensParams, SemanticTokens | null, SemanticTokensPartialResult, void, SemanticTokensRegistrationOptions>;
150 const registrationMethod: typeof SemanticTokensRegistrationType.method;
151 type HandlerSignature = RequestHandler<SemanticTokensDeltaParams, SemanticTokens | null, void>;
152}
153/**
154 * @since 3.16.0
155 */
156export interface SemanticTokensDeltaParams extends WorkDoneProgressParams, PartialResultParams {
157 /**
158 * The text document.
159 */
160 textDocument: TextDocumentIdentifier;
161 /**
162 * The result id of a previous response. The result Id can either point to a full response
163 * or a delta response depending on what was received last.
164 */
165 previousResultId: string;
166}
167/**
168 * @since 3.16.0
169 */
170export declare namespace SemanticTokensDeltaRequest {
171 const method: 'textDocument/semanticTokens/full/delta';
172 const messageDirection: MessageDirection;
173 const type: ProtocolRequestType<SemanticTokensDeltaParams, SemanticTokens | SemanticTokensDelta | null, SemanticTokensPartialResult | SemanticTokensDeltaPartialResult, void, SemanticTokensRegistrationOptions>;
174 const registrationMethod: typeof SemanticTokensRegistrationType.method;
175 type HandlerSignature = RequestHandler<SemanticTokensDeltaParams, SemanticTokens | SemanticTokensDelta | null, void>;
176}
177/**
178 * @since 3.16.0
179 */
180export interface SemanticTokensRangeParams extends WorkDoneProgressParams, PartialResultParams {
181 /**
182 * The text document.
183 */
184 textDocument: TextDocumentIdentifier;
185 /**
186 * The range the semantic tokens are requested for.
187 */
188 range: Range;
189}
190/**
191 * @since 3.16.0
192 */
193export declare namespace SemanticTokensRangeRequest {
194 const method: 'textDocument/semanticTokens/range';
195 const messageDirection: MessageDirection;
196 const type: ProtocolRequestType<SemanticTokensRangeParams, SemanticTokens | null, SemanticTokensPartialResult, void, void>;
197 const registrationMethod: typeof SemanticTokensRegistrationType.method;
198 type HandlerSignature = RequestHandler<SemanticTokensRangeParams, SemanticTokens | null, void>;
199}
200/**
201 * @since 3.16.0
202 */
203export interface SemanticTokensWorkspaceClientCapabilities {
204 /**
205 * Whether the client implementation supports a refresh request sent from
206 * the server to the client.
207 *
208 * Note that this event is global and will force the client to refresh all
209 * semantic tokens currently shown. It should be used with absolute care
210 * and is useful for situation where a server for example detects a project
211 * wide change that requires such a calculation.
212 */
213 refreshSupport?: boolean;
214}
215/**
216 * @since 3.16.0
217 */
218export declare namespace SemanticTokensRefreshRequest {
219 const method: `workspace/semanticTokens/refresh`;
220 const messageDirection: MessageDirection;
221 const type: ProtocolRequestType0<void, void, void, void>;
222 type HandlerSignature = RequestHandler0<void, void>;
223}