typescript-language-server 0.11.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +32 -6
- package/lib/calls.d.ts +3 -3
- package/lib/calls.d.ts.map +1 -1
- package/lib/calls.js +18 -46
- package/lib/calls.js.map +1 -1
- package/lib/cli.js +8 -32
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +1 -4
- package/lib/commands.js.map +1 -1
- package/lib/completion.d.ts +7 -6
- package/lib/completion.d.ts.map +1 -1
- package/lib/completion.js +95 -115
- package/lib/completion.js.map +1 -1
- package/lib/diagnostic-queue.d.ts +5 -5
- package/lib/diagnostic-queue.d.ts.map +1 -1
- package/lib/diagnostic-queue.js +7 -14
- package/lib/diagnostic-queue.js.map +1 -1
- package/lib/document-symbol.d.ts +2 -2
- package/lib/document-symbol.d.ts.map +1 -1
- package/lib/document-symbol.js +16 -22
- package/lib/document-symbol.js.map +1 -1
- package/lib/document.d.ts +1 -1
- package/lib/document.d.ts.map +1 -1
- package/lib/document.js +6 -34
- package/lib/document.js.map +1 -1
- package/lib/features/fix-all.d.ts +4 -4
- package/lib/features/fix-all.d.ts.map +1 -1
- package/lib/features/fix-all.js +17 -44
- package/lib/features/fix-all.js.map +1 -1
- package/lib/file-lsp-server.spec.js +17 -18
- package/lib/file-lsp-server.spec.js.map +1 -1
- package/lib/hover.d.ts +2 -2
- package/lib/hover.d.ts.map +1 -1
- package/lib/hover.js +8 -12
- package/lib/hover.js.map +1 -1
- package/lib/logger.d.ts +12 -4
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +36 -43
- package/lib/logger.js.map +1 -1
- package/lib/lsp-client.d.ts +3 -3
- package/lib/lsp-client.d.ts.map +1 -1
- package/lib/lsp-client.js +4 -31
- package/lib/lsp-client.js.map +1 -1
- package/lib/lsp-connection.d.ts +1 -1
- package/lib/lsp-connection.d.ts.map +1 -1
- package/lib/lsp-connection.js +10 -37
- package/lib/lsp-connection.js.map +1 -1
- package/lib/lsp-protocol.calls.proposed.d.ts +1 -1
- package/lib/lsp-protocol.calls.proposed.d.ts.map +1 -1
- package/lib/lsp-protocol.calls.proposed.js +7 -32
- package/lib/lsp-protocol.calls.proposed.js.map +1 -1
- package/lib/lsp-protocol.inlayHints.proposed.d.ts +2 -2
- package/lib/lsp-protocol.inlayHints.proposed.d.ts.map +1 -1
- package/lib/lsp-protocol.inlayHints.proposed.js +2 -28
- package/lib/lsp-protocol.inlayHints.proposed.js.map +1 -1
- package/lib/lsp-server.d.ts +13 -9
- package/lib/lsp-server.d.ts.map +1 -1
- package/lib/lsp-server.js +234 -192
- package/lib/lsp-server.js.map +1 -1
- package/lib/lsp-server.spec.js +338 -232
- package/lib/lsp-server.spec.js.map +1 -1
- package/lib/organize-imports.d.ts +3 -3
- package/lib/organize-imports.d.ts.map +1 -1
- package/lib/organize-imports.js +5 -32
- package/lib/organize-imports.js.map +1 -1
- package/lib/organize-imports.spec.js +9 -34
- package/lib/organize-imports.spec.js.map +1 -1
- package/lib/protocol-translation.d.ts +3 -3
- package/lib/protocol-translation.d.ts.map +1 -1
- package/lib/protocol-translation.js +30 -72
- package/lib/protocol-translation.js.map +1 -1
- package/lib/quickfix.d.ts +3 -3
- package/lib/quickfix.d.ts.map +1 -1
- package/lib/quickfix.js +7 -35
- package/lib/quickfix.js.map +1 -1
- package/lib/refactor.d.ts +2 -2
- package/lib/refactor.d.ts.map +1 -1
- package/lib/refactor.js +7 -36
- package/lib/refactor.js.map +1 -1
- package/lib/semantic-tokens.d.ts +1 -1
- package/lib/semantic-tokens.d.ts.map +1 -1
- package/lib/semantic-tokens.js +1 -5
- package/lib/semantic-tokens.js.map +1 -1
- package/lib/test-utils.d.ts +8 -3
- package/lib/test-utils.d.ts.map +1 -1
- package/lib/test-utils.js +51 -60
- package/lib/test-utils.js.map +1 -1
- package/lib/ts-protocol.d.ts +7 -4
- package/lib/ts-protocol.d.ts.map +1 -1
- package/lib/ts-protocol.js +4 -31
- package/lib/ts-protocol.js.map +1 -1
- package/lib/tsp-client.d.ts +42 -43
- package/lib/tsp-client.d.ts.map +1 -1
- package/lib/tsp-client.js +23 -46
- package/lib/tsp-client.js.map +1 -1
- package/lib/tsp-client.spec.js +36 -56
- package/lib/tsp-client.spec.js.map +1 -1
- package/lib/tsp-command-types.js +3 -7
- package/lib/tsp-command-types.js.map +1 -1
- package/lib/utils/SnippetString.js +1 -4
- package/lib/utils/SnippetString.js.map +1 -1
- package/lib/utils/api.d.ts +1 -0
- package/lib/utils/api.d.ts.map +1 -1
- package/lib/utils/api.js +3 -28
- package/lib/utils/api.js.map +1 -1
- package/lib/utils/configuration.d.ts +2 -2
- package/lib/utils/configuration.d.ts.map +1 -1
- package/lib/utils/configuration.js +1 -2
- package/lib/utils/errorCodes.js +11 -14
- package/lib/utils/errorCodes.js.map +1 -1
- package/lib/utils/fixNames.js +13 -16
- package/lib/utils/fixNames.js.map +1 -1
- package/lib/utils/modules-resolver.js +7 -34
- package/lib/utils/modules-resolver.js.map +1 -1
- package/lib/utils/modules-resolver.spec.d.ts +1 -1
- package/lib/utils/modules-resolver.spec.d.ts.map +1 -1
- package/lib/utils/modules-resolver.spec.js +11 -34
- package/lib/utils/modules-resolver.spec.js.map +1 -1
- package/lib/utils/typeConverters.d.ts +1 -1
- package/lib/utils/typeConverters.d.ts.map +1 -1
- package/lib/utils/typeConverters.js +2 -5
- package/lib/utils/typeConverters.js.map +1 -1
- package/lib/utils/types.js +2 -29
- package/lib/utils/types.js.map +1 -1
- package/lib/utils/versionProvider.d.ts +3 -3
- package/lib/utils/versionProvider.d.ts.map +1 -1
- package/lib/utils/versionProvider.js +35 -41
- package/lib/utils/versionProvider.js.map +1 -1
- package/lib/utils.js +1 -5
- package/lib/utils.js.map +1 -1
- package/package.json +35 -33
package/lib/lsp-server.spec.js
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (C) 2017, 2018 TypeFox and others.
|
|
4
3
|
*
|
|
5
4
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
6
5
|
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
6
|
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
7
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
8
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
9
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,18 +13,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
37
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
14
|
});
|
|
39
15
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
import * as chai from 'chai';
|
|
17
|
+
import fs from 'fs-extra';
|
|
18
|
+
import * as lsp from 'vscode-languageserver';
|
|
19
|
+
import * as lspcalls from './lsp-protocol.calls.proposed.js';
|
|
20
|
+
import { uri, createServer, position, lastPosition, filePath, getDefaultClientCapabilities, positionAfter, readContents, toPlatformEOL } from './test-utils.js';
|
|
21
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
22
|
+
import { Commands } from './commands.js';
|
|
23
|
+
import { CodeActionKind } from './utils/types.js';
|
|
47
24
|
const assert = chai.assert;
|
|
48
25
|
const diagnostics = new Map();
|
|
49
26
|
let server;
|
|
50
27
|
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
server = yield
|
|
28
|
+
server = yield createServer({
|
|
52
29
|
rootUri: null,
|
|
53
30
|
publishDiagnostics: args => diagnostics.set(args.uri, args)
|
|
54
31
|
});
|
|
@@ -64,14 +41,16 @@ beforeEach(() => {
|
|
|
64
41
|
server.closeAll();
|
|
65
42
|
// "closeAll" triggers final publishDiagnostics with an empty list so clear last.
|
|
66
43
|
diagnostics.clear();
|
|
44
|
+
server.workspaceEdits = [];
|
|
67
45
|
});
|
|
68
46
|
after(() => {
|
|
69
47
|
server.closeAll();
|
|
48
|
+
server.shutdown();
|
|
70
49
|
});
|
|
71
50
|
describe('completion', () => {
|
|
72
51
|
it('simple test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
52
|
const doc = {
|
|
74
|
-
uri:
|
|
53
|
+
uri: uri('bar.ts'),
|
|
75
54
|
languageId: 'typescript',
|
|
76
55
|
version: 1,
|
|
77
56
|
text: `
|
|
@@ -83,7 +62,7 @@ describe('completion', () => {
|
|
|
83
62
|
server.didOpenTextDocument({
|
|
84
63
|
textDocument: doc
|
|
85
64
|
});
|
|
86
|
-
const pos =
|
|
65
|
+
const pos = position(doc, 'console');
|
|
87
66
|
const proposals = yield server.completion({ textDocument: doc, position: pos });
|
|
88
67
|
assert.isNotNull(proposals);
|
|
89
68
|
assert.isAtLeast(proposals.items.length, 800);
|
|
@@ -93,10 +72,10 @@ describe('completion', () => {
|
|
|
93
72
|
assert.isNotTrue(resolvedItem.deprecated, 'resolved item is not deprecated');
|
|
94
73
|
assert.isDefined(resolvedItem.detail);
|
|
95
74
|
server.didCloseTextDocument({ textDocument: doc });
|
|
96
|
-
}))
|
|
75
|
+
}));
|
|
97
76
|
it('simple JS test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
77
|
const doc = {
|
|
99
|
-
uri:
|
|
78
|
+
uri: uri('bar.js'),
|
|
100
79
|
languageId: 'javascript',
|
|
101
80
|
version: 1,
|
|
102
81
|
text: `
|
|
@@ -108,7 +87,7 @@ describe('completion', () => {
|
|
|
108
87
|
server.didOpenTextDocument({
|
|
109
88
|
textDocument: doc
|
|
110
89
|
});
|
|
111
|
-
const pos =
|
|
90
|
+
const pos = position(doc, 'console');
|
|
112
91
|
const proposals = yield server.completion({ textDocument: doc, position: pos });
|
|
113
92
|
assert.isNotNull(proposals);
|
|
114
93
|
assert.isAtLeast(proposals.items.length, 800);
|
|
@@ -126,10 +105,10 @@ describe('completion', () => {
|
|
|
126
105
|
}, false);
|
|
127
106
|
assert.isFalse(containsInvalidCompletions);
|
|
128
107
|
server.didCloseTextDocument({ textDocument: doc });
|
|
129
|
-
}))
|
|
108
|
+
}));
|
|
130
109
|
it('deprecated by JSDoc', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
110
|
const doc = {
|
|
132
|
-
uri:
|
|
111
|
+
uri: uri('bar.ts'),
|
|
133
112
|
languageId: 'typescript',
|
|
134
113
|
version: 1,
|
|
135
114
|
text: `
|
|
@@ -147,7 +126,7 @@ describe('completion', () => {
|
|
|
147
126
|
server.didOpenTextDocument({
|
|
148
127
|
textDocument: doc
|
|
149
128
|
});
|
|
150
|
-
const pos =
|
|
129
|
+
const pos = position(doc, 'foo(); // call me');
|
|
151
130
|
const proposals = yield server.completion({ textDocument: doc, position: pos });
|
|
152
131
|
assert.isNotNull(proposals);
|
|
153
132
|
const item = proposals.items.find(i => i.label === 'foo');
|
|
@@ -157,10 +136,10 @@ describe('completion', () => {
|
|
|
157
136
|
assert.isArray(resolvedItem.tags);
|
|
158
137
|
assert.include(resolvedItem.tags, lsp.CompletionItemTag.Deprecated, 'resolved item is deprecated');
|
|
159
138
|
server.didCloseTextDocument({ textDocument: doc });
|
|
160
|
-
}))
|
|
139
|
+
}));
|
|
161
140
|
it('incorrect source location', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
141
|
const doc = {
|
|
163
|
-
uri:
|
|
142
|
+
uri: uri('bar.ts'),
|
|
164
143
|
languageId: 'typescript',
|
|
165
144
|
version: 1,
|
|
166
145
|
text: `
|
|
@@ -172,28 +151,28 @@ describe('completion', () => {
|
|
|
172
151
|
server.didOpenTextDocument({
|
|
173
152
|
textDocument: doc
|
|
174
153
|
});
|
|
175
|
-
const pos =
|
|
154
|
+
const pos = position(doc, 'foo');
|
|
176
155
|
const proposals = yield server.completion({ textDocument: doc, position: pos });
|
|
177
156
|
assert.isNull(proposals);
|
|
178
157
|
server.didCloseTextDocument({ textDocument: doc });
|
|
179
|
-
}))
|
|
158
|
+
}));
|
|
180
159
|
it('includes completions from global modules', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
160
|
const doc = {
|
|
182
|
-
uri:
|
|
161
|
+
uri: uri('bar.ts'),
|
|
183
162
|
languageId: 'typescript',
|
|
184
163
|
version: 1,
|
|
185
164
|
text: 'pathex'
|
|
186
165
|
};
|
|
187
166
|
server.didOpenTextDocument({ textDocument: doc });
|
|
188
|
-
const proposals = yield server.completion({ textDocument: doc, position:
|
|
167
|
+
const proposals = yield server.completion({ textDocument: doc, position: position(doc, 'ex') });
|
|
189
168
|
assert.isNotNull(proposals);
|
|
190
169
|
const pathExistsCompletion = proposals.items.find(completion => completion.label === 'pathExists');
|
|
191
170
|
assert.isDefined(pathExistsCompletion);
|
|
192
171
|
server.didCloseTextDocument({ textDocument: doc });
|
|
193
|
-
}))
|
|
172
|
+
}));
|
|
194
173
|
it('includes completions with invalid identifier names', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
195
174
|
const doc = {
|
|
196
|
-
uri:
|
|
175
|
+
uri: uri('bar.ts'),
|
|
197
176
|
languageId: 'typescript',
|
|
198
177
|
version: 1,
|
|
199
178
|
text: `
|
|
@@ -206,39 +185,39 @@ describe('completion', () => {
|
|
|
206
185
|
`
|
|
207
186
|
};
|
|
208
187
|
server.didOpenTextDocument({ textDocument: doc });
|
|
209
|
-
const proposals = yield server.completion({ textDocument: doc, position:
|
|
188
|
+
const proposals = yield server.completion({ textDocument: doc, position: positionAfter(doc, '.i') });
|
|
210
189
|
assert.isNotNull(proposals);
|
|
211
190
|
const completion = proposals.items.find(completion => completion.label === 'invalid-identifier-name');
|
|
212
191
|
assert.isDefined(completion);
|
|
213
192
|
assert.isDefined(completion.textEdit);
|
|
214
193
|
assert.equal(completion.textEdit.newText, '["invalid-identifier-name"]');
|
|
215
194
|
server.didCloseTextDocument({ textDocument: doc });
|
|
216
|
-
}))
|
|
195
|
+
}));
|
|
217
196
|
it('includes detail field with package name for auto-imports', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
218
197
|
const doc = {
|
|
219
|
-
uri:
|
|
198
|
+
uri: uri('bar.ts'),
|
|
220
199
|
languageId: 'typescript',
|
|
221
200
|
version: 1,
|
|
222
201
|
text: 'readFile'
|
|
223
202
|
};
|
|
224
203
|
server.didOpenTextDocument({ textDocument: doc });
|
|
225
|
-
const proposals = yield server.completion({ textDocument: doc, position:
|
|
204
|
+
const proposals = yield server.completion({ textDocument: doc, position: positionAfter(doc, 'readFile') });
|
|
226
205
|
assert.isNotNull(proposals);
|
|
227
206
|
const completion = proposals.items.find(completion => completion.label === 'readFile');
|
|
228
207
|
assert.isDefined(completion);
|
|
229
208
|
assert.strictEqual(completion.detail, 'fs');
|
|
230
209
|
assert.strictEqual(completion.insertTextFormat, /* snippet */ 2);
|
|
231
210
|
server.didCloseTextDocument({ textDocument: doc });
|
|
232
|
-
}))
|
|
211
|
+
}));
|
|
233
212
|
it('resolves text edit for auto-import completion', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
234
213
|
const doc = {
|
|
235
|
-
uri:
|
|
214
|
+
uri: uri('bar.ts'),
|
|
236
215
|
languageId: 'typescript',
|
|
237
216
|
version: 1,
|
|
238
217
|
text: 'readFile'
|
|
239
218
|
};
|
|
240
219
|
server.didOpenTextDocument({ textDocument: doc });
|
|
241
|
-
const proposals = yield server.completion({ textDocument: doc, position:
|
|
220
|
+
const proposals = yield server.completion({ textDocument: doc, position: positionAfter(doc, 'readFile') });
|
|
242
221
|
assert.isNotNull(proposals);
|
|
243
222
|
const completion = proposals.items.find(completion => completion.label === 'readFile');
|
|
244
223
|
assert.isDefined(completion);
|
|
@@ -259,7 +238,7 @@ describe('completion', () => {
|
|
|
259
238
|
}
|
|
260
239
|
]);
|
|
261
240
|
server.didCloseTextDocument({ textDocument: doc });
|
|
262
|
-
}))
|
|
241
|
+
}));
|
|
263
242
|
it('resolves text edit for auto-import completion in right format', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
243
|
server.didChangeConfiguration({
|
|
265
244
|
settings: {
|
|
@@ -272,13 +251,13 @@ describe('completion', () => {
|
|
|
272
251
|
}
|
|
273
252
|
});
|
|
274
253
|
const doc = {
|
|
275
|
-
uri:
|
|
254
|
+
uri: uri('bar.ts'),
|
|
276
255
|
languageId: 'typescript',
|
|
277
256
|
version: 1,
|
|
278
257
|
text: 'readFile'
|
|
279
258
|
};
|
|
280
259
|
server.didOpenTextDocument({ textDocument: doc });
|
|
281
|
-
const proposals = yield server.completion({ textDocument: doc, position:
|
|
260
|
+
const proposals = yield server.completion({ textDocument: doc, position: positionAfter(doc, 'readFile') });
|
|
282
261
|
assert.isNotNull(proposals);
|
|
283
262
|
const completion = proposals.items.find(completion => completion.label === 'readFile');
|
|
284
263
|
assert.isDefined(completion);
|
|
@@ -312,10 +291,10 @@ describe('completion', () => {
|
|
|
312
291
|
}
|
|
313
292
|
}
|
|
314
293
|
});
|
|
315
|
-
}))
|
|
294
|
+
}));
|
|
316
295
|
it('resolves a snippet for method completion', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
317
296
|
const doc = {
|
|
318
|
-
uri:
|
|
297
|
+
uri: uri('bar.ts'),
|
|
319
298
|
languageId: 'typescript',
|
|
320
299
|
version: 1,
|
|
321
300
|
text: `
|
|
@@ -324,7 +303,7 @@ describe('completion', () => {
|
|
|
324
303
|
`
|
|
325
304
|
};
|
|
326
305
|
server.didOpenTextDocument({ textDocument: doc });
|
|
327
|
-
const proposals = yield server.completion({ textDocument: doc, position:
|
|
306
|
+
const proposals = yield server.completion({ textDocument: doc, position: positionAfter(doc, 'readFile') });
|
|
328
307
|
assert.isNotNull(proposals);
|
|
329
308
|
const completion = proposals.items.find(completion => completion.label === 'readFile');
|
|
330
309
|
assert.strictEqual(completion.insertTextFormat, lsp.InsertTextFormat.Snippet);
|
|
@@ -334,12 +313,81 @@ describe('completion', () => {
|
|
|
334
313
|
// eslint-disable-next-line no-template-curly-in-string
|
|
335
314
|
assert.strictEqual(resolvedItem.insertText, 'readFile(${1:path}, ${2:options}, ${3:callback})$0');
|
|
336
315
|
server.didCloseTextDocument({ textDocument: doc });
|
|
337
|
-
}))
|
|
316
|
+
}));
|
|
317
|
+
it('includes textEdit for string completion', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
|
+
const doc = {
|
|
319
|
+
uri: uri('bar.ts'),
|
|
320
|
+
languageId: 'typescript',
|
|
321
|
+
version: 1,
|
|
322
|
+
text: `
|
|
323
|
+
function test(value: "fs/read" | "hello/world") {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
test("fs/")
|
|
328
|
+
`
|
|
329
|
+
};
|
|
330
|
+
server.didOpenTextDocument({ textDocument: doc });
|
|
331
|
+
const proposals = yield server.completion({
|
|
332
|
+
textDocument: doc,
|
|
333
|
+
position: positionAfter(doc, 'test("fs/'),
|
|
334
|
+
context: {
|
|
335
|
+
triggerCharacter: '/',
|
|
336
|
+
triggerKind: 2
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
assert.isNotNull(proposals);
|
|
340
|
+
const completion = proposals.items.find(completion => completion.label === 'fs/read');
|
|
341
|
+
assert.strictEqual(completion.label, 'fs/read');
|
|
342
|
+
assert.deepStrictEqual(completion.textEdit, {
|
|
343
|
+
range: {
|
|
344
|
+
start: { line: 5, character: 20 },
|
|
345
|
+
end: { line: 5, character: 23 }
|
|
346
|
+
},
|
|
347
|
+
newText: 'fs/read'
|
|
348
|
+
});
|
|
349
|
+
}));
|
|
350
|
+
it('includes labelDetails with useLabelDetailsInCompletionEntries enabled', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
351
|
+
const doc = {
|
|
352
|
+
uri: uri('foo.ts'),
|
|
353
|
+
languageId: 'typescript',
|
|
354
|
+
version: 1,
|
|
355
|
+
text: `
|
|
356
|
+
interface IFoo {
|
|
357
|
+
bar(x: number): void;
|
|
358
|
+
}
|
|
359
|
+
const obj: IFoo = {
|
|
360
|
+
/*a*/
|
|
361
|
+
}
|
|
362
|
+
`
|
|
363
|
+
};
|
|
364
|
+
server.didOpenTextDocument({ textDocument: doc });
|
|
365
|
+
const proposals = yield server.completion({
|
|
366
|
+
textDocument: doc,
|
|
367
|
+
position: positionAfter(doc, '/*a*/')
|
|
368
|
+
});
|
|
369
|
+
assert.isNotNull(proposals);
|
|
370
|
+
assert.lengthOf(proposals.items, 2);
|
|
371
|
+
assert.deepInclude(proposals.items[0], {
|
|
372
|
+
label: 'bar',
|
|
373
|
+
kind: 2,
|
|
374
|
+
insertTextFormat: 2
|
|
375
|
+
});
|
|
376
|
+
assert.deepInclude(proposals.items[1], {
|
|
377
|
+
label: 'bar',
|
|
378
|
+
labelDetails: {
|
|
379
|
+
detail: '(x)'
|
|
380
|
+
},
|
|
381
|
+
kind: 2,
|
|
382
|
+
insertTextFormat: 2,
|
|
383
|
+
insertText: toPlatformEOL('bar(x) {\n $0\n},')
|
|
384
|
+
});
|
|
385
|
+
}));
|
|
338
386
|
});
|
|
339
387
|
describe('diagnostics', () => {
|
|
340
388
|
it('simple test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
389
|
const doc = {
|
|
342
|
-
uri:
|
|
390
|
+
uri: uri('diagnosticsBar.ts'),
|
|
343
391
|
languageId: 'typescript',
|
|
344
392
|
version: 1,
|
|
345
393
|
text: `
|
|
@@ -358,10 +406,10 @@ describe('diagnostics', () => {
|
|
|
358
406
|
const fileDiagnostics = resultsForFile.diagnostics;
|
|
359
407
|
assert.equal(fileDiagnostics.length, 1);
|
|
360
408
|
assert.equal("Cannot find name 'missing'.", fileDiagnostics[0].message);
|
|
361
|
-
}))
|
|
409
|
+
}));
|
|
362
410
|
it('supports diagnostic tags', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
363
411
|
const doc = {
|
|
364
|
-
uri:
|
|
412
|
+
uri: uri('diagnosticsBar.ts'),
|
|
365
413
|
languageId: 'typescript',
|
|
366
414
|
version: 1,
|
|
367
415
|
text: `
|
|
@@ -387,10 +435,10 @@ describe('diagnostics', () => {
|
|
|
387
435
|
const deprecatedDiagnostic = fileDiagnostics.find(d => d.code === 6387);
|
|
388
436
|
assert.isDefined(deprecatedDiagnostic);
|
|
389
437
|
assert.deepEqual(deprecatedDiagnostic.tags, [lsp.DiagnosticTag.Deprecated]);
|
|
390
|
-
}))
|
|
438
|
+
}));
|
|
391
439
|
it('multiple files test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
392
440
|
const doc = {
|
|
393
|
-
uri:
|
|
441
|
+
uri: uri('multipleFileDiagnosticsBar.ts'),
|
|
394
442
|
languageId: 'typescript',
|
|
395
443
|
version: 1,
|
|
396
444
|
text: `
|
|
@@ -400,7 +448,7 @@ describe('diagnostics', () => {
|
|
|
400
448
|
`
|
|
401
449
|
};
|
|
402
450
|
const doc2 = {
|
|
403
|
-
uri:
|
|
451
|
+
uri: uri('multipleFileDiagnosticsFoo.ts'),
|
|
404
452
|
languageId: 'typescript',
|
|
405
453
|
version: 1,
|
|
406
454
|
text: `
|
|
@@ -424,7 +472,7 @@ describe('diagnostics', () => {
|
|
|
424
472
|
assert.isDefined(diagnosticsForDoc2);
|
|
425
473
|
assert.equal(diagnosticsForDoc.diagnostics.length, 1, JSON.stringify(diagnostics));
|
|
426
474
|
assert.equal(diagnosticsForDoc2.diagnostics.length, 1, JSON.stringify(diagnostics));
|
|
427
|
-
}))
|
|
475
|
+
}));
|
|
428
476
|
it('code 6133 (ununsed variable) is ignored', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
429
477
|
server.didChangeConfiguration({
|
|
430
478
|
settings: {
|
|
@@ -434,7 +482,7 @@ describe('diagnostics', () => {
|
|
|
434
482
|
}
|
|
435
483
|
});
|
|
436
484
|
const doc = {
|
|
437
|
-
uri:
|
|
485
|
+
uri: uri('diagnosticsBar2.ts'),
|
|
438
486
|
languageId: 'typescript',
|
|
439
487
|
version: 1,
|
|
440
488
|
text: `
|
|
@@ -453,12 +501,12 @@ describe('diagnostics', () => {
|
|
|
453
501
|
assert.isDefined(diagnosticsForThisFile);
|
|
454
502
|
const fileDiagnostics = diagnosticsForThisFile.diagnostics;
|
|
455
503
|
assert.equal(fileDiagnostics.length, 0, JSON.stringify(fileDiagnostics));
|
|
456
|
-
}))
|
|
504
|
+
}));
|
|
457
505
|
});
|
|
458
506
|
describe('document symbol', () => {
|
|
459
507
|
it('simple test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
460
508
|
const doc = {
|
|
461
|
-
uri:
|
|
509
|
+
uri: uri('bar.ts'),
|
|
462
510
|
languageId: 'typescript',
|
|
463
511
|
version: 1,
|
|
464
512
|
text: `
|
|
@@ -481,10 +529,10 @@ Foo
|
|
|
481
529
|
foo
|
|
482
530
|
myFunction
|
|
483
531
|
`, symbolsAsString(symbols) + '\n');
|
|
484
|
-
}))
|
|
532
|
+
}));
|
|
485
533
|
it('merges interfaces correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
486
534
|
const doc = {
|
|
487
|
-
uri:
|
|
535
|
+
uri: uri('bar.ts'),
|
|
488
536
|
languageId: 'typescript',
|
|
489
537
|
version: 1,
|
|
490
538
|
text: `
|
|
@@ -511,10 +559,10 @@ Box
|
|
|
511
559
|
Box
|
|
512
560
|
scale
|
|
513
561
|
`, symbolsAsString(symbols) + '\n');
|
|
514
|
-
}))
|
|
562
|
+
}));
|
|
515
563
|
it('duplication test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
516
564
|
const doc = {
|
|
517
|
-
uri:
|
|
565
|
+
uri: uri('bar.ts'),
|
|
518
566
|
languageId: 'typescript',
|
|
519
567
|
version: 1,
|
|
520
568
|
text: `
|
|
@@ -550,7 +598,7 @@ Foo
|
|
|
550
598
|
assert.deepEqual(symbols[0].range, { start: { line: 1, character: 8 }, end: { line: 5, character: 9 } });
|
|
551
599
|
assert.deepEqual(symbols[1].selectionRange, symbols[1].range);
|
|
552
600
|
assert.deepEqual(symbols[1].range, { start: { line: 6, character: 8 }, end: { line: 10, character: 9 } });
|
|
553
|
-
}))
|
|
601
|
+
}));
|
|
554
602
|
});
|
|
555
603
|
function symbolsAsString(symbols, indentation = '') {
|
|
556
604
|
return symbols.map(symbol => {
|
|
@@ -571,7 +619,7 @@ function symbolsAsString(symbols, indentation = '') {
|
|
|
571
619
|
describe('editing', () => {
|
|
572
620
|
it('open and change', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
573
621
|
const doc = {
|
|
574
|
-
uri:
|
|
622
|
+
uri: uri('openAndChangeBar.ts'),
|
|
575
623
|
languageId: 'typescript',
|
|
576
624
|
version: 1,
|
|
577
625
|
text: `
|
|
@@ -601,45 +649,44 @@ describe('editing', () => {
|
|
|
601
649
|
const fileDiagnostics = resultsForFile.diagnostics;
|
|
602
650
|
assert.isTrue(fileDiagnostics.length >= 1, fileDiagnostics.map(d => d.message).join(','));
|
|
603
651
|
assert.equal("Cannot find name 'missing'.", fileDiagnostics[0].message);
|
|
604
|
-
}))
|
|
652
|
+
}));
|
|
605
653
|
});
|
|
606
654
|
describe('references', () => {
|
|
607
655
|
it('respects "includeDeclaration" in the request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
608
656
|
const doc = {
|
|
609
|
-
uri:
|
|
657
|
+
uri: uri('foo.ts'),
|
|
610
658
|
languageId: 'typescript',
|
|
611
659
|
version: 1,
|
|
612
660
|
text: `
|
|
613
|
-
|
|
614
|
-
foo
|
|
615
|
-
foo = 1;
|
|
661
|
+
function foo() {};
|
|
662
|
+
foo();
|
|
616
663
|
`
|
|
617
664
|
};
|
|
618
665
|
server.didOpenTextDocument({
|
|
619
666
|
textDocument: doc
|
|
620
667
|
});
|
|
621
668
|
// Without declaration/definition.
|
|
669
|
+
const position = lastPosition(doc, 'function foo()');
|
|
622
670
|
let references = yield server.references({
|
|
623
671
|
context: { includeDeclaration: false },
|
|
624
672
|
textDocument: doc,
|
|
625
|
-
position
|
|
673
|
+
position
|
|
626
674
|
});
|
|
627
|
-
assert.strictEqual(references.length,
|
|
675
|
+
assert.strictEqual(references.length, 1);
|
|
628
676
|
assert.strictEqual(references[0].range.start.line, 2);
|
|
629
|
-
assert.strictEqual(references[1].range.start.line, 3);
|
|
630
677
|
// With declaration/definition.
|
|
631
678
|
references = yield server.references({
|
|
632
679
|
context: { includeDeclaration: true },
|
|
633
680
|
textDocument: doc,
|
|
634
|
-
position
|
|
681
|
+
position
|
|
635
682
|
});
|
|
636
|
-
assert.strictEqual(references.length,
|
|
637
|
-
}))
|
|
683
|
+
assert.strictEqual(references.length, 2);
|
|
684
|
+
}));
|
|
638
685
|
});
|
|
639
686
|
describe('workspace configuration', () => {
|
|
640
687
|
it('receives workspace configuration notification', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
641
688
|
const doc = {
|
|
642
|
-
uri:
|
|
689
|
+
uri: uri('bar.ts'),
|
|
643
690
|
languageId: 'typescript',
|
|
644
691
|
version: 1,
|
|
645
692
|
text: `
|
|
@@ -665,13 +712,13 @@ describe('workspace configuration', () => {
|
|
|
665
712
|
}
|
|
666
713
|
}
|
|
667
714
|
});
|
|
668
|
-
const file =
|
|
715
|
+
const file = filePath('bar.ts');
|
|
669
716
|
const settings = server.getWorkspacePreferencesForDocument(file);
|
|
670
717
|
assert.deepEqual(settings, { format: { insertSpaceAfterCommaDelimiter: true } });
|
|
671
718
|
}));
|
|
672
719
|
});
|
|
673
720
|
describe('formatting', () => {
|
|
674
|
-
const uriString =
|
|
721
|
+
const uriString = uri('bar.ts');
|
|
675
722
|
const languageId = 'typescript';
|
|
676
723
|
const version = 1;
|
|
677
724
|
it('full document formatting', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -687,9 +734,9 @@ describe('formatting', () => {
|
|
|
687
734
|
insertSpaces: true
|
|
688
735
|
}
|
|
689
736
|
});
|
|
690
|
-
const result =
|
|
737
|
+
const result = TextDocument.applyEdits(TextDocument.create(uriString, languageId, version, text), edits);
|
|
691
738
|
assert.equal('export function foo(): void { }', result);
|
|
692
|
-
}))
|
|
739
|
+
}));
|
|
693
740
|
it('indent settings (3 spaces)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
694
741
|
const text = 'function foo() {\n// some code\n}';
|
|
695
742
|
const textDocument = {
|
|
@@ -703,9 +750,9 @@ describe('formatting', () => {
|
|
|
703
750
|
insertSpaces: true
|
|
704
751
|
}
|
|
705
752
|
});
|
|
706
|
-
const result =
|
|
753
|
+
const result = TextDocument.applyEdits(TextDocument.create(uriString, languageId, version, text), edits);
|
|
707
754
|
assert.equal('function foo() {\n // some code\n}', result);
|
|
708
|
-
}))
|
|
755
|
+
}));
|
|
709
756
|
it('indent settings (tabs)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
710
757
|
const text = 'function foo() {\n// some code\n}';
|
|
711
758
|
const textDocument = {
|
|
@@ -719,9 +766,9 @@ describe('formatting', () => {
|
|
|
719
766
|
insertSpaces: false
|
|
720
767
|
}
|
|
721
768
|
});
|
|
722
|
-
const result =
|
|
769
|
+
const result = TextDocument.applyEdits(TextDocument.create(uriString, languageId, version, text), edits);
|
|
723
770
|
assert.equal('function foo() {\n\t// some code\n}', result);
|
|
724
|
-
}))
|
|
771
|
+
}));
|
|
725
772
|
it('formatting setting set through workspace configuration', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
726
773
|
const text = 'function foo() {\n// some code\n}';
|
|
727
774
|
const textDocument = {
|
|
@@ -745,9 +792,9 @@ describe('formatting', () => {
|
|
|
745
792
|
insertSpaces: false
|
|
746
793
|
}
|
|
747
794
|
});
|
|
748
|
-
const result =
|
|
795
|
+
const result = TextDocument.applyEdits(TextDocument.create(uriString, languageId, version, text), edits);
|
|
749
796
|
assert.equal('function foo()\n{\n\t// some code\n}', result);
|
|
750
|
-
}))
|
|
797
|
+
}));
|
|
751
798
|
it('selected range', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
752
799
|
const text = 'function foo() {\nconst first = 1;\nconst second = 2;\nconst val = foo( "something" );\n//const fourth = 4;\n}';
|
|
753
800
|
const textDocument = {
|
|
@@ -771,14 +818,14 @@ describe('formatting', () => {
|
|
|
771
818
|
insertSpaces: true
|
|
772
819
|
}
|
|
773
820
|
});
|
|
774
|
-
const result =
|
|
821
|
+
const result = TextDocument.applyEdits(TextDocument.create(uriString, languageId, version, text), edits);
|
|
775
822
|
assert.equal('function foo() {\nconst first = 1;\n const second = 2;\n const val = foo("something");\n//const fourth = 4;\n}', result);
|
|
776
|
-
}))
|
|
823
|
+
}));
|
|
777
824
|
});
|
|
778
825
|
describe('signatureHelp', () => {
|
|
779
826
|
it('simple test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
780
827
|
const doc = {
|
|
781
|
-
uri:
|
|
828
|
+
uri: uri('bar.ts'),
|
|
782
829
|
languageId: 'typescript',
|
|
783
830
|
version: 1,
|
|
784
831
|
text: `
|
|
@@ -791,19 +838,19 @@ describe('signatureHelp', () => {
|
|
|
791
838
|
});
|
|
792
839
|
let result = (yield server.signatureHelp({
|
|
793
840
|
textDocument: doc,
|
|
794
|
-
position:
|
|
841
|
+
position: position(doc, 'param1')
|
|
795
842
|
}));
|
|
796
843
|
assert.equal('bar: string', result.signatures[result.activeSignature].parameters[result.activeParameter].label);
|
|
797
844
|
result = (yield server.signatureHelp({
|
|
798
845
|
textDocument: doc,
|
|
799
|
-
position:
|
|
846
|
+
position: position(doc, 'param2')
|
|
800
847
|
}));
|
|
801
848
|
assert.equal('baz?: boolean', result.signatures[result.activeSignature].parameters[result.activeParameter].label);
|
|
802
|
-
}))
|
|
849
|
+
}));
|
|
803
850
|
});
|
|
804
851
|
describe('code actions', () => {
|
|
805
852
|
const doc = {
|
|
806
|
-
uri:
|
|
853
|
+
uri: uri('bar.ts'),
|
|
807
854
|
languageId: 'typescript',
|
|
808
855
|
version: 1,
|
|
809
856
|
text: `import { something } from "something";
|
|
@@ -845,7 +892,7 @@ describe('code actions', () => {
|
|
|
845
892
|
documentChanges: [
|
|
846
893
|
{
|
|
847
894
|
textDocument: {
|
|
848
|
-
uri:
|
|
895
|
+
uri: uri('bar.ts'),
|
|
849
896
|
version: 1
|
|
850
897
|
},
|
|
851
898
|
edits: [
|
|
@@ -879,7 +926,7 @@ describe('code actions', () => {
|
|
|
879
926
|
command: '_typescript.applyRefactoring',
|
|
880
927
|
arguments: [
|
|
881
928
|
{
|
|
882
|
-
file:
|
|
929
|
+
file: filePath('bar.ts'),
|
|
883
930
|
startLine: 2,
|
|
884
931
|
startOffset: 26,
|
|
885
932
|
endLine: 2,
|
|
@@ -891,7 +938,7 @@ describe('code actions', () => {
|
|
|
891
938
|
},
|
|
892
939
|
kind: 'refactor'
|
|
893
940
|
});
|
|
894
|
-
}))
|
|
941
|
+
}));
|
|
895
942
|
it('can filter quickfix code actions filtered by only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
896
943
|
server.didOpenTextDocument({
|
|
897
944
|
textDocument: doc
|
|
@@ -922,7 +969,7 @@ describe('code actions', () => {
|
|
|
922
969
|
action: 'Convert parameters to destructured object',
|
|
923
970
|
endLine: 2,
|
|
924
971
|
endOffset: 50,
|
|
925
|
-
file:
|
|
972
|
+
file: filePath('bar.ts'),
|
|
926
973
|
refactor: 'Convert parameters to destructured object',
|
|
927
974
|
startLine: 2,
|
|
928
975
|
startOffset: 26
|
|
@@ -935,7 +982,7 @@ describe('code actions', () => {
|
|
|
935
982
|
title: 'Convert parameters to destructured object'
|
|
936
983
|
}
|
|
937
984
|
]);
|
|
938
|
-
}))
|
|
985
|
+
}));
|
|
939
986
|
it('does not provide organize imports when there are errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
940
987
|
server.didOpenTextDocument({
|
|
941
988
|
textDocument: doc
|
|
@@ -957,14 +1004,14 @@ describe('code actions', () => {
|
|
|
957
1004
|
code: 6133,
|
|
958
1005
|
message: 'unused arg'
|
|
959
1006
|
}],
|
|
960
|
-
only: [
|
|
1007
|
+
only: [CodeActionKind.SourceOrganizeImportsTs.value]
|
|
961
1008
|
}
|
|
962
1009
|
}));
|
|
963
1010
|
assert.deepEqual(result, []);
|
|
964
|
-
}))
|
|
1011
|
+
}));
|
|
965
1012
|
it('provides "add missing imports" when explicitly requested in only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
966
1013
|
const doc = {
|
|
967
|
-
uri:
|
|
1014
|
+
uri: uri('bar.ts'),
|
|
968
1015
|
languageId: 'typescript',
|
|
969
1016
|
version: 1,
|
|
970
1017
|
text: 'existsSync(\'t\');'
|
|
@@ -982,12 +1029,12 @@ describe('code actions', () => {
|
|
|
982
1029
|
},
|
|
983
1030
|
context: {
|
|
984
1031
|
diagnostics: [],
|
|
985
|
-
only: [
|
|
1032
|
+
only: [CodeActionKind.SourceAddMissingImportsTs.value]
|
|
986
1033
|
}
|
|
987
1034
|
}));
|
|
988
1035
|
assert.deepEqual(result, [
|
|
989
1036
|
{
|
|
990
|
-
kind:
|
|
1037
|
+
kind: CodeActionKind.SourceAddMissingImportsTs.value,
|
|
991
1038
|
title: 'Add all missing imports',
|
|
992
1039
|
edit: {
|
|
993
1040
|
documentChanges: [
|
|
@@ -1009,7 +1056,7 @@ describe('code actions', () => {
|
|
|
1009
1056
|
}
|
|
1010
1057
|
],
|
|
1011
1058
|
textDocument: {
|
|
1012
|
-
uri:
|
|
1059
|
+
uri: uri('bar.ts'),
|
|
1013
1060
|
version: 1
|
|
1014
1061
|
}
|
|
1015
1062
|
}
|
|
@@ -1017,10 +1064,10 @@ describe('code actions', () => {
|
|
|
1017
1064
|
}
|
|
1018
1065
|
}
|
|
1019
1066
|
]);
|
|
1020
|
-
}))
|
|
1067
|
+
}));
|
|
1021
1068
|
it('provides "fix all" when explicitly requested in only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1022
1069
|
const doc = {
|
|
1023
|
-
uri:
|
|
1070
|
+
uri: uri('bar.ts'),
|
|
1024
1071
|
languageId: 'typescript',
|
|
1025
1072
|
version: 1,
|
|
1026
1073
|
text: `function foo() {
|
|
@@ -1041,12 +1088,12 @@ describe('code actions', () => {
|
|
|
1041
1088
|
},
|
|
1042
1089
|
context: {
|
|
1043
1090
|
diagnostics: [],
|
|
1044
|
-
only: [
|
|
1091
|
+
only: [CodeActionKind.SourceFixAllTs.value]
|
|
1045
1092
|
}
|
|
1046
1093
|
}));
|
|
1047
1094
|
assert.deepEqual(result, [
|
|
1048
1095
|
{
|
|
1049
|
-
kind:
|
|
1096
|
+
kind: CodeActionKind.SourceFixAllTs.value,
|
|
1050
1097
|
title: 'Fix all',
|
|
1051
1098
|
edit: {
|
|
1052
1099
|
documentChanges: [
|
|
@@ -1067,7 +1114,7 @@ describe('code actions', () => {
|
|
|
1067
1114
|
}
|
|
1068
1115
|
],
|
|
1069
1116
|
textDocument: {
|
|
1070
|
-
uri:
|
|
1117
|
+
uri: uri('bar.ts'),
|
|
1071
1118
|
version: 1
|
|
1072
1119
|
}
|
|
1073
1120
|
}
|
|
@@ -1075,10 +1122,10 @@ describe('code actions', () => {
|
|
|
1075
1122
|
}
|
|
1076
1123
|
}
|
|
1077
1124
|
]);
|
|
1078
|
-
}))
|
|
1125
|
+
}));
|
|
1079
1126
|
it('provides organize imports when explicitly requested in only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1080
1127
|
const doc = {
|
|
1081
|
-
uri:
|
|
1128
|
+
uri: uri('bar.ts'),
|
|
1082
1129
|
languageId: 'typescript',
|
|
1083
1130
|
version: 1,
|
|
1084
1131
|
text: `import { existsSync } from 'fs';
|
|
@@ -1103,12 +1150,12 @@ existsSync('t');`
|
|
|
1103
1150
|
code: 6133,
|
|
1104
1151
|
message: 'unused arg'
|
|
1105
1152
|
}],
|
|
1106
|
-
only: [
|
|
1153
|
+
only: [CodeActionKind.SourceOrganizeImportsTs.value]
|
|
1107
1154
|
}
|
|
1108
1155
|
}));
|
|
1109
1156
|
assert.deepEqual(result, [
|
|
1110
1157
|
{
|
|
1111
|
-
kind:
|
|
1158
|
+
kind: CodeActionKind.SourceOrganizeImportsTs.value,
|
|
1112
1159
|
title: 'Organize imports',
|
|
1113
1160
|
edit: {
|
|
1114
1161
|
documentChanges: [
|
|
@@ -1142,7 +1189,7 @@ existsSync('t');`
|
|
|
1142
1189
|
}
|
|
1143
1190
|
],
|
|
1144
1191
|
textDocument: {
|
|
1145
|
-
uri:
|
|
1192
|
+
uri: uri('bar.ts'),
|
|
1146
1193
|
version: 1
|
|
1147
1194
|
}
|
|
1148
1195
|
}
|
|
@@ -1150,10 +1197,10 @@ existsSync('t');`
|
|
|
1150
1197
|
}
|
|
1151
1198
|
}
|
|
1152
1199
|
]);
|
|
1153
|
-
}))
|
|
1200
|
+
}));
|
|
1154
1201
|
it('provides "remove unused" when explicitly requested in only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1155
1202
|
const doc = {
|
|
1156
|
-
uri:
|
|
1203
|
+
uri: uri('bar.ts'),
|
|
1157
1204
|
languageId: 'typescript',
|
|
1158
1205
|
version: 1,
|
|
1159
1206
|
text: 'import { existsSync } from \'fs\';'
|
|
@@ -1166,17 +1213,17 @@ existsSync('t');`
|
|
|
1166
1213
|
const result = (yield server.codeAction({
|
|
1167
1214
|
textDocument: doc,
|
|
1168
1215
|
range: {
|
|
1169
|
-
start:
|
|
1170
|
-
end:
|
|
1216
|
+
start: position(doc, 'existsSync'),
|
|
1217
|
+
end: positionAfter(doc, 'existsSync')
|
|
1171
1218
|
},
|
|
1172
1219
|
context: {
|
|
1173
1220
|
diagnostics: [],
|
|
1174
|
-
only: [
|
|
1221
|
+
only: [CodeActionKind.SourceRemoveUnusedTs.value]
|
|
1175
1222
|
}
|
|
1176
1223
|
}));
|
|
1177
1224
|
assert.deepEqual(result, [
|
|
1178
1225
|
{
|
|
1179
|
-
kind:
|
|
1226
|
+
kind: CodeActionKind.SourceRemoveUnusedTs.value,
|
|
1180
1227
|
title: 'Remove all unused code',
|
|
1181
1228
|
edit: {
|
|
1182
1229
|
documentChanges: [
|
|
@@ -1197,7 +1244,7 @@ existsSync('t');`
|
|
|
1197
1244
|
}
|
|
1198
1245
|
],
|
|
1199
1246
|
textDocument: {
|
|
1200
|
-
uri:
|
|
1247
|
+
uri: uri('bar.ts'),
|
|
1201
1248
|
version: 1
|
|
1202
1249
|
}
|
|
1203
1250
|
}
|
|
@@ -1205,10 +1252,10 @@ existsSync('t');`
|
|
|
1205
1252
|
}
|
|
1206
1253
|
}
|
|
1207
1254
|
]);
|
|
1208
|
-
}))
|
|
1255
|
+
}));
|
|
1209
1256
|
it('only provides the "source.fixAll" kind if requested in only', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1210
1257
|
const doc = {
|
|
1211
|
-
uri:
|
|
1258
|
+
uri: uri('bar.ts'),
|
|
1212
1259
|
languageId: 'typescript',
|
|
1213
1260
|
version: 1,
|
|
1214
1261
|
text: `
|
|
@@ -1228,17 +1275,17 @@ existsSync('t');`
|
|
|
1228
1275
|
textDocument: doc,
|
|
1229
1276
|
range: {
|
|
1230
1277
|
start: { line: 0, character: 0 },
|
|
1231
|
-
end:
|
|
1278
|
+
end: lastPosition(doc, '}')
|
|
1232
1279
|
},
|
|
1233
1280
|
context: {
|
|
1234
1281
|
diagnostics: [],
|
|
1235
|
-
only: [
|
|
1282
|
+
only: [CodeActionKind.SourceFixAllTs.value]
|
|
1236
1283
|
}
|
|
1237
1284
|
}));
|
|
1238
1285
|
assert.strictEqual(result.length, 1, JSON.stringify(result, null, 2));
|
|
1239
1286
|
assert.deepEqual(result, [
|
|
1240
1287
|
{
|
|
1241
|
-
kind:
|
|
1288
|
+
kind: CodeActionKind.SourceFixAllTs.value,
|
|
1242
1289
|
title: 'Fix all',
|
|
1243
1290
|
edit: {
|
|
1244
1291
|
documentChanges: [
|
|
@@ -1259,7 +1306,7 @@ existsSync('t');`
|
|
|
1259
1306
|
}
|
|
1260
1307
|
],
|
|
1261
1308
|
textDocument: {
|
|
1262
|
-
uri:
|
|
1309
|
+
uri: uri('bar.ts'),
|
|
1263
1310
|
version: 1
|
|
1264
1311
|
}
|
|
1265
1312
|
}
|
|
@@ -1267,12 +1314,84 @@ existsSync('t');`
|
|
|
1267
1314
|
}
|
|
1268
1315
|
}
|
|
1269
1316
|
]);
|
|
1270
|
-
}))
|
|
1317
|
+
}));
|
|
1318
|
+
});
|
|
1319
|
+
describe('executeCommand', () => {
|
|
1320
|
+
it('apply refactoring (move to new file)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1321
|
+
const fooUri = uri('foo.ts');
|
|
1322
|
+
const doc = {
|
|
1323
|
+
uri: fooUri,
|
|
1324
|
+
languageId: 'typescript',
|
|
1325
|
+
version: 1,
|
|
1326
|
+
text: 'export function fn(): void {}\nexport function newFn(): void {}'
|
|
1327
|
+
};
|
|
1328
|
+
server.didOpenTextDocument({
|
|
1329
|
+
textDocument: doc
|
|
1330
|
+
});
|
|
1331
|
+
const codeActions = (yield server.codeAction({
|
|
1332
|
+
textDocument: doc,
|
|
1333
|
+
range: {
|
|
1334
|
+
start: position(doc, 'newFn'),
|
|
1335
|
+
end: position(doc, 'newFn')
|
|
1336
|
+
},
|
|
1337
|
+
context: {
|
|
1338
|
+
diagnostics: []
|
|
1339
|
+
}
|
|
1340
|
+
}));
|
|
1341
|
+
// Find refactoring code action.
|
|
1342
|
+
const applyRefactoringAction = codeActions.find(action => { var _a; return ((_a = action.command) === null || _a === void 0 ? void 0 : _a.command) === Commands.APPLY_REFACTORING; });
|
|
1343
|
+
assert.isDefined(applyRefactoringAction);
|
|
1344
|
+
// Execute refactoring action.
|
|
1345
|
+
yield server.executeCommand({
|
|
1346
|
+
command: applyRefactoringAction.command.command,
|
|
1347
|
+
arguments: applyRefactoringAction.command.arguments
|
|
1348
|
+
});
|
|
1349
|
+
assert.equal(1, server.workspaceEdits.length);
|
|
1350
|
+
const { changes } = server.workspaceEdits[0].edit;
|
|
1351
|
+
assert.isDefined(changes);
|
|
1352
|
+
assert.equal(2, Object.keys(changes).length);
|
|
1353
|
+
const change1 = changes[fooUri];
|
|
1354
|
+
assert.isDefined(change1);
|
|
1355
|
+
const change2 = changes[uri('newFn.ts')];
|
|
1356
|
+
assert.isDefined(change2);
|
|
1357
|
+
// Clean up file that is created on applying edit.
|
|
1358
|
+
fs.unlinkSync(filePath('newFn.ts'));
|
|
1359
|
+
assert.deepEqual(change1, [
|
|
1360
|
+
{
|
|
1361
|
+
range: {
|
|
1362
|
+
start: {
|
|
1363
|
+
line: 1,
|
|
1364
|
+
character: 0
|
|
1365
|
+
},
|
|
1366
|
+
end: {
|
|
1367
|
+
line: 1,
|
|
1368
|
+
character: 32
|
|
1369
|
+
}
|
|
1370
|
+
},
|
|
1371
|
+
newText: ''
|
|
1372
|
+
}
|
|
1373
|
+
]);
|
|
1374
|
+
assert.deepEqual(change2, [
|
|
1375
|
+
{
|
|
1376
|
+
range: {
|
|
1377
|
+
start: {
|
|
1378
|
+
line: 0,
|
|
1379
|
+
character: 0
|
|
1380
|
+
},
|
|
1381
|
+
end: {
|
|
1382
|
+
line: 0,
|
|
1383
|
+
character: 0
|
|
1384
|
+
}
|
|
1385
|
+
},
|
|
1386
|
+
newText: 'export function newFn(): void { }\n'
|
|
1387
|
+
}
|
|
1388
|
+
]);
|
|
1389
|
+
}));
|
|
1271
1390
|
});
|
|
1272
1391
|
describe('documentHighlight', () => {
|
|
1273
1392
|
it('simple test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1274
1393
|
const barDoc = {
|
|
1275
|
-
uri:
|
|
1394
|
+
uri: uri('bar.d.ts'),
|
|
1276
1395
|
languageId: 'typescript',
|
|
1277
1396
|
version: 1,
|
|
1278
1397
|
text: `
|
|
@@ -1285,7 +1404,7 @@ describe('documentHighlight', () => {
|
|
|
1285
1404
|
textDocument: barDoc
|
|
1286
1405
|
});
|
|
1287
1406
|
const fooDoc = {
|
|
1288
|
-
uri:
|
|
1407
|
+
uri: uri('bar.ts'),
|
|
1289
1408
|
languageId: 'typescript',
|
|
1290
1409
|
version: 1,
|
|
1291
1410
|
text: `
|
|
@@ -1299,10 +1418,10 @@ describe('documentHighlight', () => {
|
|
|
1299
1418
|
});
|
|
1300
1419
|
const result = yield server.documentHighlight({
|
|
1301
1420
|
textDocument: fooDoc,
|
|
1302
|
-
position:
|
|
1421
|
+
position: lastPosition(fooDoc, 'Bar')
|
|
1303
1422
|
});
|
|
1304
1423
|
assert.equal(2, result.length, JSON.stringify(result, undefined, 2));
|
|
1305
|
-
}))
|
|
1424
|
+
}));
|
|
1306
1425
|
});
|
|
1307
1426
|
describe('calls', () => {
|
|
1308
1427
|
function resultToString(callsResult, direction) {
|
|
@@ -1322,7 +1441,7 @@ describe('calls', () => {
|
|
|
1322
1441
|
return out.join('\n');
|
|
1323
1442
|
}
|
|
1324
1443
|
const doDoc = {
|
|
1325
|
-
uri:
|
|
1444
|
+
uri: uri('do.ts'),
|
|
1326
1445
|
languageId: 'typescript',
|
|
1327
1446
|
version: 1,
|
|
1328
1447
|
text: `
|
|
@@ -1340,7 +1459,7 @@ export function three() {
|
|
|
1340
1459
|
`
|
|
1341
1460
|
};
|
|
1342
1461
|
const fooDoc = {
|
|
1343
|
-
uri:
|
|
1462
|
+
uri: uri('foo.ts'),
|
|
1344
1463
|
languageId: 'typescript',
|
|
1345
1464
|
version: 1,
|
|
1346
1465
|
text: `import { doStuff } from './do';
|
|
@@ -1357,18 +1476,14 @@ export function factory() {
|
|
|
1357
1476
|
`
|
|
1358
1477
|
};
|
|
1359
1478
|
function openDocuments() {
|
|
1360
|
-
server.didOpenTextDocument({
|
|
1361
|
-
|
|
1362
|
-
});
|
|
1363
|
-
server.didOpenTextDocument({
|
|
1364
|
-
textDocument: fooDoc
|
|
1365
|
-
});
|
|
1479
|
+
server.didOpenTextDocument({ textDocument: doDoc });
|
|
1480
|
+
server.didOpenTextDocument({ textDocument: fooDoc });
|
|
1366
1481
|
}
|
|
1367
1482
|
it('callers: first step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1368
1483
|
openDocuments();
|
|
1369
1484
|
const callsResult = yield server.calls({
|
|
1370
1485
|
textDocument: fooDoc,
|
|
1371
|
-
position:
|
|
1486
|
+
position: position(fooDoc, 'doStuff();')
|
|
1372
1487
|
});
|
|
1373
1488
|
assert.equal(resultToString(callsResult, lspcalls.CallDirection.Incoming), `
|
|
1374
1489
|
↘ doStuff (do.ts#1)
|
|
@@ -1376,61 +1491,72 @@ export function factory() {
|
|
|
1376
1491
|
↘ doSomething (foo.ts#2) - foo.ts#3
|
|
1377
1492
|
↘ x (foo.ts#4) - foo.ts#4
|
|
1378
1493
|
`.trim());
|
|
1379
|
-
}))
|
|
1494
|
+
}));
|
|
1380
1495
|
it('callers: second step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1381
1496
|
openDocuments();
|
|
1382
1497
|
const callsResult = yield server.calls({
|
|
1383
1498
|
textDocument: fooDoc,
|
|
1384
|
-
position:
|
|
1499
|
+
position: position(fooDoc, 'doSomething() {')
|
|
1385
1500
|
});
|
|
1386
1501
|
assert.equal(resultToString(callsResult, lspcalls.CallDirection.Incoming), `
|
|
1387
1502
|
↘ doSomething (foo.ts#2)
|
|
1388
1503
|
↘ factory (foo.ts#8) - foo.ts#9
|
|
1389
1504
|
`.trim());
|
|
1390
|
-
}))
|
|
1391
|
-
it('callees: first step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1505
|
+
}));
|
|
1506
|
+
it.skip('callees: first step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1392
1507
|
openDocuments();
|
|
1393
1508
|
const direction = lspcalls.CallDirection.Outgoing;
|
|
1394
1509
|
const callsResult = yield server.calls({
|
|
1395
1510
|
direction,
|
|
1396
1511
|
textDocument: fooDoc,
|
|
1397
|
-
position:
|
|
1512
|
+
position: position(fooDoc, 'doStuff()')
|
|
1398
1513
|
});
|
|
1399
1514
|
assert.equal(resultToString(callsResult, direction), `
|
|
1400
1515
|
↖ doStuff (do.ts#1)
|
|
1401
1516
|
↖ two (do.ts#4) - do.ts#2
|
|
1402
1517
|
`.trim());
|
|
1403
|
-
}))
|
|
1404
|
-
it('callees: second step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1518
|
+
}));
|
|
1519
|
+
it.skip('callees: second step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1405
1520
|
openDocuments();
|
|
1406
1521
|
const direction = lspcalls.CallDirection.Outgoing;
|
|
1407
1522
|
const callsResult = yield server.calls({
|
|
1408
1523
|
direction,
|
|
1409
1524
|
textDocument: doDoc,
|
|
1410
|
-
position:
|
|
1525
|
+
position: position(doDoc, 'function two()')
|
|
1411
1526
|
});
|
|
1412
1527
|
assert.equal(resultToString(callsResult, direction), `
|
|
1413
1528
|
↖ two (do.ts#4)
|
|
1414
1529
|
↖ three (do.ts#9) - do.ts#5
|
|
1415
1530
|
↖ ttt (do.ts#6) - do.ts#7
|
|
1416
1531
|
`.trim());
|
|
1417
|
-
}))
|
|
1532
|
+
}));
|
|
1418
1533
|
});
|
|
1419
1534
|
describe('diagnostics (no client support)', () => {
|
|
1535
|
+
let localServer;
|
|
1420
1536
|
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
1421
1537
|
var _a;
|
|
1422
1538
|
// Remove the "textDocument.publishDiagnostics" client capability.
|
|
1423
|
-
const clientCapabilitiesOverride =
|
|
1539
|
+
const clientCapabilitiesOverride = getDefaultClientCapabilities();
|
|
1424
1540
|
(_a = clientCapabilitiesOverride.textDocument) === null || _a === void 0 ? true : delete _a.publishDiagnostics;
|
|
1425
|
-
|
|
1541
|
+
localServer = yield createServer({
|
|
1426
1542
|
rootUri: null,
|
|
1427
1543
|
publishDiagnostics: args => diagnostics.set(args.uri, args),
|
|
1428
1544
|
clientCapabilitiesOverride
|
|
1429
1545
|
});
|
|
1430
1546
|
}));
|
|
1547
|
+
beforeEach(() => {
|
|
1548
|
+
localServer.closeAll();
|
|
1549
|
+
// "closeAll" triggers final publishDiagnostics with an empty list so clear last.
|
|
1550
|
+
diagnostics.clear();
|
|
1551
|
+
localServer.workspaceEdits = [];
|
|
1552
|
+
});
|
|
1553
|
+
after(() => {
|
|
1554
|
+
localServer.closeAll();
|
|
1555
|
+
localServer.shutdown();
|
|
1556
|
+
});
|
|
1431
1557
|
it('diagnostics are published', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1432
1558
|
const doc = {
|
|
1433
|
-
uri:
|
|
1559
|
+
uri: uri('diagnosticsBar.ts'),
|
|
1434
1560
|
languageId: 'typescript',
|
|
1435
1561
|
version: 1,
|
|
1436
1562
|
text: `
|
|
@@ -1439,78 +1565,77 @@ describe('diagnostics (no client support)', () => {
|
|
|
1439
1565
|
}
|
|
1440
1566
|
`
|
|
1441
1567
|
};
|
|
1442
|
-
|
|
1568
|
+
localServer.didOpenTextDocument({
|
|
1443
1569
|
textDocument: doc
|
|
1444
1570
|
});
|
|
1445
|
-
yield
|
|
1571
|
+
yield localServer.requestDiagnostics();
|
|
1446
1572
|
yield new Promise(resolve => setTimeout(resolve, 200));
|
|
1447
1573
|
const resultsForFile = diagnostics.get(doc.uri);
|
|
1448
1574
|
assert.isDefined(resultsForFile);
|
|
1449
1575
|
assert.strictEqual(resultsForFile === null || resultsForFile === void 0 ? void 0 : resultsForFile.diagnostics.length, 1);
|
|
1450
|
-
}))
|
|
1576
|
+
}));
|
|
1451
1577
|
});
|
|
1452
1578
|
describe('jsx/tsx project', () => {
|
|
1579
|
+
let localServer;
|
|
1453
1580
|
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
1454
|
-
|
|
1455
|
-
rootUri:
|
|
1581
|
+
localServer = yield createServer({
|
|
1582
|
+
rootUri: uri('jsx'),
|
|
1456
1583
|
publishDiagnostics: args => diagnostics.set(args.uri, args)
|
|
1457
1584
|
});
|
|
1458
1585
|
}));
|
|
1586
|
+
beforeEach(() => {
|
|
1587
|
+
localServer.closeAll();
|
|
1588
|
+
// "closeAll" triggers final publishDiagnostics with an empty list so clear last.
|
|
1589
|
+
diagnostics.clear();
|
|
1590
|
+
localServer.workspaceEdits = [];
|
|
1591
|
+
});
|
|
1592
|
+
after(() => {
|
|
1593
|
+
localServer.closeAll();
|
|
1594
|
+
localServer.shutdown();
|
|
1595
|
+
});
|
|
1459
1596
|
it('includes snippet completion for element prop', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1460
1597
|
const doc = {
|
|
1461
|
-
uri:
|
|
1598
|
+
uri: uri('jsx', 'app.tsx'),
|
|
1462
1599
|
languageId: 'typescriptreact',
|
|
1463
1600
|
version: 1,
|
|
1464
|
-
text:
|
|
1601
|
+
text: readContents(filePath('jsx', 'app.tsx'))
|
|
1465
1602
|
};
|
|
1466
|
-
|
|
1603
|
+
localServer.didOpenTextDocument({
|
|
1467
1604
|
textDocument: doc
|
|
1468
1605
|
});
|
|
1469
|
-
const completion = yield
|
|
1606
|
+
const completion = yield localServer.completion({ textDocument: doc, position: position(doc, 'title') });
|
|
1470
1607
|
assert.isNotNull(completion);
|
|
1471
1608
|
const item = completion.items.find(i => i.label === 'title');
|
|
1472
1609
|
assert.isDefined(item);
|
|
1473
1610
|
assert.strictEqual(item === null || item === void 0 ? void 0 : item.insertTextFormat, 2);
|
|
1474
|
-
}))
|
|
1611
|
+
}));
|
|
1475
1612
|
});
|
|
1476
1613
|
describe('inlayHints', () => {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
return 3
|
|
1485
|
-
}
|
|
1486
|
-
`
|
|
1487
|
-
};
|
|
1488
|
-
yield server.initialize({
|
|
1489
|
-
initializationOptions: {
|
|
1490
|
-
preferences: {
|
|
1491
|
-
includeInlayFunctionLikeReturnTypeHints: true
|
|
1614
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
1615
|
+
server.didChangeConfiguration({
|
|
1616
|
+
settings: {
|
|
1617
|
+
typescript: {
|
|
1618
|
+
inlayHints: {
|
|
1619
|
+
includeInlayFunctionLikeReturnTypeHints: true
|
|
1620
|
+
}
|
|
1492
1621
|
}
|
|
1493
|
-
}
|
|
1494
|
-
processId: null,
|
|
1495
|
-
capabilities: (0, test_utils_1.getDefaultClientCapabilities)(),
|
|
1496
|
-
workspaceFolders: [],
|
|
1497
|
-
rootUri: ''
|
|
1498
|
-
});
|
|
1499
|
-
server.didOpenTextDocument({
|
|
1500
|
-
textDocument: doc
|
|
1622
|
+
}
|
|
1501
1623
|
});
|
|
1502
|
-
|
|
1503
|
-
|
|
1624
|
+
}));
|
|
1625
|
+
after(() => {
|
|
1626
|
+
server.didChangeConfiguration({
|
|
1627
|
+
settings: {
|
|
1628
|
+
typescript: {
|
|
1629
|
+
inlayHints: {
|
|
1630
|
+
includeInlayFunctionLikeReturnTypeHints: false
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1504
1634
|
});
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
assert.strictEqual(inlayHints[0].text, ': number');
|
|
1508
|
-
assert.strictEqual(inlayHints[0].kind, 'Type');
|
|
1509
|
-
assert.deepStrictEqual(inlayHints[0].position, { line: 1, character: 29 });
|
|
1510
|
-
})).timeout(10000);
|
|
1511
|
-
it('inlayHints options set through workspace configuration ', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1635
|
+
});
|
|
1636
|
+
it('inlayHints', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1512
1637
|
const doc = {
|
|
1513
|
-
uri:
|
|
1638
|
+
uri: uri('module.ts'),
|
|
1514
1639
|
languageId: 'typescript',
|
|
1515
1640
|
version: 1,
|
|
1516
1641
|
text: `
|
|
@@ -1519,32 +1644,13 @@ describe('inlayHints', () => {
|
|
|
1519
1644
|
}
|
|
1520
1645
|
`
|
|
1521
1646
|
};
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
capabilities: (0, test_utils_1.getDefaultClientCapabilities)(),
|
|
1525
|
-
workspaceFolders: [],
|
|
1526
|
-
rootUri: ''
|
|
1527
|
-
});
|
|
1528
|
-
server.didChangeConfiguration({
|
|
1529
|
-
settings: {
|
|
1530
|
-
typescript: {
|
|
1531
|
-
inlayHints: {
|
|
1532
|
-
includeInlayFunctionLikeReturnTypeHints: true
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
});
|
|
1537
|
-
server.didOpenTextDocument({
|
|
1538
|
-
textDocument: doc
|
|
1539
|
-
});
|
|
1540
|
-
const { inlayHints } = yield server.inlayHints({
|
|
1541
|
-
textDocument: doc
|
|
1542
|
-
});
|
|
1647
|
+
server.didOpenTextDocument({ textDocument: doc });
|
|
1648
|
+
const { inlayHints } = yield server.inlayHints({ textDocument: doc });
|
|
1543
1649
|
assert.isDefined(inlayHints);
|
|
1544
1650
|
assert.strictEqual(inlayHints.length, 1);
|
|
1545
1651
|
assert.strictEqual(inlayHints[0].text, ': number');
|
|
1546
1652
|
assert.strictEqual(inlayHints[0].kind, 'Type');
|
|
1547
1653
|
assert.deepStrictEqual(inlayHints[0].position, { line: 1, character: 29 });
|
|
1548
|
-
}))
|
|
1654
|
+
}));
|
|
1549
1655
|
});
|
|
1550
1656
|
//# sourceMappingURL=lsp-server.spec.js.map
|