volar-service-typescript 0.0.46 → 0.0.48
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/lib/configs/getFormatCodeSettings.d.ts +2 -2
- package/lib/configs/getUserPreferences.d.ts +2 -2
- package/lib/configs/getUserPreferences.js +4 -2
- package/lib/plugins/directiveComment.js +5 -1
- package/lib/plugins/docCommentTemplate.js +5 -1
- package/lib/plugins/semantic.d.ts +6 -5
- package/lib/plugins/semantic.js +154 -55
- package/lib/plugins/syntactic.d.ts +4 -4
- package/lib/plugins/syntactic.js +15 -6
- package/lib/semanticFeatures/codeAction.d.ts +3 -2
- package/lib/semanticFeatures/codeAction.js +3 -3
- package/lib/semanticFeatures/codeActionResolve.js +2 -1
- package/lib/semanticFeatures/semanticTokens.d.ts +2 -1
- package/lib/semanticFeatures/semanticTokens.js +2 -2
- package/lib/semanticFeatures/types.d.ts +6 -5
- package/lib/utils/lspConverters.d.ts +6 -5
- package/lib/utils/lspConverters.js +10 -10
- package/lib/utils/previewer.d.ts +5 -4
- package/lib/utils/typeConverters.d.ts +1 -1
- package/package.json +5 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FormattingOptions,
|
|
1
|
+
import type { FormattingOptions, LanguageServiceContext } from '@volar/language-service';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
export declare function getFormatCodeSettings(ctx:
|
|
4
|
+
export declare function getFormatCodeSettings(ctx: LanguageServiceContext, document: TextDocument, options: FormattingOptions | undefined): Promise<ts.FormatCodeSettings>;
|
|
5
5
|
//# sourceMappingURL=getFormatCodeSettings.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function getUserPreferences(ctx:
|
|
3
|
+
import type { LanguageServiceContext } from '@volar/language-service';
|
|
4
|
+
export declare function getUserPreferences(ctx: LanguageServiceContext, document: TextDocument): Promise<ts.UserPreferences>;
|
|
5
5
|
//# sourceMappingURL=getUserPreferences.d.ts.map
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getUserPreferences = void 0;
|
|
4
4
|
const path = require("path-browserify");
|
|
5
5
|
const shared_1 = require("../shared");
|
|
6
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
6
7
|
async function getUserPreferences(ctx, document) {
|
|
7
8
|
let currentDirectory = '';
|
|
8
9
|
if (ctx.language.typescript) {
|
|
9
10
|
currentDirectory = ctx.language.typescript.languageServiceHost.getCurrentDirectory();
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
13
|
+
const documentUri = ctx.decodeEmbeddedDocumentUri(uri)?.[0] ?? uri;
|
|
12
14
|
const config = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document)) ?? {};
|
|
13
15
|
const preferencesConfig = config?.preferences ?? {};
|
|
14
16
|
const preferences = {
|
|
@@ -17,7 +19,7 @@ async function getUserPreferences(ctx, document) {
|
|
|
17
19
|
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
|
|
18
20
|
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
|
|
19
21
|
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig),
|
|
20
|
-
allowTextChangesInNewFiles: documentUri.
|
|
22
|
+
allowTextChangesInNewFiles: documentUri.scheme === 'file',
|
|
21
23
|
providePrefixAndSuffixTextForRename: (preferencesConfig.renameShorthandProperties ?? true) === false ? false : (preferencesConfig.useAliasesForRenames ?? true),
|
|
22
24
|
allowRenameOfImportPath: true,
|
|
23
25
|
includeAutomaticOptionalChainCompletions: config.suggest?.includeAutomaticOptionalChainCompletions ?? true,
|
|
@@ -22,7 +22,11 @@ const directives = [
|
|
|
22
22
|
function create() {
|
|
23
23
|
return {
|
|
24
24
|
name: 'typescript-directive-comment',
|
|
25
|
-
|
|
25
|
+
capabilities: {
|
|
26
|
+
completionProvider: {
|
|
27
|
+
triggerCharacters: ['@'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
26
30
|
create() {
|
|
27
31
|
return {
|
|
28
32
|
provideCompletionItems(document, position) {
|
|
@@ -10,7 +10,11 @@ const defaultJsDoc = `/**\n * $0\n */`;
|
|
|
10
10
|
function create(ts) {
|
|
11
11
|
return {
|
|
12
12
|
name: 'typescript-doc-comment-template',
|
|
13
|
-
|
|
13
|
+
capabilities: {
|
|
14
|
+
completionProvider: {
|
|
15
|
+
triggerCharacters: ['*'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
14
18
|
create() {
|
|
15
19
|
return {
|
|
16
20
|
provideCompletionItems(document, position) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { ProviderResult,
|
|
1
|
+
import type { ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
import { URI } from 'vscode-uri';
|
|
4
5
|
export interface Provide {
|
|
5
6
|
'typescript/languageService': () => ts.LanguageService;
|
|
6
7
|
'typescript/languageServiceHost': () => ts.LanguageServiceHost;
|
|
7
|
-
'typescript/documentFileName': (uri:
|
|
8
|
-
'typescript/documentUri': (fileName: string) =>
|
|
8
|
+
'typescript/documentFileName': (uri: URI) => string;
|
|
9
|
+
'typescript/documentUri': (fileName: string) => URI;
|
|
9
10
|
}
|
|
10
11
|
export interface CompletionItemData {
|
|
11
12
|
uri: string;
|
|
@@ -19,7 +20,7 @@ export interface CompletionItemData {
|
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
export declare function create(ts: typeof import('typescript'), { isValidationEnabled, isSuggestionsEnabled, }?: {
|
|
22
|
-
isValidationEnabled?(document: TextDocument, context:
|
|
23
|
-
isSuggestionsEnabled?(document: TextDocument, context:
|
|
23
|
+
isValidationEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
|
|
24
|
+
isSuggestionsEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
|
|
24
25
|
}): LanguageServicePlugin;
|
|
25
26
|
//# sourceMappingURL=semantic.d.ts.map
|
package/lib/plugins/semantic.js
CHANGED
|
@@ -12,6 +12,7 @@ const snippetForFunctionCall_1 = require("../utils/snippetForFunctionCall");
|
|
|
12
12
|
const codeActions = require("../semanticFeatures/codeAction");
|
|
13
13
|
const codeActionResolve = require("../semanticFeatures/codeActionResolve");
|
|
14
14
|
const semanticTokens = require("../semanticFeatures/semanticTokens");
|
|
15
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
15
16
|
const documentRegistries = [];
|
|
16
17
|
function getDocumentRegistry(ts, useCaseSensitiveFileNames, currentDirectory) {
|
|
17
18
|
let documentRegistry = documentRegistries.find(item => item[0] === useCaseSensitiveFileNames && item[1] === currentDirectory)?.[2];
|
|
@@ -28,15 +29,93 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
28
29
|
}, } = {}) {
|
|
29
30
|
return {
|
|
30
31
|
name: 'typescript-semantic',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
capabilities: {
|
|
33
|
+
completionProvider: {
|
|
34
|
+
triggerCharacters: getBasicTriggerCharacters(ts.version),
|
|
35
|
+
resolveProvider: true,
|
|
36
|
+
},
|
|
37
|
+
renameProvider: {
|
|
38
|
+
prepareProvider: true,
|
|
39
|
+
},
|
|
40
|
+
codeActionProvider: {
|
|
41
|
+
codeActionKinds: [
|
|
42
|
+
'',
|
|
43
|
+
'quickfix',
|
|
44
|
+
'refactor',
|
|
45
|
+
'refactor.extract',
|
|
46
|
+
'refactor.inline',
|
|
47
|
+
'refactor.rewrite',
|
|
48
|
+
'source',
|
|
49
|
+
'source.fixAll',
|
|
50
|
+
'source.organizeImports',
|
|
51
|
+
],
|
|
52
|
+
resolveProvider: true,
|
|
53
|
+
},
|
|
54
|
+
inlayHintProvider: {},
|
|
55
|
+
callHierarchyProvider: true,
|
|
56
|
+
definitionProvider: true,
|
|
57
|
+
typeDefinitionProvider: true,
|
|
58
|
+
diagnosticProvider: true,
|
|
59
|
+
hoverProvider: true,
|
|
60
|
+
implementationProvider: true,
|
|
61
|
+
referencesProvider: true,
|
|
62
|
+
// fileReferencesProvider: true,
|
|
63
|
+
documentHighlightProvider: true,
|
|
64
|
+
semanticTokensProvider: {
|
|
65
|
+
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
|
|
66
|
+
legend: {
|
|
67
|
+
tokenTypes: [
|
|
68
|
+
'namespace',
|
|
69
|
+
'class',
|
|
70
|
+
'enum',
|
|
71
|
+
'interface',
|
|
72
|
+
'struct',
|
|
73
|
+
'typeParameter',
|
|
74
|
+
'type',
|
|
75
|
+
'parameter',
|
|
76
|
+
'variable',
|
|
77
|
+
'property',
|
|
78
|
+
'enumMember',
|
|
79
|
+
'decorator',
|
|
80
|
+
'event',
|
|
81
|
+
'function',
|
|
82
|
+
'method',
|
|
83
|
+
'macro',
|
|
84
|
+
'label',
|
|
85
|
+
'comment',
|
|
86
|
+
'string',
|
|
87
|
+
'keyword',
|
|
88
|
+
'number',
|
|
89
|
+
'regexp',
|
|
90
|
+
'operator',
|
|
91
|
+
],
|
|
92
|
+
tokenModifiers: [
|
|
93
|
+
'declaration',
|
|
94
|
+
'definition',
|
|
95
|
+
'readonly',
|
|
96
|
+
'static',
|
|
97
|
+
'deprecated',
|
|
98
|
+
'abstract',
|
|
99
|
+
'async',
|
|
100
|
+
'modification',
|
|
101
|
+
'documentation',
|
|
102
|
+
'defaultLibrary',
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
workspaceSymbolProvider: true,
|
|
107
|
+
// fileRenameEdits: true,
|
|
108
|
+
selectionRangeProvider: true,
|
|
109
|
+
signatureHelpProvider: {
|
|
110
|
+
triggerCharacters: ['(', ',', '<'],
|
|
111
|
+
retriggerCharacters: [')'],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
34
114
|
create(context) {
|
|
35
115
|
if (!context.language.typescript) {
|
|
36
116
|
return {};
|
|
37
117
|
}
|
|
38
|
-
const {
|
|
39
|
-
const sys = projectHost;
|
|
118
|
+
const { sys, languageServiceHost, asFileName, asScriptId } = context.language.typescript;
|
|
40
119
|
const created = tsWithImportCache.createLanguageService(ts, sys, languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, getDocumentRegistry(ts, sys.useCaseSensitiveFileNames, languageServiceHost.getCurrentDirectory())));
|
|
41
120
|
const { languageService } = created;
|
|
42
121
|
if (created.setPreferences && context.env.getConfiguration) {
|
|
@@ -61,7 +140,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
61
140
|
updateSourceScriptFileNames();
|
|
62
141
|
}
|
|
63
142
|
for (const change of params.changes) {
|
|
64
|
-
const fileName =
|
|
143
|
+
const fileName = asFileName(vscode_uri_1.URI.parse(change.uri));
|
|
65
144
|
if (sourceScriptNames.has(normalizeFileName(fileName))) {
|
|
66
145
|
created.projectUpdated?.(languageServiceHost.getCurrentDirectory());
|
|
67
146
|
}
|
|
@@ -70,7 +149,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
70
149
|
function updateSourceScriptFileNames() {
|
|
71
150
|
sourceScriptNames.clear();
|
|
72
151
|
for (const fileName of languageServiceHost.getScriptFileNames()) {
|
|
73
|
-
const uri =
|
|
152
|
+
const uri = asScriptId(fileName);
|
|
74
153
|
const sourceScript = context.language.scripts.get(uri);
|
|
75
154
|
if (sourceScript?.generated) {
|
|
76
155
|
const tsCode = sourceScript.generated.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
|
|
@@ -93,10 +172,10 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
93
172
|
if (virtualScript) {
|
|
94
173
|
return virtualScript.fileName;
|
|
95
174
|
}
|
|
96
|
-
return
|
|
175
|
+
return asFileName(uri);
|
|
97
176
|
},
|
|
98
177
|
fileNameToUri(fileName) {
|
|
99
|
-
const uri =
|
|
178
|
+
const uri = asScriptId(fileName);
|
|
100
179
|
const sourceScript = context.language.scripts.get(uri);
|
|
101
180
|
const extraServiceScript = context.language.typescript.getExtraServiceScript(fileName);
|
|
102
181
|
let virtualCode = extraServiceScript?.code;
|
|
@@ -153,7 +232,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
153
232
|
return undefined;
|
|
154
233
|
},
|
|
155
234
|
async provideCompletionItems(document, position, completeContext, token) {
|
|
156
|
-
|
|
235
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
236
|
+
if (!isSemanticDocument(uri, document)) {
|
|
157
237
|
return;
|
|
158
238
|
}
|
|
159
239
|
if (!await isSuggestionsEnabled(document, context)) {
|
|
@@ -161,7 +241,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
161
241
|
}
|
|
162
242
|
return await worker(token, async () => {
|
|
163
243
|
const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
164
|
-
const fileName = ctx.uriToFileName(
|
|
244
|
+
const fileName = ctx.uriToFileName(uri);
|
|
165
245
|
const offset = document.offsetAt(position);
|
|
166
246
|
const info = (0, shared_1.safeCall)(() => ctx.languageService.getCompletionsAtPosition(fileName, offset, {
|
|
167
247
|
...preferences,
|
|
@@ -190,7 +270,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
190
270
|
return item;
|
|
191
271
|
}
|
|
192
272
|
const { fileName, offset } = data;
|
|
193
|
-
const
|
|
273
|
+
const uri = vscode_uri_1.URI.parse(data.uri);
|
|
274
|
+
const document = ctx.getTextDocument(uri);
|
|
194
275
|
const [formatOptions, preferences] = await Promise.all([
|
|
195
276
|
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
|
|
196
277
|
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
@@ -262,11 +343,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
262
343
|
}) ?? item;
|
|
263
344
|
},
|
|
264
345
|
provideRenameRange(document, position, token) {
|
|
265
|
-
|
|
346
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
347
|
+
if (!isSemanticDocument(uri, document)) {
|
|
266
348
|
return;
|
|
267
349
|
}
|
|
268
350
|
return worker(token, () => {
|
|
269
|
-
const fileName = ctx.uriToFileName(
|
|
351
|
+
const fileName = ctx.uriToFileName(uri);
|
|
270
352
|
const offset = document.offsetAt(position);
|
|
271
353
|
const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, renameInfoOptions));
|
|
272
354
|
if (!renameInfo) {
|
|
@@ -279,11 +361,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
279
361
|
});
|
|
280
362
|
},
|
|
281
363
|
provideRenameEdits(document, position, newName, token) {
|
|
282
|
-
|
|
364
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
365
|
+
if (!isSemanticDocument(uri, document, true)) {
|
|
283
366
|
return;
|
|
284
367
|
}
|
|
285
368
|
return worker(token, async () => {
|
|
286
|
-
const fileName = ctx.uriToFileName(
|
|
369
|
+
const fileName = ctx.uriToFileName(uri);
|
|
287
370
|
const offset = document.offsetAt(position);
|
|
288
371
|
const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, renameInfoOptions));
|
|
289
372
|
if (!renameInfo?.canRename) {
|
|
@@ -319,19 +402,20 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
319
402
|
}
|
|
320
403
|
edits.documentChanges.push({
|
|
321
404
|
kind: 'rename',
|
|
322
|
-
oldUri: ctx.fileNameToUri(fileToRename),
|
|
323
|
-
newUri: ctx.fileNameToUri(newFilePath),
|
|
405
|
+
oldUri: ctx.fileNameToUri(fileToRename).toString(),
|
|
406
|
+
newUri: ctx.fileNameToUri(newFilePath).toString(),
|
|
324
407
|
});
|
|
325
408
|
return edits;
|
|
326
409
|
}
|
|
327
410
|
});
|
|
328
411
|
},
|
|
329
412
|
provideCodeActions(document, range, context, token) {
|
|
330
|
-
|
|
413
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
414
|
+
if (!isSemanticDocument(uri, document)) {
|
|
331
415
|
return;
|
|
332
416
|
}
|
|
333
417
|
return worker(token, () => {
|
|
334
|
-
return getCodeActions(document, range, context, formattingOptions);
|
|
418
|
+
return getCodeActions(uri, document, range, context, formattingOptions);
|
|
335
419
|
});
|
|
336
420
|
},
|
|
337
421
|
async resolveCodeAction(codeAction, token) {
|
|
@@ -340,12 +424,13 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
340
424
|
}) ?? codeAction;
|
|
341
425
|
},
|
|
342
426
|
provideInlayHints(document, range, token) {
|
|
343
|
-
|
|
427
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
428
|
+
if (!isSemanticDocument(uri, document)) {
|
|
344
429
|
return;
|
|
345
430
|
}
|
|
346
431
|
return worker(token, async () => {
|
|
347
432
|
const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
348
|
-
const fileName = ctx.uriToFileName(
|
|
433
|
+
const fileName = ctx.uriToFileName(uri);
|
|
349
434
|
const start = document.offsetAt(range.start);
|
|
350
435
|
const end = document.offsetAt(range.end);
|
|
351
436
|
const inlayHints = (0, shared_1.safeCall)(() => 'provideInlayHints' in ctx.languageService
|
|
@@ -358,11 +443,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
358
443
|
});
|
|
359
444
|
},
|
|
360
445
|
provideCallHierarchyItems(document, position, token) {
|
|
361
|
-
|
|
446
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
447
|
+
if (!isSemanticDocument(uri, document)) {
|
|
362
448
|
return;
|
|
363
449
|
}
|
|
364
450
|
return worker(token, () => {
|
|
365
|
-
const fileName = ctx.uriToFileName(
|
|
451
|
+
const fileName = ctx.uriToFileName(uri);
|
|
366
452
|
const offset = document.offsetAt(position);
|
|
367
453
|
const calls = (0, shared_1.safeCall)(() => ctx.languageService.prepareCallHierarchy(fileName, offset));
|
|
368
454
|
if (!calls) {
|
|
@@ -374,8 +460,9 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
374
460
|
},
|
|
375
461
|
async provideCallHierarchyIncomingCalls(item, token) {
|
|
376
462
|
return await worker(token, () => {
|
|
377
|
-
const
|
|
378
|
-
const
|
|
463
|
+
const uri = vscode_uri_1.URI.parse(item.uri);
|
|
464
|
+
const document = ctx.getTextDocument(uri);
|
|
465
|
+
const fileName = ctx.uriToFileName(uri);
|
|
379
466
|
const offset = document.offsetAt(item.selectionRange.start);
|
|
380
467
|
const calls = (0, shared_1.safeCall)(() => ctx.languageService.provideCallHierarchyIncomingCalls(fileName, offset));
|
|
381
468
|
if (!calls) {
|
|
@@ -387,8 +474,9 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
387
474
|
},
|
|
388
475
|
async provideCallHierarchyOutgoingCalls(item, token) {
|
|
389
476
|
return await worker(token, () => {
|
|
390
|
-
const
|
|
391
|
-
const
|
|
477
|
+
const uri = vscode_uri_1.URI.parse(item.uri);
|
|
478
|
+
const document = ctx.getTextDocument(uri);
|
|
479
|
+
const fileName = ctx.uriToFileName(uri);
|
|
392
480
|
const offset = document.offsetAt(item.selectionRange.start);
|
|
393
481
|
const calls = (0, shared_1.safeCall)(() => ctx.languageService.provideCallHierarchyOutgoingCalls(fileName, offset));
|
|
394
482
|
if (!calls) {
|
|
@@ -399,11 +487,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
399
487
|
}) ?? [];
|
|
400
488
|
},
|
|
401
489
|
provideDefinition(document, position, token) {
|
|
402
|
-
|
|
490
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
491
|
+
if (!isSemanticDocument(uri, document)) {
|
|
403
492
|
return;
|
|
404
493
|
}
|
|
405
494
|
return worker(token, () => {
|
|
406
|
-
const fileName = ctx.uriToFileName(
|
|
495
|
+
const fileName = ctx.uriToFileName(uri);
|
|
407
496
|
const offset = document.offsetAt(position);
|
|
408
497
|
const info = (0, shared_1.safeCall)(() => ctx.languageService.getDefinitionAndBoundSpan(fileName, offset));
|
|
409
498
|
if (!info) {
|
|
@@ -413,11 +502,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
413
502
|
});
|
|
414
503
|
},
|
|
415
504
|
provideTypeDefinition(document, position, token) {
|
|
416
|
-
|
|
505
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
506
|
+
if (!isSemanticDocument(uri, document)) {
|
|
417
507
|
return;
|
|
418
508
|
}
|
|
419
509
|
return worker(token, () => {
|
|
420
|
-
const fileName = ctx.uriToFileName(
|
|
510
|
+
const fileName = ctx.uriToFileName(uri);
|
|
421
511
|
const offset = document.offsetAt(position);
|
|
422
512
|
const entries = (0, shared_1.safeCall)(() => ctx.languageService.getTypeDefinitionAtPosition(fileName, offset));
|
|
423
513
|
if (!entries) {
|
|
@@ -433,11 +523,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
433
523
|
return provideDiagnosticsWorker(document, token, 'semantic');
|
|
434
524
|
},
|
|
435
525
|
provideHover(document, position, token) {
|
|
436
|
-
|
|
526
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
527
|
+
if (!isSemanticDocument(uri, document)) {
|
|
437
528
|
return;
|
|
438
529
|
}
|
|
439
530
|
return worker(token, () => {
|
|
440
|
-
const fileName = ctx.uriToFileName(
|
|
531
|
+
const fileName = ctx.uriToFileName(uri);
|
|
441
532
|
const offset = document.offsetAt(position);
|
|
442
533
|
const info = (0, shared_1.safeCall)(() => ctx.languageService.getQuickInfoAtPosition(fileName, offset));
|
|
443
534
|
if (!info) {
|
|
@@ -447,11 +538,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
447
538
|
});
|
|
448
539
|
},
|
|
449
540
|
provideImplementation(document, position, token) {
|
|
450
|
-
|
|
541
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
542
|
+
if (!isSemanticDocument(uri, document)) {
|
|
451
543
|
return;
|
|
452
544
|
}
|
|
453
545
|
return worker(token, () => {
|
|
454
|
-
const fileName = ctx.uriToFileName(
|
|
546
|
+
const fileName = ctx.uriToFileName(uri);
|
|
455
547
|
const offset = document.offsetAt(position);
|
|
456
548
|
const entries = (0, shared_1.safeCall)(() => ctx.languageService.getImplementationAtPosition(fileName, offset));
|
|
457
549
|
if (!entries) {
|
|
@@ -461,11 +553,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
461
553
|
});
|
|
462
554
|
},
|
|
463
555
|
provideReferences(document, position, referenceContext, token) {
|
|
464
|
-
|
|
556
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
557
|
+
if (!isSemanticDocument(uri, document, true)) {
|
|
465
558
|
return;
|
|
466
559
|
}
|
|
467
560
|
return worker(token, () => {
|
|
468
|
-
const fileName = ctx.uriToFileName(
|
|
561
|
+
const fileName = ctx.uriToFileName(uri);
|
|
469
562
|
const offset = document.offsetAt(position);
|
|
470
563
|
const references = (0, shared_1.safeCall)(() => ctx.languageService.findReferences(fileName, offset));
|
|
471
564
|
if (!references) {
|
|
@@ -490,11 +583,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
490
583
|
});
|
|
491
584
|
},
|
|
492
585
|
provideFileReferences(document, token) {
|
|
493
|
-
|
|
586
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
587
|
+
if (!isSemanticDocument(uri, document, true)) {
|
|
494
588
|
return;
|
|
495
589
|
}
|
|
496
590
|
return worker(token, () => {
|
|
497
|
-
const fileName = ctx.uriToFileName(
|
|
591
|
+
const fileName = ctx.uriToFileName(uri);
|
|
498
592
|
const entries = (0, shared_1.safeCall)(() => ctx.languageService.getFileReferences(fileName));
|
|
499
593
|
if (!entries) {
|
|
500
594
|
return [];
|
|
@@ -503,11 +597,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
503
597
|
});
|
|
504
598
|
},
|
|
505
599
|
provideDocumentHighlights(document, position, token) {
|
|
506
|
-
|
|
600
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
601
|
+
if (!isSemanticDocument(uri, document)) {
|
|
507
602
|
return;
|
|
508
603
|
}
|
|
509
604
|
return worker(token, () => {
|
|
510
|
-
const fileName = ctx.uriToFileName(
|
|
605
|
+
const fileName = ctx.uriToFileName(uri);
|
|
511
606
|
const offset = document.offsetAt(position);
|
|
512
607
|
const highlights = (0, shared_1.safeCall)(() => ctx.languageService.getDocumentHighlights(fileName, offset, [fileName]));
|
|
513
608
|
if (!highlights) {
|
|
@@ -523,11 +618,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
523
618
|
});
|
|
524
619
|
},
|
|
525
620
|
provideDocumentSemanticTokens(document, range, legend, token) {
|
|
526
|
-
|
|
621
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
622
|
+
if (!isSemanticDocument(uri, document)) {
|
|
527
623
|
return;
|
|
528
624
|
}
|
|
529
625
|
return worker(token, () => {
|
|
530
|
-
return getDocumentSemanticTokens(document, range, legend);
|
|
626
|
+
return getDocumentSemanticTokens(uri, document, range, legend);
|
|
531
627
|
});
|
|
532
628
|
},
|
|
533
629
|
provideWorkspaceSymbols(query, token) {
|
|
@@ -559,13 +655,14 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
559
655
|
});
|
|
560
656
|
},
|
|
561
657
|
provideSelectionRanges(document, positions, token) {
|
|
562
|
-
|
|
658
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
659
|
+
if (!isSemanticDocument(uri, document)) {
|
|
563
660
|
return;
|
|
564
661
|
}
|
|
565
662
|
return worker(token, () => {
|
|
566
663
|
return positions
|
|
567
664
|
.map(position => {
|
|
568
|
-
const fileName = ctx.uriToFileName(
|
|
665
|
+
const fileName = ctx.uriToFileName(uri);
|
|
569
666
|
const offset = document.offsetAt(position);
|
|
570
667
|
const range = (0, shared_1.safeCall)(() => ctx.languageService.getSmartSelectionRange(fileName, offset));
|
|
571
668
|
if (!range) {
|
|
@@ -577,7 +674,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
577
674
|
});
|
|
578
675
|
},
|
|
579
676
|
provideSignatureHelp(document, position, context, token) {
|
|
580
|
-
|
|
677
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
678
|
+
if (!isSemanticDocument(uri, document)) {
|
|
581
679
|
return;
|
|
582
680
|
}
|
|
583
681
|
return worker(token, () => {
|
|
@@ -599,7 +697,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
599
697
|
triggerCharacter: context.triggerCharacter,
|
|
600
698
|
};
|
|
601
699
|
}
|
|
602
|
-
const fileName = ctx.uriToFileName(
|
|
700
|
+
const fileName = ctx.uriToFileName(uri);
|
|
603
701
|
const offset = document.offsetAt(position);
|
|
604
702
|
const helpItems = (0, shared_1.safeCall)(() => ctx.languageService.getSignatureHelpItems(fileName, offset, options));
|
|
605
703
|
if (!helpItems) {
|
|
@@ -635,14 +733,15 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
635
733
|
},
|
|
636
734
|
};
|
|
637
735
|
async function provideDiagnosticsWorker(document, token, mode) {
|
|
638
|
-
|
|
736
|
+
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
737
|
+
if (!isSemanticDocument(uri, document)) {
|
|
639
738
|
return;
|
|
640
739
|
}
|
|
641
740
|
if (!await isValidationEnabled(document, context)) {
|
|
642
741
|
return;
|
|
643
742
|
}
|
|
644
743
|
return await worker(token, () => {
|
|
645
|
-
const fileName = ctx.uriToFileName(
|
|
744
|
+
const fileName = ctx.uriToFileName(uri);
|
|
646
745
|
const program = ctx.languageService.getProgram();
|
|
647
746
|
const sourceFile = program?.getSourceFile(fileName);
|
|
648
747
|
if (!program || !sourceFile) {
|
|
@@ -675,8 +774,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
675
774
|
function getEmitDeclarations(compilerOptions) {
|
|
676
775
|
return !!(compilerOptions.declaration || compilerOptions.composite);
|
|
677
776
|
}
|
|
678
|
-
function isSemanticDocument(document, withJson = false) {
|
|
679
|
-
const virtualScript = getVirtualScriptByUri(
|
|
777
|
+
function isSemanticDocument(uri, document, withJson = false) {
|
|
778
|
+
const virtualScript = getVirtualScriptByUri(uri);
|
|
680
779
|
if (virtualScript) {
|
|
681
780
|
return true;
|
|
682
781
|
}
|
|
@@ -688,7 +787,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
688
787
|
async function worker(token, fn) {
|
|
689
788
|
let result;
|
|
690
789
|
let oldSysVersion;
|
|
691
|
-
let newSysVersion = await
|
|
790
|
+
let newSysVersion = await sys.sync?.();
|
|
692
791
|
do {
|
|
693
792
|
oldSysVersion = newSysVersion;
|
|
694
793
|
try {
|
|
@@ -698,7 +797,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
698
797
|
console.warn(err);
|
|
699
798
|
break;
|
|
700
799
|
}
|
|
701
|
-
newSysVersion = await
|
|
800
|
+
newSysVersion = await sys.sync?.();
|
|
702
801
|
} while (newSysVersion !== oldSysVersion && !token.isCancellationRequested);
|
|
703
802
|
return result;
|
|
704
803
|
}
|
|
@@ -708,7 +807,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
708
807
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
709
808
|
if (virtualCode && sourceScript?.generated?.languagePlugin.typescript) {
|
|
710
809
|
const { getServiceScript, getExtraServiceScripts } = sourceScript.generated?.languagePlugin.typescript;
|
|
711
|
-
const sourceFileName =
|
|
810
|
+
const sourceFileName = asFileName(sourceScript.id);
|
|
712
811
|
if (getServiceScript(sourceScript.generated.root)?.code === virtualCode) {
|
|
713
812
|
return {
|
|
714
813
|
fileName: sourceFileName,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ProviderResult,
|
|
1
|
+
import type { ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import type * as ts from 'typescript';
|
|
4
4
|
export declare function getLanguageServiceByDocument(ts: typeof import('typescript'), document: TextDocument): {
|
|
5
5
|
languageService: ts.LanguageService;
|
|
6
6
|
fileName: string;
|
|
7
7
|
};
|
|
8
|
-
export declare function create(ts: typeof import('typescript'), { isFormattingEnabled,
|
|
9
|
-
isFormattingEnabled?(document: TextDocument, context:
|
|
10
|
-
isAutoClosingTagsEnabled?(document: TextDocument, context:
|
|
8
|
+
export declare function create(ts: typeof import('typescript'), { isFormattingEnabled, }?: {
|
|
9
|
+
isFormattingEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
|
|
10
|
+
isAutoClosingTagsEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
|
|
11
11
|
}): LanguageServicePlugin;
|
|
12
12
|
//# sourceMappingURL=syntactic.d.ts.map
|
package/lib/plugins/syntactic.js
CHANGED
|
@@ -32,23 +32,32 @@ function getLanguageServiceByDocument(ts, document) {
|
|
|
32
32
|
exports.getLanguageServiceByDocument = getLanguageServiceByDocument;
|
|
33
33
|
function create(ts, { isFormattingEnabled = async (document, context) => {
|
|
34
34
|
return await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format.enable') ?? true;
|
|
35
|
-
}, isAutoClosingTagsEnabled = async (document, context) => {
|
|
36
|
-
return await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.autoClosingTags') ?? true;
|
|
37
35
|
}, } = {}) {
|
|
38
36
|
return {
|
|
39
37
|
name: 'typescript-syntactic',
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
capabilities: {
|
|
39
|
+
autoInsertionProvider: {
|
|
40
|
+
triggerCharacters: ['>', '>'],
|
|
41
|
+
configurationSections: ['javascript.autoClosingTags', 'typescript.autoClosingTags'],
|
|
42
|
+
},
|
|
43
|
+
foldingRangeProvider: true,
|
|
44
|
+
documentSymbolProvider: true,
|
|
45
|
+
documentFormattingProvider: true,
|
|
46
|
+
documentOnTypeFormattingProvider: {
|
|
47
|
+
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
|
|
48
|
+
triggerCharacters: [';', '}', '\n'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
42
51
|
create(context) {
|
|
43
52
|
return {
|
|
44
|
-
async
|
|
53
|
+
async provideAutoInsertSnippet(document, selection, change) {
|
|
45
54
|
// selection must at end of change
|
|
46
55
|
if (document.offsetAt(selection) !== change.rangeOffset + change.text.length) {
|
|
47
56
|
return;
|
|
48
57
|
}
|
|
49
58
|
if ((document.languageId === 'javascriptreact' || document.languageId === 'typescriptreact')
|
|
50
59
|
&& change.text.endsWith('>')
|
|
51
|
-
&& await
|
|
60
|
+
&& (await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.autoClosingTags') ?? true)) {
|
|
52
61
|
const { languageService, fileName } = getLanguageServiceByDocument(ts, document);
|
|
53
62
|
const close = languageService.getJsxClosingTagAtPosition(fileName, document.offsetAt(selection));
|
|
54
63
|
if (close) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as vscode from '@volar/language-service';
|
|
2
|
-
import type { SharedContext } from './types';
|
|
3
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
+
import type { URI } from 'vscode-uri';
|
|
4
|
+
import type { SharedContext } from './types';
|
|
4
5
|
export interface FixAllData {
|
|
5
6
|
type: 'fixAll';
|
|
6
7
|
uri: string;
|
|
@@ -24,5 +25,5 @@ export interface OrganizeImportsData {
|
|
|
24
25
|
fileName: string;
|
|
25
26
|
}
|
|
26
27
|
export type Data = FixAllData | RefactorData | OrganizeImportsData;
|
|
27
|
-
export declare function register(ctx: SharedContext): (document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, formattingOptions: vscode.FormattingOptions | undefined) => Promise<vscode.CodeAction[]>;
|
|
28
|
+
export declare function register(ctx: SharedContext): (uri: URI, document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, formattingOptions: vscode.FormattingOptions | undefined) => Promise<vscode.CodeAction[]>;
|
|
28
29
|
//# sourceMappingURL=codeAction.d.ts.map
|
|
@@ -5,8 +5,8 @@ const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
|
|
|
5
5
|
const getUserPreferences_1 = require("../configs/getUserPreferences");
|
|
6
6
|
const shared_1 = require("../shared");
|
|
7
7
|
const fixNames = require("../utils/fixNames");
|
|
8
|
-
const codeActionResolve_1 = require("./codeActionResolve");
|
|
9
8
|
const lspConverters_1 = require("../utils/lspConverters");
|
|
9
|
+
const codeActionResolve_1 = require("./codeActionResolve");
|
|
10
10
|
const renameCommandRefactors = new Set([
|
|
11
11
|
'refactor.rewrite.property.generateAccessors',
|
|
12
12
|
'refactor.extract.type',
|
|
@@ -30,12 +30,12 @@ function register(ctx) {
|
|
|
30
30
|
resolveCommandSupport = true;
|
|
31
31
|
resolveEditSupport = true;
|
|
32
32
|
}
|
|
33
|
-
return async (document, range, context, formattingOptions) => {
|
|
33
|
+
return async (uri, document, range, context, formattingOptions) => {
|
|
34
34
|
const [formatOptions, preferences] = await Promise.all([
|
|
35
35
|
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
|
|
36
36
|
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
37
37
|
]);
|
|
38
|
-
const fileName = ctx.uriToFileName(
|
|
38
|
+
const fileName = ctx.uriToFileName(uri);
|
|
39
39
|
const start = document.offsetAt(range.start);
|
|
40
40
|
const end = document.offsetAt(range.end);
|
|
41
41
|
let result = [];
|
|
@@ -5,10 +5,11 @@ const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
|
|
|
5
5
|
const getUserPreferences_1 = require("../configs/getUserPreferences");
|
|
6
6
|
const shared_1 = require("../shared");
|
|
7
7
|
const lspConverters_1 = require("../utils/lspConverters");
|
|
8
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
8
9
|
function register(ctx) {
|
|
9
10
|
return async (codeAction, formattingOptions) => {
|
|
10
11
|
const data = codeAction.data;
|
|
11
|
-
const document = ctx.getTextDocument(data.uri);
|
|
12
|
+
const document = ctx.getTextDocument(vscode_uri_1.URI.parse(data.uri));
|
|
12
13
|
const [formatOptions, preferences] = await Promise.all([
|
|
13
14
|
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
|
|
14
15
|
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as vscode from '@volar/language-service';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import type { SharedContext } from './types';
|
|
4
|
-
|
|
4
|
+
import type { URI } from 'vscode-uri';
|
|
5
|
+
export declare function register(ts: typeof import('typescript'), ctx: SharedContext): (uri: URI, document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend) => [number, number, number, number, number][] | undefined;
|
|
5
6
|
//# sourceMappingURL=semanticTokens.d.ts.map
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.register = void 0;
|
|
4
4
|
const shared_1 = require("../shared");
|
|
5
5
|
function register(ts, ctx) {
|
|
6
|
-
return (document, range, legend) => {
|
|
7
|
-
const fileName = ctx.uriToFileName(
|
|
6
|
+
return (uri, document, range, legend) => {
|
|
7
|
+
const fileName = ctx.uriToFileName(uri);
|
|
8
8
|
const start = range ? document.offsetAt(range.start) : 0;
|
|
9
9
|
const length = range ? (document.offsetAt(range.end) - start) : document.getText().length;
|
|
10
10
|
if (ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested()) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageServiceContext } from '@volar/language-service';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
|
|
4
|
+
import type { URI } from 'vscode-uri';
|
|
5
|
+
export type SharedContext = LanguageServiceContext & {
|
|
5
6
|
languageServiceHost: ts.LanguageServiceHost;
|
|
6
7
|
languageService: ts.LanguageService;
|
|
7
|
-
getTextDocument: (uri:
|
|
8
|
-
uriToFileName: (uri:
|
|
9
|
-
fileNameToUri: (fileName: string) =>
|
|
8
|
+
getTextDocument: (uri: URI) => TextDocument | undefined;
|
|
9
|
+
uriToFileName: (uri: URI) => string;
|
|
10
|
+
fileNameToUri: (fileName: string) => URI;
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type * as vscode from '@volar/language-service';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
import type { URI } from 'vscode-uri';
|
|
4
5
|
import type { SharedContext } from '../semanticFeatures/types';
|
|
5
|
-
export declare function convertDiagnostic(diag: ts.Diagnostic, document: TextDocument, fileNameToUri: (fileName: string) =>
|
|
6
|
-
export declare function applyCompletionEntryDetails(ts: typeof import('typescript'), item: vscode.CompletionItem, data: ts.CompletionEntryDetails, document: TextDocument, fileNameToUri: (fileName: string) =>
|
|
6
|
+
export declare function convertDiagnostic(diag: ts.Diagnostic, document: TextDocument, fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): vscode.Diagnostic | undefined;
|
|
7
|
+
export declare function applyCompletionEntryDetails(ts: typeof import('typescript'), item: vscode.CompletionItem, data: ts.CompletionEntryDetails, document: TextDocument, fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): void;
|
|
7
8
|
export declare function convertCompletionInfo<T>(ts: typeof import('typescript'), completionContext: ts.CompletionInfo, document: TextDocument, position: vscode.Position, createData: (tsEntry: ts.CompletionEntry) => T): vscode.CompletionList;
|
|
8
9
|
export declare function getLineText(document: TextDocument, line: number): string;
|
|
9
10
|
export declare function convertNavigateToItem(item: ts.NavigateToItem, document: TextDocument): vscode.WorkspaceSymbol;
|
|
10
11
|
export declare function convertInlayHint(hint: ts.InlayHint, document: TextDocument): vscode.InlayHint;
|
|
11
12
|
export declare function convertHighlightSpan(span: ts.HighlightSpan, document: TextDocument): vscode.DocumentHighlight;
|
|
12
13
|
export declare function convertSelectionRange(range: ts.SelectionRange, document: TextDocument): vscode.SelectionRange;
|
|
13
|
-
export declare function convertFileTextChanges(changes: readonly ts.FileTextChanges[], fileNameToUri: (fileName: string) =>
|
|
14
|
-
export declare function convertRenameLocations(newText: string, locations: readonly ts.RenameLocation[], fileNameToUri: (fileName: string) =>
|
|
15
|
-
export declare function convertQuickInfo(ts: typeof import('typescript'), info: ts.QuickInfo, document: TextDocument, fileNameToUri: (fileName: string) =>
|
|
14
|
+
export declare function convertFileTextChanges(changes: readonly ts.FileTextChanges[], fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): vscode.WorkspaceEdit;
|
|
15
|
+
export declare function convertRenameLocations(newText: string, locations: readonly ts.RenameLocation[], fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): vscode.WorkspaceEdit;
|
|
16
|
+
export declare function convertQuickInfo(ts: typeof import('typescript'), info: ts.QuickInfo, document: TextDocument, fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): vscode.Hover;
|
|
16
17
|
export declare function convertNavTree(item: ts.NavigationTree, document: TextDocument): vscode.DocumentSymbol[];
|
|
17
18
|
export declare function convertOutliningSpan(outliningSpan: ts.OutliningSpan, document: TextDocument): vscode.FoldingRange;
|
|
18
19
|
export declare function convertOutliningSpanKind(kind: ts.OutliningSpanKind): vscode.FoldingRangeKind | undefined;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertTextSpan = exports.convertDocumentSpantoLocationLink = exports.convertDefinitionInfoAndBoundSpan = exports.convertDocumentSpanToLocation = exports.convertCallHierarchyItem = exports.convertCallHierarchyOutgoingCall = exports.convertCallHierarchyIncomingCall = exports.convertTextChange = exports.convertOutliningSpanKind = exports.convertOutliningSpan = exports.convertNavTree = exports.convertQuickInfo = exports.convertRenameLocations = exports.convertFileTextChanges = exports.convertSelectionRange = exports.convertHighlightSpan = exports.convertInlayHint = exports.convertNavigateToItem = exports.getLineText = exports.convertCompletionInfo = exports.applyCompletionEntryDetails = exports.convertDiagnostic = void 0;
|
|
4
4
|
const path = require("path-browserify");
|
|
5
|
+
const semver = require("semver");
|
|
5
6
|
const PConst = require("../protocol.const");
|
|
6
7
|
const shared_1 = require("../shared");
|
|
7
8
|
const modifiers_1 = require("../utils/modifiers");
|
|
8
9
|
const previewer = require("../utils/previewer");
|
|
9
10
|
const typeConverters = require("../utils/typeConverters");
|
|
10
|
-
const semver = require("semver");
|
|
11
11
|
// diagnostics
|
|
12
12
|
function convertDiagnostic(diag, document, fileNameToUri, getTextDocument) {
|
|
13
13
|
if (diag.start === undefined) {
|
|
@@ -510,10 +510,10 @@ function convertFileTextChanges(changes, fileNameToUri, getTextDocument) {
|
|
|
510
510
|
}
|
|
511
511
|
const uri = fileNameToUri(change.fileName);
|
|
512
512
|
if (change.isNewFile) {
|
|
513
|
-
workspaceEdit.documentChanges.push({ kind: 'create', uri });
|
|
513
|
+
workspaceEdit.documentChanges.push({ kind: 'create', uri: uri.toString() });
|
|
514
514
|
workspaceEdit.documentChanges.push({
|
|
515
515
|
textDocument: {
|
|
516
|
-
uri,
|
|
516
|
+
uri: uri.toString(),
|
|
517
517
|
version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
|
|
518
518
|
},
|
|
519
519
|
edits: change.textChanges.map(edit => ({
|
|
@@ -529,7 +529,7 @@ function convertFileTextChanges(changes, fileNameToUri, getTextDocument) {
|
|
|
529
529
|
const doc = getTextDocument(uri);
|
|
530
530
|
workspaceEdit.documentChanges.push({
|
|
531
531
|
textDocument: {
|
|
532
|
-
uri,
|
|
532
|
+
uri: uri.toString(),
|
|
533
533
|
version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
|
|
534
534
|
},
|
|
535
535
|
edits: change.textChanges.map(edit => convertTextChange(edit, doc)),
|
|
@@ -548,8 +548,8 @@ function convertRenameLocations(newText, locations, fileNameToUri, getTextDocume
|
|
|
548
548
|
}
|
|
549
549
|
const uri = fileNameToUri(location.fileName);
|
|
550
550
|
const doc = getTextDocument(uri);
|
|
551
|
-
if (!workspaceEdit.changes[uri]) {
|
|
552
|
-
workspaceEdit.changes[uri] = [];
|
|
551
|
+
if (!workspaceEdit.changes[uri.toString()]) {
|
|
552
|
+
workspaceEdit.changes[uri.toString()] = [];
|
|
553
553
|
}
|
|
554
554
|
let _newText = newText;
|
|
555
555
|
if (location.prefixText) {
|
|
@@ -558,7 +558,7 @@ function convertRenameLocations(newText, locations, fileNameToUri, getTextDocume
|
|
|
558
558
|
if (location.suffixText) {
|
|
559
559
|
_newText = _newText + location.suffixText;
|
|
560
560
|
}
|
|
561
|
-
workspaceEdit.changes[uri].push({
|
|
561
|
+
workspaceEdit.changes[uri.toString()].push({
|
|
562
562
|
newText: _newText,
|
|
563
563
|
range: convertTextSpan(location.textSpan, doc),
|
|
564
564
|
});
|
|
@@ -736,7 +736,7 @@ function convertCallHierarchyItem(item, ctx) {
|
|
|
736
736
|
kind: typeConverters.SymbolKind.fromProtocolScriptElementKind(item.kind),
|
|
737
737
|
name,
|
|
738
738
|
detail,
|
|
739
|
-
uri,
|
|
739
|
+
uri: uri.toString(),
|
|
740
740
|
range: convertTextSpan(item.span, document),
|
|
741
741
|
selectionRange: convertTextSpan(item.selectionSpan, document),
|
|
742
742
|
};
|
|
@@ -756,7 +756,7 @@ function convertDocumentSpanToLocation(documentSpan, ctx) {
|
|
|
756
756
|
const document = ctx.getTextDocument(uri);
|
|
757
757
|
const range = convertTextSpan(documentSpan.textSpan, document);
|
|
758
758
|
return {
|
|
759
|
-
uri,
|
|
759
|
+
uri: uri.toString(),
|
|
760
760
|
range,
|
|
761
761
|
};
|
|
762
762
|
}
|
|
@@ -788,7 +788,7 @@ function convertDocumentSpantoLocationLink(documentSpan, ctx) {
|
|
|
788
788
|
? convertTextSpan(documentSpan.originalTextSpan, document)
|
|
789
789
|
: undefined;
|
|
790
790
|
return {
|
|
791
|
-
targetUri,
|
|
791
|
+
targetUri: targetUri.toString(),
|
|
792
792
|
targetRange,
|
|
793
793
|
targetSelectionRange,
|
|
794
794
|
originSelectionRange,
|
package/lib/utils/previewer.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
3
|
+
import type { URI } from 'vscode-uri';
|
|
4
|
+
export declare function plainWithLinks(parts: readonly ts.server.protocol.SymbolDisplayPart[] | string, fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): string;
|
|
5
|
+
export declare function tagsMarkdownPreview(tags: readonly ts.JSDocTagInfo[], fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): string;
|
|
6
|
+
export declare function markdownDocumentation(documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): string;
|
|
7
|
+
export declare function addMarkdownDocumentation(out: string, documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => URI, getTextDocument: (uri: URI) => TextDocument | undefined): string;
|
|
7
8
|
//# sourceMappingURL=previewer.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
export declare namespace SymbolKind {
|
|
3
|
-
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 |
|
|
3
|
+
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 10 | 22 | 11 | 6 | 7 | 13 | 12 | 9 | 26 | 15;
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=typeConverters.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Integrate TypeScript into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/typescript",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
"semver": "^7.5.4",
|
|
33
33
|
"typescript-auto-import-cache": "^0.3.1",
|
|
34
34
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
35
|
-
"vscode-nls": "^5.2.0"
|
|
35
|
+
"vscode-nls": "^5.2.0",
|
|
36
|
+
"vscode-uri": "^3.0.8"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
"@volar/language-service": "~2.
|
|
39
|
+
"@volar/language-service": "~2.3.0-alpha.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependenciesMeta": {
|
|
41
42
|
"@volar/language-service": {
|
|
42
43
|
"optional": true
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "6a80c92133e154907a79eefa05603f63994214c3"
|
|
46
47
|
}
|