volar-service-typescript 0.0.47 → 0.0.49

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.
@@ -1,5 +1,5 @@
1
- import type { FormattingOptions, ServiceContext } from '@volar/language-service';
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: ServiceContext, document: TextDocument, options: FormattingOptions | undefined): Promise<ts.FormatCodeSettings>;
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 { ServiceContext } from '@volar/language-service';
4
- export declare function getUserPreferences(ctx: ServiceContext, document: TextDocument): Promise<ts.UserPreferences>;
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 documentUri = ctx.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
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.startsWith('file://'),
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
- triggerCharacters: ['@'],
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
- triggerCharacters: ['*'],
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, ServiceContext, LanguageServicePlugin } from '@volar/language-service';
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: string) => string;
8
- 'typescript/documentUri': (fileName: string) => 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: ServiceContext): ProviderResult<boolean>;
23
- isSuggestionsEnabled?(document: TextDocument, context: ServiceContext): ProviderResult<boolean>;
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
@@ -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,17 +29,142 @@ function create(ts, { isValidationEnabled = async (document, context) => {
28
29
  }, } = {}) {
29
30
  return {
30
31
  name: 'typescript-semantic',
31
- triggerCharacters: getBasicTriggerCharacters(ts.version),
32
- signatureHelpTriggerCharacters: ['(', ',', '<'],
33
- signatureHelpRetriggerCharacters: [')'],
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 { projectHost, languageServiceHost } = context.language.typescript;
39
- const sys = projectHost;
118
+ const { sys, languageServiceHost, asFileName, asScriptId, getExtraServiceScript } = 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;
121
+ const ctx = {
122
+ ...context,
123
+ languageServiceHost,
124
+ languageService,
125
+ uriToFileName(uri) {
126
+ const virtualScript = getVirtualScriptByUri(uri);
127
+ if (virtualScript) {
128
+ return virtualScript.fileName;
129
+ }
130
+ return asFileName(uri);
131
+ },
132
+ fileNameToUri(fileName) {
133
+ const extraServiceScript = getExtraServiceScript(fileName);
134
+ if (extraServiceScript) {
135
+ return context.encodeEmbeddedDocumentUri(extraServiceScript[0].id, extraServiceScript[1].code.id);
136
+ }
137
+ const uri = asScriptId(fileName);
138
+ const sourceScript = context.language.scripts.get(uri);
139
+ const serviceScript = sourceScript?.generated?.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
140
+ if (sourceScript && serviceScript) {
141
+ return context.encodeEmbeddedDocumentUri(sourceScript.id, serviceScript.code.id);
142
+ }
143
+ return uri;
144
+ },
145
+ getTextDocument(uri) {
146
+ const decoded = context.decodeEmbeddedDocumentUri(uri);
147
+ if (decoded) {
148
+ const sourceScript = context.language.scripts.get(decoded[0]);
149
+ const virtualCode = sourceScript?.generated?.embeddedCodes.get(decoded[1]);
150
+ if (virtualCode) {
151
+ return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
152
+ }
153
+ }
154
+ else {
155
+ const sourceFile = context.language.scripts.get(uri);
156
+ if (sourceFile) {
157
+ return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
158
+ }
159
+ }
160
+ },
161
+ };
162
+ const getCodeActions = codeActions.register(ctx);
163
+ const doCodeActionResolve = codeActionResolve.register(ctx);
164
+ const getDocumentSemanticTokens = semanticTokens.register(ts, ctx);
165
+ /* typescript-language-features is hardcode true */
166
+ const renameInfoOptions = { allowRenameOfImportPath: true };
167
+ let formattingOptions;
42
168
  if (created.setPreferences && context.env.getConfiguration) {
43
169
  updatePreferences();
44
170
  context.env.onDidChangeConfiguration?.(updatePreferences);
@@ -61,7 +187,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
61
187
  updateSourceScriptFileNames();
62
188
  }
63
189
  for (const change of params.changes) {
64
- const fileName = context.env.typescript.uriToFileName(change.uri);
190
+ const fileName = asFileName(vscode_uri_1.URI.parse(change.uri));
65
191
  if (sourceScriptNames.has(normalizeFileName(fileName))) {
66
192
  created.projectUpdated?.(languageServiceHost.getCurrentDirectory());
67
193
  }
@@ -70,7 +196,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
70
196
  function updateSourceScriptFileNames() {
71
197
  sourceScriptNames.clear();
72
198
  for (const fileName of languageServiceHost.getScriptFileNames()) {
73
- const uri = context.env.typescript.fileNameToUri(fileName);
199
+ const uri = ctx.fileNameToUri(fileName);
74
200
  const sourceScript = context.language.scripts.get(uri);
75
201
  if (sourceScript?.generated) {
76
202
  const tsCode = sourceScript.generated.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
@@ -84,56 +210,6 @@ function create(ts, { isValidationEnabled = async (document, context) => {
84
210
  }
85
211
  }
86
212
  }
87
- const ctx = {
88
- ...context,
89
- languageServiceHost,
90
- languageService,
91
- uriToFileName(uri) {
92
- const virtualScript = getVirtualScriptByUri(uri);
93
- if (virtualScript) {
94
- return virtualScript.fileName;
95
- }
96
- return context.env.typescript.uriToFileName(uri);
97
- },
98
- fileNameToUri(fileName) {
99
- const uri = context.env.typescript.fileNameToUri(fileName);
100
- const sourceScript = context.language.scripts.get(uri);
101
- const extraServiceScript = context.language.typescript.getExtraServiceScript(fileName);
102
- let virtualCode = extraServiceScript?.code;
103
- if (!virtualCode && sourceScript?.generated?.languagePlugin.typescript) {
104
- const serviceScript = sourceScript.generated.languagePlugin.typescript.getServiceScript(sourceScript.generated.root);
105
- if (serviceScript) {
106
- virtualCode = serviceScript.code;
107
- }
108
- }
109
- if (sourceScript && virtualCode) {
110
- return context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id);
111
- }
112
- return uri;
113
- },
114
- getTextDocument(uri) {
115
- const decoded = context.decodeEmbeddedDocumentUri(uri);
116
- if (decoded) {
117
- const sourceScript = context.language.scripts.get(decoded[0]);
118
- const virtualCode = sourceScript?.generated?.embeddedCodes.get(decoded[1]);
119
- if (virtualCode) {
120
- return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
121
- }
122
- }
123
- else {
124
- const sourceFile = context.language.scripts.get(uri);
125
- if (sourceFile) {
126
- return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
127
- }
128
- }
129
- },
130
- };
131
- const getCodeActions = codeActions.register(ctx);
132
- const doCodeActionResolve = codeActionResolve.register(ctx);
133
- const getDocumentSemanticTokens = semanticTokens.register(ts, ctx);
134
- /* typescript-language-features is hardcode true */
135
- const renameInfoOptions = { allowRenameOfImportPath: true };
136
- let formattingOptions;
137
213
  return {
138
214
  provide: {
139
215
  'typescript/languageService': () => languageService,
@@ -153,7 +229,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
153
229
  return undefined;
154
230
  },
155
231
  async provideCompletionItems(document, position, completeContext, token) {
156
- if (!isSemanticDocument(document)) {
232
+ const uri = vscode_uri_1.URI.parse(document.uri);
233
+ if (!isSemanticDocument(uri, document)) {
157
234
  return;
158
235
  }
159
236
  if (!await isSuggestionsEnabled(document, context)) {
@@ -161,7 +238,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
161
238
  }
162
239
  return await worker(token, async () => {
163
240
  const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
164
- const fileName = ctx.uriToFileName(document.uri);
241
+ const fileName = ctx.uriToFileName(uri);
165
242
  const offset = document.offsetAt(position);
166
243
  const info = (0, shared_1.safeCall)(() => ctx.languageService.getCompletionsAtPosition(fileName, offset, {
167
244
  ...preferences,
@@ -190,7 +267,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
190
267
  return item;
191
268
  }
192
269
  const { fileName, offset } = data;
193
- const document = ctx.getTextDocument(data.uri);
270
+ const uri = vscode_uri_1.URI.parse(data.uri);
271
+ const document = ctx.getTextDocument(uri);
194
272
  const [formatOptions, preferences] = await Promise.all([
195
273
  (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
196
274
  (0, getUserPreferences_1.getUserPreferences)(ctx, document),
@@ -262,11 +340,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
262
340
  }) ?? item;
263
341
  },
264
342
  provideRenameRange(document, position, token) {
265
- if (!isSemanticDocument(document)) {
343
+ const uri = vscode_uri_1.URI.parse(document.uri);
344
+ if (!isSemanticDocument(uri, document)) {
266
345
  return;
267
346
  }
268
347
  return worker(token, () => {
269
- const fileName = ctx.uriToFileName(document.uri);
348
+ const fileName = ctx.uriToFileName(uri);
270
349
  const offset = document.offsetAt(position);
271
350
  const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, renameInfoOptions));
272
351
  if (!renameInfo) {
@@ -279,11 +358,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
279
358
  });
280
359
  },
281
360
  provideRenameEdits(document, position, newName, token) {
282
- if (!isSemanticDocument(document, true)) {
361
+ const uri = vscode_uri_1.URI.parse(document.uri);
362
+ if (!isSemanticDocument(uri, document, true)) {
283
363
  return;
284
364
  }
285
365
  return worker(token, async () => {
286
- const fileName = ctx.uriToFileName(document.uri);
366
+ const fileName = ctx.uriToFileName(uri);
287
367
  const offset = document.offsetAt(position);
288
368
  const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, renameInfoOptions));
289
369
  if (!renameInfo?.canRename) {
@@ -319,19 +399,20 @@ function create(ts, { isValidationEnabled = async (document, context) => {
319
399
  }
320
400
  edits.documentChanges.push({
321
401
  kind: 'rename',
322
- oldUri: ctx.fileNameToUri(fileToRename),
323
- newUri: ctx.fileNameToUri(newFilePath),
402
+ oldUri: ctx.fileNameToUri(fileToRename).toString(),
403
+ newUri: ctx.fileNameToUri(newFilePath).toString(),
324
404
  });
325
405
  return edits;
326
406
  }
327
407
  });
328
408
  },
329
409
  provideCodeActions(document, range, context, token) {
330
- if (!isSemanticDocument(document)) {
410
+ const uri = vscode_uri_1.URI.parse(document.uri);
411
+ if (!isSemanticDocument(uri, document)) {
331
412
  return;
332
413
  }
333
414
  return worker(token, () => {
334
- return getCodeActions(document, range, context, formattingOptions);
415
+ return getCodeActions(uri, document, range, context, formattingOptions);
335
416
  });
336
417
  },
337
418
  async resolveCodeAction(codeAction, token) {
@@ -340,12 +421,13 @@ function create(ts, { isValidationEnabled = async (document, context) => {
340
421
  }) ?? codeAction;
341
422
  },
342
423
  provideInlayHints(document, range, token) {
343
- if (!isSemanticDocument(document)) {
424
+ const uri = vscode_uri_1.URI.parse(document.uri);
425
+ if (!isSemanticDocument(uri, document)) {
344
426
  return;
345
427
  }
346
428
  return worker(token, async () => {
347
429
  const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
348
- const fileName = ctx.uriToFileName(document.uri);
430
+ const fileName = ctx.uriToFileName(uri);
349
431
  const start = document.offsetAt(range.start);
350
432
  const end = document.offsetAt(range.end);
351
433
  const inlayHints = (0, shared_1.safeCall)(() => 'provideInlayHints' in ctx.languageService
@@ -358,11 +440,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
358
440
  });
359
441
  },
360
442
  provideCallHierarchyItems(document, position, token) {
361
- if (!isSemanticDocument(document)) {
443
+ const uri = vscode_uri_1.URI.parse(document.uri);
444
+ if (!isSemanticDocument(uri, document)) {
362
445
  return;
363
446
  }
364
447
  return worker(token, () => {
365
- const fileName = ctx.uriToFileName(document.uri);
448
+ const fileName = ctx.uriToFileName(uri);
366
449
  const offset = document.offsetAt(position);
367
450
  const calls = (0, shared_1.safeCall)(() => ctx.languageService.prepareCallHierarchy(fileName, offset));
368
451
  if (!calls) {
@@ -374,8 +457,9 @@ function create(ts, { isValidationEnabled = async (document, context) => {
374
457
  },
375
458
  async provideCallHierarchyIncomingCalls(item, token) {
376
459
  return await worker(token, () => {
377
- const document = ctx.getTextDocument(item.uri);
378
- const fileName = ctx.uriToFileName(item.uri);
460
+ const uri = vscode_uri_1.URI.parse(item.uri);
461
+ const document = ctx.getTextDocument(uri);
462
+ const fileName = ctx.uriToFileName(uri);
379
463
  const offset = document.offsetAt(item.selectionRange.start);
380
464
  const calls = (0, shared_1.safeCall)(() => ctx.languageService.provideCallHierarchyIncomingCalls(fileName, offset));
381
465
  if (!calls) {
@@ -387,8 +471,9 @@ function create(ts, { isValidationEnabled = async (document, context) => {
387
471
  },
388
472
  async provideCallHierarchyOutgoingCalls(item, token) {
389
473
  return await worker(token, () => {
390
- const document = ctx.getTextDocument(item.uri);
391
- const fileName = ctx.uriToFileName(item.uri);
474
+ const uri = vscode_uri_1.URI.parse(item.uri);
475
+ const document = ctx.getTextDocument(uri);
476
+ const fileName = ctx.uriToFileName(uri);
392
477
  const offset = document.offsetAt(item.selectionRange.start);
393
478
  const calls = (0, shared_1.safeCall)(() => ctx.languageService.provideCallHierarchyOutgoingCalls(fileName, offset));
394
479
  if (!calls) {
@@ -399,11 +484,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
399
484
  }) ?? [];
400
485
  },
401
486
  provideDefinition(document, position, token) {
402
- if (!isSemanticDocument(document)) {
487
+ const uri = vscode_uri_1.URI.parse(document.uri);
488
+ if (!isSemanticDocument(uri, document)) {
403
489
  return;
404
490
  }
405
491
  return worker(token, () => {
406
- const fileName = ctx.uriToFileName(document.uri);
492
+ const fileName = ctx.uriToFileName(uri);
407
493
  const offset = document.offsetAt(position);
408
494
  const info = (0, shared_1.safeCall)(() => ctx.languageService.getDefinitionAndBoundSpan(fileName, offset));
409
495
  if (!info) {
@@ -413,11 +499,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
413
499
  });
414
500
  },
415
501
  provideTypeDefinition(document, position, token) {
416
- if (!isSemanticDocument(document)) {
502
+ const uri = vscode_uri_1.URI.parse(document.uri);
503
+ if (!isSemanticDocument(uri, document)) {
417
504
  return;
418
505
  }
419
506
  return worker(token, () => {
420
- const fileName = ctx.uriToFileName(document.uri);
507
+ const fileName = ctx.uriToFileName(uri);
421
508
  const offset = document.offsetAt(position);
422
509
  const entries = (0, shared_1.safeCall)(() => ctx.languageService.getTypeDefinitionAtPosition(fileName, offset));
423
510
  if (!entries) {
@@ -433,11 +520,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
433
520
  return provideDiagnosticsWorker(document, token, 'semantic');
434
521
  },
435
522
  provideHover(document, position, token) {
436
- if (!isSemanticDocument(document)) {
523
+ const uri = vscode_uri_1.URI.parse(document.uri);
524
+ if (!isSemanticDocument(uri, document)) {
437
525
  return;
438
526
  }
439
527
  return worker(token, () => {
440
- const fileName = ctx.uriToFileName(document.uri);
528
+ const fileName = ctx.uriToFileName(uri);
441
529
  const offset = document.offsetAt(position);
442
530
  const info = (0, shared_1.safeCall)(() => ctx.languageService.getQuickInfoAtPosition(fileName, offset));
443
531
  if (!info) {
@@ -447,11 +535,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
447
535
  });
448
536
  },
449
537
  provideImplementation(document, position, token) {
450
- if (!isSemanticDocument(document)) {
538
+ const uri = vscode_uri_1.URI.parse(document.uri);
539
+ if (!isSemanticDocument(uri, document)) {
451
540
  return;
452
541
  }
453
542
  return worker(token, () => {
454
- const fileName = ctx.uriToFileName(document.uri);
543
+ const fileName = ctx.uriToFileName(uri);
455
544
  const offset = document.offsetAt(position);
456
545
  const entries = (0, shared_1.safeCall)(() => ctx.languageService.getImplementationAtPosition(fileName, offset));
457
546
  if (!entries) {
@@ -461,11 +550,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
461
550
  });
462
551
  },
463
552
  provideReferences(document, position, referenceContext, token) {
464
- if (!isSemanticDocument(document, true)) {
553
+ const uri = vscode_uri_1.URI.parse(document.uri);
554
+ if (!isSemanticDocument(uri, document, true)) {
465
555
  return;
466
556
  }
467
557
  return worker(token, () => {
468
- const fileName = ctx.uriToFileName(document.uri);
558
+ const fileName = ctx.uriToFileName(uri);
469
559
  const offset = document.offsetAt(position);
470
560
  const references = (0, shared_1.safeCall)(() => ctx.languageService.findReferences(fileName, offset));
471
561
  if (!references) {
@@ -490,11 +580,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
490
580
  });
491
581
  },
492
582
  provideFileReferences(document, token) {
493
- if (!isSemanticDocument(document, true)) {
583
+ const uri = vscode_uri_1.URI.parse(document.uri);
584
+ if (!isSemanticDocument(uri, document, true)) {
494
585
  return;
495
586
  }
496
587
  return worker(token, () => {
497
- const fileName = ctx.uriToFileName(document.uri);
588
+ const fileName = ctx.uriToFileName(uri);
498
589
  const entries = (0, shared_1.safeCall)(() => ctx.languageService.getFileReferences(fileName));
499
590
  if (!entries) {
500
591
  return [];
@@ -503,11 +594,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
503
594
  });
504
595
  },
505
596
  provideDocumentHighlights(document, position, token) {
506
- if (!isSemanticDocument(document)) {
597
+ const uri = vscode_uri_1.URI.parse(document.uri);
598
+ if (!isSemanticDocument(uri, document)) {
507
599
  return;
508
600
  }
509
601
  return worker(token, () => {
510
- const fileName = ctx.uriToFileName(document.uri);
602
+ const fileName = ctx.uriToFileName(uri);
511
603
  const offset = document.offsetAt(position);
512
604
  const highlights = (0, shared_1.safeCall)(() => ctx.languageService.getDocumentHighlights(fileName, offset, [fileName]));
513
605
  if (!highlights) {
@@ -523,11 +615,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
523
615
  });
524
616
  },
525
617
  provideDocumentSemanticTokens(document, range, legend, token) {
526
- if (!isSemanticDocument(document)) {
618
+ const uri = vscode_uri_1.URI.parse(document.uri);
619
+ if (!isSemanticDocument(uri, document)) {
527
620
  return;
528
621
  }
529
622
  return worker(token, () => {
530
- return getDocumentSemanticTokens(document, range, legend);
623
+ return getDocumentSemanticTokens(uri, document, range, legend);
531
624
  });
532
625
  },
533
626
  provideWorkspaceSymbols(query, token) {
@@ -559,13 +652,14 @@ function create(ts, { isValidationEnabled = async (document, context) => {
559
652
  });
560
653
  },
561
654
  provideSelectionRanges(document, positions, token) {
562
- if (!isSemanticDocument(document)) {
655
+ const uri = vscode_uri_1.URI.parse(document.uri);
656
+ if (!isSemanticDocument(uri, document)) {
563
657
  return;
564
658
  }
565
659
  return worker(token, () => {
566
660
  return positions
567
661
  .map(position => {
568
- const fileName = ctx.uriToFileName(document.uri);
662
+ const fileName = ctx.uriToFileName(uri);
569
663
  const offset = document.offsetAt(position);
570
664
  const range = (0, shared_1.safeCall)(() => ctx.languageService.getSmartSelectionRange(fileName, offset));
571
665
  if (!range) {
@@ -577,7 +671,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
577
671
  });
578
672
  },
579
673
  provideSignatureHelp(document, position, context, token) {
580
- if (!isSemanticDocument(document)) {
674
+ const uri = vscode_uri_1.URI.parse(document.uri);
675
+ if (!isSemanticDocument(uri, document)) {
581
676
  return;
582
677
  }
583
678
  return worker(token, () => {
@@ -599,7 +694,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
599
694
  triggerCharacter: context.triggerCharacter,
600
695
  };
601
696
  }
602
- const fileName = ctx.uriToFileName(document.uri);
697
+ const fileName = ctx.uriToFileName(uri);
603
698
  const offset = document.offsetAt(position);
604
699
  const helpItems = (0, shared_1.safeCall)(() => ctx.languageService.getSignatureHelpItems(fileName, offset, options));
605
700
  if (!helpItems) {
@@ -635,14 +730,15 @@ function create(ts, { isValidationEnabled = async (document, context) => {
635
730
  },
636
731
  };
637
732
  async function provideDiagnosticsWorker(document, token, mode) {
638
- if (!isSemanticDocument(document)) {
733
+ const uri = vscode_uri_1.URI.parse(document.uri);
734
+ if (!isSemanticDocument(uri, document)) {
639
735
  return;
640
736
  }
641
737
  if (!await isValidationEnabled(document, context)) {
642
738
  return;
643
739
  }
644
740
  return await worker(token, () => {
645
- const fileName = ctx.uriToFileName(document.uri);
741
+ const fileName = ctx.uriToFileName(uri);
646
742
  const program = ctx.languageService.getProgram();
647
743
  const sourceFile = program?.getSourceFile(fileName);
648
744
  if (!program || !sourceFile) {
@@ -675,8 +771,8 @@ function create(ts, { isValidationEnabled = async (document, context) => {
675
771
  function getEmitDeclarations(compilerOptions) {
676
772
  return !!(compilerOptions.declaration || compilerOptions.composite);
677
773
  }
678
- function isSemanticDocument(document, withJson = false) {
679
- const virtualScript = getVirtualScriptByUri(document.uri);
774
+ function isSemanticDocument(uri, document, withJson = false) {
775
+ const virtualScript = getVirtualScriptByUri(uri);
680
776
  if (virtualScript) {
681
777
  return true;
682
778
  }
@@ -688,7 +784,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
688
784
  async function worker(token, fn) {
689
785
  let result;
690
786
  let oldSysVersion;
691
- let newSysVersion = await projectHost.syncSystem?.();
787
+ let newSysVersion = await sys.sync?.();
692
788
  do {
693
789
  oldSysVersion = newSysVersion;
694
790
  try {
@@ -698,7 +794,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
698
794
  console.warn(err);
699
795
  break;
700
796
  }
701
- newSysVersion = await projectHost.syncSystem?.();
797
+ newSysVersion = await sys.sync?.();
702
798
  } while (newSysVersion !== oldSysVersion && !token.isCancellationRequested);
703
799
  return result;
704
800
  }
@@ -708,7 +804,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
708
804
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
709
805
  if (virtualCode && sourceScript?.generated?.languagePlugin.typescript) {
710
806
  const { getServiceScript, getExtraServiceScripts } = sourceScript.generated?.languagePlugin.typescript;
711
- const sourceFileName = context.env.typescript.uriToFileName(sourceScript.id);
807
+ const sourceFileName = asFileName(sourceScript.id);
712
808
  if (getServiceScript(sourceScript.generated.root)?.code === virtualCode) {
713
809
  return {
714
810
  fileName: sourceFileName,
@@ -1,12 +1,12 @@
1
- import type { ProviderResult, ServiceContext, LanguageServicePlugin } from '@volar/language-service';
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, isAutoClosingTagsEnabled, }?: {
9
- isFormattingEnabled?(document: TextDocument, context: ServiceContext): ProviderResult<boolean>;
10
- isAutoClosingTagsEnabled?(document: TextDocument, context: ServiceContext): ProviderResult<boolean>;
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
@@ -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
- // https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
41
- autoFormatTriggerCharacters: [';', '}', '\n'],
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 provideAutoInsertionEdit(document, selection, change) {
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 isAutoClosingTagsEnabled(document, context)) {
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(document.uri);
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
- export declare function register(ts: typeof import('typescript'), ctx: SharedContext): (document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend) => [number, number, number, number, number][] | undefined;
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(document.uri);
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 { ServiceContext } from '@volar/language-service';
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
- export type SharedContext = ServiceContext & {
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: string) => TextDocument | undefined;
8
- uriToFileName: (uri: string) => string;
9
- fileNameToUri: (fileName: string) => 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) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.Diagnostic | undefined;
6
- export declare function applyCompletionEntryDetails(ts: typeof import('typescript'), item: vscode.CompletionItem, data: ts.CompletionEntryDetails, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): void;
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) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.WorkspaceEdit;
14
- export declare function convertRenameLocations(newText: string, locations: readonly ts.RenameLocation[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.WorkspaceEdit;
15
- export declare function convertQuickInfo(ts: typeof import('typescript'), info: ts.QuickInfo, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.Hover;
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,
@@ -1,7 +1,8 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { TextDocument } from 'vscode-languageserver-textdocument';
3
- export declare function plainWithLinks(parts: readonly ts.server.protocol.SymbolDisplayPart[] | string, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
4
- export declare function tagsMarkdownPreview(tags: readonly ts.JSDocTagInfo[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
5
- export declare function markdownDocumentation(documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
6
- export declare function addMarkdownDocumentation(out: string, documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-typescript",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
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.2.3"
39
+ "@volar/language-service": "~2.3.0-alpha.1"
39
40
  },
40
41
  "peerDependenciesMeta": {
41
42
  "@volar/language-service": {
42
43
  "optional": true
43
44
  }
44
45
  },
45
- "gitHead": "d53f4dfa7007e77409af3ef28cc165e9940e7313"
46
+ "gitHead": "81275d75ab2adc03a643785a551ad31debd72866"
46
47
  }