forked from denoland/vscode_deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsp_extensions.ts
More file actions
266 lines (210 loc) · 6.71 KB
/
lsp_extensions.ts
File metadata and controls
266 lines (210 loc) · 6.71 KB
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
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
/** Contains extensions to the Language Server Protocol that are supported by
* the Deno Language Server.
*
* The requests and notifications types should mirror the Deno's CLI
* `cli/lsp/language_server.rs` under the method `request_else`.
*/
import {
NotificationType,
RequestType,
RequestType0,
} from "vscode-languageclient";
import type {
Location,
MarkupContent,
Range,
TextDocumentIdentifier,
} from "vscode-languageclient";
export interface RegistryStateParams {
origin: string;
suggestions: boolean;
}
export const registryState = new NotificationType<RegistryStateParams>(
"deno/registryState",
);
export interface TaskRequestResponse {
name: string;
// TODO(nayeemrmn): `detail` is renamed to `command` for Deno > 2.1.1. Remove
// `detail` eventually.
command: string | null;
detail: string;
sourceUri: string;
description: string | null;
}
/** Requests any tasks from the language server that the language server is
* aware of, which are defined in a Deno configuration file. */
export const task = new RequestType0<
TaskRequestResponse[] | undefined,
void
>(
"deno/taskDefinitions",
);
export interface TestData {
/** The unique ID for this test/step. */
id: string;
/** The display label for the test/step. */
label: string;
/** Any test steps that are associated with this test/step */
steps?: TestData[];
/** The range of the owning text document that applies to the test. */
range?: Range;
}
export interface TestModuleParams {
/** The text document identifier that the tests are related to. */
textDocument: TextDocumentIdentifier;
/** A indication if tests described are _newly_ discovered and should be
* _inserted_ or if the tests associated are a replacement for any existing
* tests. */
kind: "insert" | "replace";
/** The text label for the test module. */
label: string;
/** An array of tests that are owned by this test module. */
tests: TestData[];
}
/** Notification of a discovery of a test module. The notification parameters
* include */
export const testModule = new NotificationType<TestModuleParams>(
"deno/testModule",
);
export interface TestModuleDeleteParams {
/** The text document identifier that has been removed. */
textDocument: TextDocumentIdentifier;
}
export const testModuleDelete = new NotificationType<TestModuleDeleteParams>(
"deno/testModuleDelete",
);
export interface TestRunRequestParams {
/** The id of the test run to be used for future messages. */
id: number;
/** The run kind. Currently Deno only supports `"run"` */
kind: "run" | "coverage" | "debug";
/** Whether the run should watch the files and continously re-run. */
isContinuous: boolean;
/** Test modules or tests to exclude from the test run. */
exclude?: TestIdentifier[];
/** Test modules or tests to include in the test run. */
include?: TestIdentifier[];
}
interface EnqueuedTestModule {
/** The test module the enqueued test IDs relate to */
textDocument: TextDocumentIdentifier;
/** The test IDs which are now enqueued for testing */
ids: string[];
}
export interface TestRunResponseParams {
/** Test modules and test IDs that are now enqueued for testing. */
enqueued: EnqueuedTestModule[];
}
export const testRun = new RequestType<
TestRunRequestParams,
TestRunResponseParams,
void
>("deno/testRun");
export interface TestIdentifier {
/** The test module the message is related to. */
textDocument: TextDocumentIdentifier;
/** The optional ID of the test. If not present, then the message applies to
* all tests in the test module. */
id?: string;
/** The optional ID of the step. If not present, then the message only applies
* to the test. */
stepId?: string;
}
export interface TestMessage {
/** The content of the message. */
message: MarkupContent;
/** An optional string which represents the expected output. */
expectedOutput?: string;
/** An optional string which represents the actual output. */
actualOutput?: string;
/** An optional location related to the message. */
location?: Location;
}
interface TestEnqueuedStartedSkipped {
/** The state change that has occurred to a specific test or test step.
*
* - `"enqueued"` - the test is now enqueued to be tested
* - `"started"` - the test has started
* - `"skipped"` - the test was skipped
*/
type: "enqueued" | "started" | "skipped";
/** The test or test step relating to the state change. */
test: TestIdentifier;
}
interface TestFailedErrored {
/** The state change that has occurred to a specific test or test step.
*
* - `"failed"` - The test failed to run properly, versus the test erroring.
* currently the Deno language server does not support this.
* - `"errored"` - The test errored.
*/
type: "failed" | "errored";
/** The test or test step relating to the state change. */
test: TestIdentifier;
/** Messages related to the state change. */
messages: TestMessage[];
/** An optional duration, in milliseconds from the start to the current
* state. */
duration?: number;
}
interface TestPassed {
/** The state change that has occurred to a specific test or test step. */
type: "passed";
/** The test or test step relating to the state change. */
test: TestIdentifier;
/** An optional duration, in milliseconds from the start to the current
* state. */
duration?: number;
}
interface TestOutput {
/** The test or test step has output information / logged information. */
type: "output";
/** The value of the output. */
value: string;
/** The associated test or test step if there was one. */
test?: TestIdentifier;
/** An optional location associated with the output. */
location?: Location;
}
interface TestRunRestart {
type: "restart";
enqueued: EnqueuedTestModule[];
}
interface TestEnd {
/** The test run has ended. */
type: "end";
}
type TestRunProgressMessage =
| TestEnqueuedStartedSkipped
| TestFailedErrored
| TestPassed
| TestOutput
| TestRunRestart
| TestEnd;
export interface TestRunProgressParams {
/** The test run ID that the progress message applies to. */
id: number;
/** The message*/
message: TestRunProgressMessage;
}
export const testRunProgress = new NotificationType<TestRunProgressParams>(
"deno/testRunProgress",
);
export interface TestRunCancelParams {
/** The test id to be cancelled. */
id: number;
}
export const testRunCancel = new RequestType<
TestRunCancelParams,
boolean,
void
>("deno/testRunCancel");
export interface VirtualTextDocumentParams {
textDocument: TextDocumentIdentifier;
}
export const virtualTextDocument = new RequestType<
VirtualTextDocumentParams,
string,
void
>("deno/virtualTextDocument");