UNPKG

10.6 kBTypeScriptView Raw
1import { RequestHandler0, RequestHandler, ProgressType } from 'vscode-jsonrpc';
2import { TextDocumentIdentifier, Diagnostic, DocumentUri, integer } from 'vscode-languageserver-types';
3import { MessageDirection, ProtocolRequestType0, ProtocolRequestType } from './messages';
4import type { PartialResultParams, StaticRegistrationOptions, WorkDoneProgressParams, TextDocumentRegistrationOptions, WorkDoneProgressOptions } from './protocol';
5/**
6 * Client capabilities specific to diagnostic pull requests.
7 *
8 * @since 3.17.0
9 */
10export type DiagnosticClientCapabilities = {
11 /**
12 * Whether implementation supports dynamic registration. If this is set to `true`
13 * the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
14 * return value for the corresponding server capability as well.
15 */
16 dynamicRegistration?: boolean;
17 /**
18 * Whether the clients supports related documents for document diagnostic pulls.
19 */
20 relatedDocumentSupport?: boolean;
21};
22/**
23 * Workspace client capabilities specific to diagnostic pull requests.
24 *
25 * @since 3.17.0
26 */
27export type DiagnosticWorkspaceClientCapabilities = {
28 /**
29 * Whether the client implementation supports a refresh request sent from
30 * the server to the client.
31 *
32 * Note that this event is global and will force the client to refresh all
33 * pulled diagnostics currently shown. It should be used with absolute care and
34 * is useful for situation where a server for example detects a project wide
35 * change that requires such a calculation.
36 */
37 refreshSupport?: boolean;
38};
39/**
40 * Diagnostic options.
41 *
42 * @since 3.17.0
43 */
44export type DiagnosticOptions = WorkDoneProgressOptions & {
45 /**
46 * An optional identifier under which the diagnostics are
47 * managed by the client.
48 */
49 identifier?: string;
50 /**
51 * Whether the language has inter file dependencies meaning that
52 * editing code in one file can result in a different diagnostic
53 * set in another file. Inter file dependencies are common for
54 * most programming languages and typically uncommon for linters.
55 */
56 interFileDependencies: boolean;
57 /**
58 * The server provides support for workspace diagnostics as well.
59 */
60 workspaceDiagnostics: boolean;
61};
62/**
63 * Diagnostic registration options.
64 *
65 * @since 3.17.0
66 */
67export type DiagnosticRegistrationOptions = TextDocumentRegistrationOptions & DiagnosticOptions & StaticRegistrationOptions;
68export type $DiagnosticServerCapabilities = {
69 diagnosticProvider?: DiagnosticOptions;
70};
71/**
72 * Cancellation data returned from a diagnostic request.
73 *
74 * @since 3.17.0
75 */
76export type DiagnosticServerCancellationData = {
77 retriggerRequest: boolean;
78};
79/**
80 * @since 3.17.0
81 */
82export declare namespace DiagnosticServerCancellationData {
83 function is(value: any): value is DiagnosticServerCancellationData;
84}
85/**
86 * Parameters of the document diagnostic request.
87 *
88 * @since 3.17.0
89 */
90export type DocumentDiagnosticParams = WorkDoneProgressParams & PartialResultParams & {
91 /**
92 * The text document.
93 */
94 textDocument: TextDocumentIdentifier;
95 /**
96 * The additional identifier provided during registration.
97 */
98 identifier?: string;
99 /**
100 * The result id of a previous response if provided.
101 */
102 previousResultId?: string;
103};
104/**
105 * The document diagnostic report kinds.
106 *
107 * @since 3.17.0
108 */
109export declare namespace DocumentDiagnosticReportKind {
110 /**
111 * A diagnostic report with a full
112 * set of problems.
113 */
114 const Full = "full";
115 /**
116 * A report indicating that the last
117 * returned report is still accurate.
118 */
119 const Unchanged = "unchanged";
120}
121export type DocumentDiagnosticReportKind = 'full' | 'unchanged';
122/**
123 * A diagnostic report with a full set of problems.
124 *
125 * @since 3.17.0
126 */
127export type FullDocumentDiagnosticReport = {
128 /**
129 * A full document diagnostic report.
130 */
131 kind: typeof DocumentDiagnosticReportKind.Full;
132 /**
133 * An optional result id. If provided it will
134 * be sent on the next diagnostic request for the
135 * same document.
136 */
137 resultId?: string;
138 /**
139 * The actual items.
140 */
141 items: Diagnostic[];
142};
143/**
144 * A full diagnostic report with a set of related documents.
145 *
146 * @since 3.17.0
147 */
148export type RelatedFullDocumentDiagnosticReport = FullDocumentDiagnosticReport & {
149 /**
150 * Diagnostics of related documents. This information is useful
151 * in programming languages where code in a file A can generate
152 * diagnostics in a file B which A depends on. An example of
153 * such a language is C/C++ where marco definitions in a file
154 * a.cpp and result in errors in a header file b.hpp.
155 *
156 * @since 3.17.0
157 */
158 relatedDocuments?: {
159 [uri: DocumentUri]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport;
160 };
161};
162/**
163 * A diagnostic report indicating that the last returned
164 * report is still accurate.
165 *
166 * @since 3.17.0
167 */
168export type UnchangedDocumentDiagnosticReport = {
169 /**
170 * A document diagnostic report indicating
171 * no changes to the last result. A server can
172 * only return `unchanged` if result ids are
173 * provided.
174 */
175 kind: typeof DocumentDiagnosticReportKind.Unchanged;
176 /**
177 * A result id which will be sent on the next
178 * diagnostic request for the same document.
179 */
180 resultId: string;
181};
182/**
183 * An unchanged diagnostic report with a set of related documents.
184 *
185 * @since 3.17.0
186 */
187export type RelatedUnchangedDocumentDiagnosticReport = UnchangedDocumentDiagnosticReport & {
188 /**
189 * Diagnostics of related documents. This information is useful
190 * in programming languages where code in a file A can generate
191 * diagnostics in a file B which A depends on. An example of
192 * such a language is C/C++ where marco definitions in a file
193 * a.cpp and result in errors in a header file b.hpp.
194 *
195 * @since 3.17.0
196 */
197 relatedDocuments?: {
198 [uri: DocumentUri]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport;
199 };
200};
201/**
202 * The result of a document diagnostic pull request. A report can
203 * either be a full report containing all diagnostics for the
204 * requested document or an unchanged report indicating that nothing
205 * has changed in terms of diagnostics in comparison to the last
206 * pull request.
207 *
208 * @since 3.17.0
209 */
210export type DocumentDiagnosticReport = RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport;
211/**
212 * A partial result for a document diagnostic report.
213 *
214 * @since 3.17.0
215 */
216export type DocumentDiagnosticReportPartialResult = {
217 relatedDocuments: {
218 [uri: DocumentUri]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport;
219 };
220};
221/**
222 * The document diagnostic request definition.
223 *
224 * @since 3.17.0
225 */
226export declare namespace DocumentDiagnosticRequest {
227 const method: 'textDocument/diagnostic';
228 const messageDirection: MessageDirection;
229 const type: ProtocolRequestType<DocumentDiagnosticParams, DocumentDiagnosticReport, DocumentDiagnosticReportPartialResult, DiagnosticServerCancellationData, DiagnosticRegistrationOptions>;
230 const partialResult: ProgressType<DocumentDiagnosticReportPartialResult>;
231 type HandlerSignature = RequestHandler<DocumentDiagnosticParams, DocumentDiagnosticReport, void>;
232}
233/**
234 * A previous result id in a workspace pull request.
235 *
236 * @since 3.17.0
237 */
238export type PreviousResultId = {
239 /**
240 * The URI for which the client knowns a
241 * result id.
242 */
243 uri: DocumentUri;
244 /**
245 * The value of the previous result id.
246 */
247 value: string;
248};
249/**
250 * Parameters of the workspace diagnostic request.
251 *
252 * @since 3.17.0
253 */
254export type WorkspaceDiagnosticParams = WorkDoneProgressParams & PartialResultParams & {
255 /**
256 * The additional identifier provided during registration.
257 */
258 identifier?: string;
259 /**
260 * The currently known diagnostic reports with their
261 * previous result ids.
262 */
263 previousResultIds: PreviousResultId[];
264};
265/**
266 * A full document diagnostic report for a workspace diagnostic result.
267 *
268 * @since 3.17.0
269 */
270export type WorkspaceFullDocumentDiagnosticReport = FullDocumentDiagnosticReport & {
271 /**
272 * The URI for which diagnostic information is reported.
273 */
274 uri: DocumentUri;
275 /**
276 * The version number for which the diagnostics are reported.
277 * If the document is not marked as open `null` can be provided.
278 */
279 version: integer | null;
280};
281/**
282 * An unchanged document diagnostic report for a workspace diagnostic result.
283 *
284 * @since 3.17.0
285 */
286export type WorkspaceUnchangedDocumentDiagnosticReport = UnchangedDocumentDiagnosticReport & {
287 /**
288 * The URI for which diagnostic information is reported.
289 */
290 uri: DocumentUri;
291 /**
292 * The version number for which the diagnostics are reported.
293 * If the document is not marked as open `null` can be provided.
294 */
295 version: integer | null;
296};
297/**
298 * A workspace diagnostic document report.
299 *
300 * @since 3.17.0
301 */
302export type WorkspaceDocumentDiagnosticReport = WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport;
303/**
304 * A workspace diagnostic report.
305 *
306 * @since 3.17.0
307 */
308export type WorkspaceDiagnosticReport = {
309 items: WorkspaceDocumentDiagnosticReport[];
310};
311/**
312 * A partial result for a workspace diagnostic report.
313 *
314 * @since 3.17.0
315 */
316export type WorkspaceDiagnosticReportPartialResult = {
317 items: WorkspaceDocumentDiagnosticReport[];
318};
319/**
320 * The workspace diagnostic request definition.
321 *
322 * @since 3.17.0
323 */
324export declare namespace WorkspaceDiagnosticRequest {
325 const method: 'workspace/diagnostic';
326 const messageDirection: MessageDirection;
327 const type: ProtocolRequestType<WorkspaceDiagnosticParams, WorkspaceDiagnosticReport, WorkspaceDiagnosticReportPartialResult, DiagnosticServerCancellationData, void>;
328 const partialResult: ProgressType<WorkspaceDiagnosticReportPartialResult>;
329 type HandlerSignature = RequestHandler<WorkspaceDiagnosticParams, WorkspaceDiagnosticReport | null, void>;
330}
331/**
332 * The diagnostic refresh request definition.
333 *
334 * @since 3.17.0
335 */
336export declare namespace DiagnosticRefreshRequest {
337 const method: `workspace/diagnostic/refresh`;
338 const messageDirection: MessageDirection;
339 const type: ProtocolRequestType0<void, void, void, void>;
340 type HandlerSignature = RequestHandler0<void, void>;
341}