@volar/language-service 2.3.0-alpha.5 → 2.3.0-alpha.7

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.
@@ -125,17 +125,19 @@ function register(context) {
125
125
  if (!virtualCode) {
126
126
  return [tsItem, tsRanges];
127
127
  }
128
- const map = context.documents.getSourceMap(virtualCode);
129
- let range = map.getSourceRange(tsItem.range);
130
- if (!range) {
131
- // TODO: <script> range
132
- range = {
133
- start: map.sourceDocument.positionAt(0),
134
- end: map.sourceDocument.positionAt(map.sourceDocument.getText().length),
135
- };
136
- }
137
- const selectionRange = map.getSourceRange(tsItem.selectionRange);
138
- if (selectionRange) {
128
+ for (const map of context.documents.getMaps(virtualCode)) {
129
+ let range = map.getSourceRange(tsItem.range);
130
+ if (!range) {
131
+ // TODO: <script> range
132
+ range = {
133
+ start: map.sourceDocument.positionAt(0),
134
+ end: map.sourceDocument.positionAt(map.sourceDocument.getText().length),
135
+ };
136
+ }
137
+ const selectionRange = map.getSourceRange(tsItem.selectionRange);
138
+ if (!selectionRange) {
139
+ continue;
140
+ }
139
141
  const vueRanges = tsRanges.map(tsRange => map.getSourceRange(tsRange)).filter(common_1.notEmpty);
140
142
  const vueItem = {
141
143
  ...tsItem,
@@ -30,28 +30,29 @@ function register(context) {
30
30
  if (!virtualCode) {
31
31
  continue;
32
32
  }
33
- const map = context.documents.getSourceMap(virtualCode);
34
- for (const mapped of map.getGeneratedPositions(position, data => (0, language_core_1.isCompletionEnabled)(data))) {
35
- if (!cacheData.plugin.provideCompletionItems) {
36
- continue;
33
+ for (const map of context.documents.getMaps(virtualCode)) {
34
+ for (const mapped of map.getGeneratedPositions(position, data => (0, language_core_1.isCompletionEnabled)(data))) {
35
+ if (!cacheData.plugin.provideCompletionItems) {
36
+ continue;
37
+ }
38
+ cacheData.list = await cacheData.plugin.provideCompletionItems(map.embeddedDocument, mapped, completionContext, token);
39
+ if (!cacheData.list) {
40
+ continue;
41
+ }
42
+ for (const item of cacheData.list.items) {
43
+ item.data = {
44
+ uri: uri.toString(),
45
+ original: {
46
+ additionalTextEdits: item.additionalTextEdits,
47
+ textEdit: item.textEdit,
48
+ data: item.data,
49
+ },
50
+ pluginIndex: pluginIndex,
51
+ embeddedDocumentUri: map.embeddedDocument.uri,
52
+ };
53
+ }
54
+ cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range => map.getSourceRange(range), map.embeddedDocument, context);
37
55
  }
38
- cacheData.list = await cacheData.plugin.provideCompletionItems(map.embeddedDocument, mapped, completionContext, token);
39
- if (!cacheData.list) {
40
- continue;
41
- }
42
- for (const item of cacheData.list.items) {
43
- item.data = {
44
- uri: uri.toString(),
45
- original: {
46
- additionalTextEdits: item.additionalTextEdits,
47
- textEdit: item.textEdit,
48
- data: item.data,
49
- },
50
- pluginIndex: pluginIndex,
51
- embeddedDocumentUri: map.embeddedDocument.uri,
52
- };
53
- }
54
- cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range => map.getSourceRange(range), map.embeddedDocument, context);
55
56
  }
56
57
  }
57
58
  else {
@@ -65,39 +65,41 @@ function register(context, apiName, isValidPosition) {
65
65
  }
66
66
  link.originSelectionRange = originSelectionRange;
67
67
  }
68
+ let foundTargetSelectionRange = false;
68
69
  const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(link.targetUri));
69
70
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
70
71
  const targetVirtualFile = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
71
72
  if (targetVirtualFile) {
72
- const targetSourceMap = context.documents.getSourceMap(targetVirtualFile);
73
- const targetSelectionRange = targetSourceMap.getSourceRange(link.targetSelectionRange);
74
- if (targetSelectionRange) {
73
+ for (const targetSourceMap of context.documents.getMaps(targetVirtualFile)) {
74
+ const targetSelectionRange = targetSourceMap.getSourceRange(link.targetSelectionRange);
75
+ if (!targetSelectionRange) {
76
+ continue;
77
+ }
78
+ foundTargetSelectionRange = true;
75
79
  let targetRange = targetSourceMap.getSourceRange(link.targetRange);
76
80
  link.targetUri = targetSourceMap.sourceDocument.uri;
77
81
  // loose range mapping to for template slots, slot properties
78
82
  link.targetRange = targetRange ?? targetSelectionRange;
79
83
  link.targetSelectionRange = targetSelectionRange;
80
84
  }
81
- else if (apiName === 'provideDefinition') {
82
- const targetMap = context.documents.getSourceMap(targetVirtualFile);
83
- // cross file definition
84
- if (targetMap.sourceDocument.uri !== uri.toString()) {
85
- return {
86
- ...link,
87
- targetUri: targetMap.sourceDocument.uri,
88
- targetRange: {
89
- start: { line: 0, character: 0 },
90
- end: { line: 0, character: 0 },
91
- },
92
- targetSelectionRange: {
93
- start: { line: 0, character: 0 },
94
- end: { line: 0, character: 0 },
95
- },
96
- };
97
- }
98
- else {
99
- return;
85
+ if (apiName === 'provideDefinition' && !foundTargetSelectionRange) {
86
+ for (const targetMap of context.documents.getMaps(targetVirtualFile)) {
87
+ if (targetMap && targetMap.sourceDocument.uri !== uri.toString()) {
88
+ return {
89
+ ...link,
90
+ targetUri: targetMap.sourceDocument.uri,
91
+ targetRange: {
92
+ start: { line: 0, character: 0 },
93
+ end: { line: 0, character: 0 },
94
+ },
95
+ targetSelectionRange: {
96
+ start: { line: 0, character: 0 },
97
+ end: { line: 0, character: 0 },
98
+ },
99
+ };
100
+ }
100
101
  }
102
+ return;
101
103
  }
102
104
  }
103
105
  return link;
@@ -137,7 +137,7 @@ function register(context) {
137
137
  errorsUpdated = false;
138
138
  }
139
139
  }
140
- async function collectErrors() {
140
+ function collectErrors() {
141
141
  return Object.values(lastResponse).flatMap(({ errors }) => errors);
142
142
  }
143
143
  async function worker(api, cacheMap, cache) {
@@ -204,16 +204,17 @@ function register(context) {
204
204
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
205
205
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
206
206
  if (virtualCode) {
207
- const map = context.documents.getSourceMap(virtualCode);
208
- const range = map.getSourceRange(info.location.range, filter);
209
- if (range) {
210
- relatedInfos.push({
211
- location: {
212
- uri: map.sourceDocument.uri,
213
- range,
214
- },
215
- message: info.message,
216
- });
207
+ for (const map of context.documents.getMaps(virtualCode)) {
208
+ const range = map.getSourceRange(info.location.range, filter);
209
+ if (range) {
210
+ relatedInfos.push({
211
+ location: {
212
+ uri: map.sourceDocument.uri,
213
+ range,
214
+ },
215
+ message: info.message,
216
+ });
217
+ }
217
218
  }
218
219
  }
219
220
  else {
@@ -8,7 +8,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
8
8
  const transform_1 = require("../utils/transform");
9
9
  function register(context) {
10
10
  return (uri, token = cancellation_1.NoneCancellationToken) => {
11
- return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), async (plugin, document) => {
11
+ return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), (plugin, document) => {
12
12
  if (token.isCancellationRequested) {
13
13
  return;
14
14
  }
@@ -22,12 +22,13 @@ function register(context) {
22
22
  if (!virtualCode) {
23
23
  return reference;
24
24
  }
25
- const map = context.documents.getSourceMap(virtualCode);
26
- const range = map.getSourceRange(reference.range, language_core_1.isReferencesEnabled);
27
- if (range) {
28
- reference.uri = map.sourceDocument.uri;
29
- reference.range = range;
30
- return reference;
25
+ for (const map of context.documents.getMaps(virtualCode)) {
26
+ const range = map.getSourceRange(reference.range, language_core_1.isReferencesEnabled);
27
+ if (range) {
28
+ reference.uri = map.sourceDocument.uri;
29
+ reference.range = range;
30
+ return reference;
31
+ }
31
32
  }
32
33
  })
33
34
  .filter(common_1.notEmpty), arr => dedupe.withLocations(arr.flat()));
@@ -55,13 +55,14 @@ function register(context) {
55
55
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
56
56
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
57
57
  if (virtualCode) {
58
- const map = context.documents.getSourceMap(virtualCode);
59
- const range = map.getSourceRange(reference.range, language_core_1.isReferencesEnabled);
60
- if (range) {
61
- results.push({
62
- uri: map.sourceDocument.uri,
63
- range,
64
- });
58
+ for (const map of context.documents.getMaps(virtualCode)) {
59
+ const range = map.getSourceRange(reference.range, language_core_1.isReferencesEnabled);
60
+ if (range) {
61
+ results.push({
62
+ uri: map.sourceDocument.uri,
63
+ range,
64
+ });
65
+ }
65
66
  }
66
67
  }
67
68
  else {
@@ -27,10 +27,11 @@ function register(context) {
27
27
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
28
28
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
29
29
  if (virtualCode) {
30
- const map = context.documents.getSourceMap(virtualCode);
31
- const range = map.getSourceRange(loc.range);
32
- if (range) {
33
- return { uri: map.sourceDocument.uri, range };
30
+ for (const map of context.documents.getMaps(virtualCode)) {
31
+ const range = map.getSourceRange(loc.range);
32
+ if (range) {
33
+ return { uri: map.sourceDocument.uri, range };
34
+ }
34
35
  }
35
36
  }
36
37
  else {
@@ -18,9 +18,10 @@ function register(context) {
18
18
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
19
19
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
20
20
  if (virtualCode) {
21
- const map = context.documents.getSourceMap(virtualCode);
22
- item = await plugin[1].resolveCompletionItem(item, token);
23
- item = plugin[1].transformCompletionItem?.(item) ?? (0, transform_1.transformCompletionItem)(item, embeddedRange => map.getSourceRange(embeddedRange), map.embeddedDocument, context);
21
+ for (const map of context.documents.getMaps(virtualCode)) {
22
+ item = await plugin[1].resolveCompletionItem(item, token);
23
+ item = plugin[1].transformCompletionItem?.(item) ?? (0, transform_1.transformCompletionItem)(item, embeddedRange => map.getSourceRange(embeddedRange), map.embeddedDocument, context);
24
+ }
24
25
  }
25
26
  }
26
27
  else {
@@ -59,15 +59,14 @@ function createLanguageService(language, plugins, env) {
59
59
  }
60
60
  return map.get(uri);
61
61
  },
62
- getSourceMap(virtualCode) {
63
- const map = context.language.maps.get(virtualCode);
64
- let result = map2DocMap.get(map);
65
- if (!result) {
66
- const sourceScript = context.language.scripts.fromVirtualCode(virtualCode);
67
- const embeddedUri = context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id);
68
- map2DocMap.set(map, result = new documents_1.SourceMapWithDocuments(this.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
62
+ *getMaps(virtualCode) {
63
+ for (const [uri, snapshot, map] of context.language.maps.forEach(virtualCode)) {
64
+ if (!map2DocMap.has(map)) {
65
+ const embeddedUri = context.encodeEmbeddedDocumentUri(uri, virtualCode.id);
66
+ map2DocMap.set(map, new documents_1.SourceMapWithDocuments(this.get(uri, context.language.scripts.get(uri).languageId, snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
67
+ }
68
+ yield map2DocMap.get(map);
69
69
  }
70
- return result;
71
70
  },
72
71
  getLinkedCodeMap(virtualCode, documentUri) {
73
72
  const map = context.language.linkedCodeMaps.get(virtualCode);
package/lib/types.d.ts CHANGED
@@ -49,7 +49,7 @@ export interface LanguageServiceContext {
49
49
  };
50
50
  documents: {
51
51
  get(uri: URI, languageId: string, snapshot: ts.IScriptSnapshot): TextDocument;
52
- getSourceMap(virtualCode: VirtualCode): SourceMapWithDocuments;
52
+ getMaps(virtualCode: VirtualCode): Generator<SourceMapWithDocuments>;
53
53
  getLinkedCodeMap(virtualCode: VirtualCode, documentUri: URI): LinkedCodeMapWithDocument | undefined;
54
54
  };
55
55
  plugins: [LanguageServicePlugin, LanguageServicePluginInstance][];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEmbeddedFilesByLevel = exports.forEachEmbeddedDocument = exports.safeCall = exports.languageFeatureWorker = exports.documentFeatureWorker = void 0;
4
- async function documentFeatureWorker(context, uri, valid, worker, transformResult, combineResult) {
4
+ function documentFeatureWorker(context, uri, valid, worker, transformResult, combineResult) {
5
5
  return languageFeatureWorker(context, uri, () => void 0, function* (map) {
6
6
  if (valid(map)) {
7
7
  yield;
@@ -89,9 +89,11 @@ function* forEachEmbeddedDocument(context, sourceScriptId, current) {
89
89
  yield* forEachEmbeddedDocument(context, sourceScriptId, embeddedCode);
90
90
  }
91
91
  }
92
- const map = context.documents.getSourceMap(current);
93
- if (!context.disabledEmbeddedDocumentUris.get(context.encodeEmbeddedDocumentUri(sourceScriptId, current.id))) {
94
- yield map;
92
+ for (const map of context.documents.getMaps(current)) {
93
+ if (sourceScriptId.toString() === map.sourceDocument.uri
94
+ && !context.disabledEmbeddedDocumentUris.get(context.encodeEmbeddedDocumentUri(sourceScriptId, current.id))) {
95
+ yield map;
96
+ }
95
97
  }
96
98
  }
97
99
  exports.forEachEmbeddedDocument = forEachEmbeddedDocument;
@@ -15,8 +15,10 @@ function transformDocumentLinkTarget(_target, context) {
15
15
  const virtualCode = sourceScript?.generated?.embeddedCodes.get(decoded[1]);
16
16
  target = decoded[0];
17
17
  if (embeddedRange && virtualCode) {
18
- const map = context.documents.getSourceMap(virtualCode);
19
- if (map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data))) {
18
+ for (const map of context.documents.getMaps(virtualCode)) {
19
+ if (!map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data))) {
20
+ continue;
21
+ }
20
22
  const startLine = Number(embeddedRange[1]) - 1;
21
23
  const startCharacter = Number(embeddedRange[3] ?? 1) - 1;
22
24
  if (embeddedRange[5] !== undefined) {
@@ -31,6 +33,7 @@ function transformDocumentLinkTarget(_target, context) {
31
33
  fragment: 'L' + (sourceRange.start.line + 1) + ',' + (sourceRange.start.character + 1)
32
34
  + '-L' + (sourceRange.end.line + 1) + ',' + (sourceRange.end.character + 1),
33
35
  });
36
+ break;
34
37
  }
35
38
  }
36
39
  else {
@@ -39,6 +42,7 @@ function transformDocumentLinkTarget(_target, context) {
39
42
  target = target.with({
40
43
  fragment: 'L' + (sourcePos.line + 1) + ',' + (sourcePos.character + 1),
41
44
  });
45
+ break;
42
46
  }
43
47
  }
44
48
  }
@@ -272,10 +276,11 @@ function transformWorkspaceEdit(edit, context, mode, versions = {}) {
272
276
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
273
277
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
274
278
  if (virtualCode) {
275
- const map = context.documents.getSourceMap(virtualCode);
276
- // TODO: check capability?
277
- const uri = map.sourceDocument.uri;
278
- sourceResult.changeAnnotations[uri] = tsAnno;
279
+ for (const map of context.documents.getMaps(virtualCode)) {
280
+ // TODO: check capability?
281
+ const uri = map.sourceDocument.uri;
282
+ sourceResult.changeAnnotations[uri] = tsAnno;
283
+ }
279
284
  }
280
285
  else {
281
286
  sourceResult.changeAnnotations[tsUri] = tsAnno;
@@ -287,30 +292,31 @@ function transformWorkspaceEdit(edit, context, mode, versions = {}) {
287
292
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
288
293
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
289
294
  if (virtualCode) {
290
- const map = context.documents.getSourceMap(virtualCode);
291
- const tsEdits = edit.changes[tsUri];
292
- for (const tsEdit of tsEdits) {
293
- if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
294
- let _data;
295
- const range = map.getSourceRange(tsEdit.range, data => {
296
- _data = data;
297
- return (0, language_core_1.isRenameEnabled)(data);
298
- });
299
- if (range) {
300
- sourceResult.changes[map.sourceDocument.uri] ??= [];
301
- sourceResult.changes[map.sourceDocument.uri].push({
302
- newText: (0, language_core_1.resolveRenameEditText)(tsEdit.newText, _data),
303
- range,
295
+ for (const map of context.documents.getMaps(virtualCode)) {
296
+ const tsEdits = edit.changes[tsUri];
297
+ for (const tsEdit of tsEdits) {
298
+ if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
299
+ let _data;
300
+ const range = map.getSourceRange(tsEdit.range, data => {
301
+ _data = data;
302
+ return (0, language_core_1.isRenameEnabled)(data);
304
303
  });
305
- hasResult = true;
304
+ if (range) {
305
+ sourceResult.changes[map.sourceDocument.uri] ??= [];
306
+ sourceResult.changes[map.sourceDocument.uri].push({
307
+ newText: (0, language_core_1.resolveRenameEditText)(tsEdit.newText, _data),
308
+ range,
309
+ });
310
+ hasResult = true;
311
+ }
306
312
  }
307
- }
308
- else {
309
- const range = map.getSourceRange(tsEdit.range);
310
- if (range) {
311
- sourceResult.changes[map.sourceDocument.uri] ??= [];
312
- sourceResult.changes[map.sourceDocument.uri].push({ newText: tsEdit.newText, range });
313
- hasResult = true;
313
+ else {
314
+ const range = map.getSourceRange(tsEdit.range);
315
+ if (range) {
316
+ sourceResult.changes[map.sourceDocument.uri] ??= [];
317
+ sourceResult.changes[map.sourceDocument.uri].push({ newText: tsEdit.newText, range });
318
+ hasResult = true;
319
+ }
314
320
  }
315
321
  }
316
322
  }
@@ -329,43 +335,44 @@ function transformWorkspaceEdit(edit, context, mode, versions = {}) {
329
335
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
330
336
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
331
337
  if (virtualCode) {
332
- const map = context.documents.getSourceMap(virtualCode);
333
- sourceEdit = {
334
- textDocument: {
335
- uri: map.sourceDocument.uri,
336
- version: versions[map.sourceDocument.uri] ?? null,
337
- },
338
- edits: [],
339
- };
340
- for (const tsEdit of tsDocEdit.edits) {
341
- if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
342
- let _data;
343
- const range = map.getSourceRange(tsEdit.range, data => {
344
- _data = data;
345
- // fix https://github.com/johnsoncodehk/volar/issues/1091
346
- return (0, language_core_1.isRenameEnabled)(data);
347
- });
348
- if (range) {
349
- sourceEdit.edits.push({
350
- annotationId: 'annotationId' in tsEdit ? tsEdit.annotationId : undefined,
351
- newText: (0, language_core_1.resolveRenameEditText)(tsEdit.newText, _data),
352
- range,
338
+ for (const map of context.documents.getMaps(virtualCode)) {
339
+ sourceEdit = {
340
+ textDocument: {
341
+ uri: map.sourceDocument.uri,
342
+ version: versions[map.sourceDocument.uri] ?? null,
343
+ },
344
+ edits: [],
345
+ };
346
+ for (const tsEdit of tsDocEdit.edits) {
347
+ if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
348
+ let _data;
349
+ const range = map.getSourceRange(tsEdit.range, data => {
350
+ _data = data;
351
+ // fix https://github.com/johnsoncodehk/volar/issues/1091
352
+ return (0, language_core_1.isRenameEnabled)(data);
353
353
  });
354
+ if (range) {
355
+ sourceEdit.edits.push({
356
+ annotationId: 'annotationId' in tsEdit ? tsEdit.annotationId : undefined,
357
+ newText: (0, language_core_1.resolveRenameEditText)(tsEdit.newText, _data),
358
+ range,
359
+ });
360
+ }
354
361
  }
355
- }
356
- else {
357
- const range = map.getSourceRange(tsEdit.range);
358
- if (range) {
359
- sourceEdit.edits.push({
360
- annotationId: 'annotationId' in tsEdit ? tsEdit.annotationId : undefined,
361
- newText: tsEdit.newText,
362
- range,
363
- });
362
+ else {
363
+ const range = map.getSourceRange(tsEdit.range);
364
+ if (range) {
365
+ sourceEdit.edits.push({
366
+ annotationId: 'annotationId' in tsEdit ? tsEdit.annotationId : undefined,
367
+ newText: tsEdit.newText,
368
+ range,
369
+ });
370
+ }
364
371
  }
365
372
  }
366
- }
367
- if (!sourceEdit.edits.length) {
368
- sourceEdit = undefined;
373
+ if (!sourceEdit.edits.length) {
374
+ sourceEdit = undefined;
375
+ }
369
376
  }
370
377
  }
371
378
  else {
@@ -380,15 +387,16 @@ function transformWorkspaceEdit(edit, context, mode, versions = {}) {
380
387
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
381
388
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
382
389
  if (virtualCode) {
383
- const map = context.documents.getSourceMap(virtualCode);
384
- // TODO: check capability?
385
- sourceEdit = {
386
- kind: 'rename',
387
- oldUri: map.sourceDocument.uri,
388
- newUri: tsDocEdit.newUri /* TODO: remove .ts? */,
389
- options: tsDocEdit.options,
390
- annotationId: tsDocEdit.annotationId,
391
- };
390
+ for (const map of context.documents.getMaps(virtualCode)) {
391
+ // TODO: check capability?
392
+ sourceEdit = {
393
+ kind: 'rename',
394
+ oldUri: map.sourceDocument.uri,
395
+ newUri: tsDocEdit.newUri /* TODO: remove .ts? */,
396
+ options: tsDocEdit.options,
397
+ annotationId: tsDocEdit.annotationId,
398
+ };
399
+ }
392
400
  }
393
401
  else {
394
402
  sourceEdit = tsDocEdit;
@@ -399,14 +407,15 @@ function transformWorkspaceEdit(edit, context, mode, versions = {}) {
399
407
  const sourceScript = decoded && context.language.scripts.get(decoded[0]);
400
408
  const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
401
409
  if (virtualCode) {
402
- const map = context.documents.getSourceMap(virtualCode);
403
- // TODO: check capability?
404
- sourceEdit = {
405
- kind: 'delete',
406
- uri: map.sourceDocument.uri,
407
- options: tsDocEdit.options,
408
- annotationId: tsDocEdit.annotationId,
409
- };
410
+ for (const map of context.documents.getMaps(virtualCode)) {
411
+ // TODO: check capability?
412
+ sourceEdit = {
413
+ kind: 'delete',
414
+ uri: map.sourceDocument.uri,
415
+ options: tsDocEdit.options,
416
+ annotationId: tsDocEdit.annotationId,
417
+ };
418
+ }
410
419
  }
411
420
  else {
412
421
  sourceEdit = tsDocEdit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "2.3.0-alpha.5",
3
+ "version": "2.3.0-alpha.7",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,10 +12,10 @@
12
12
  "directory": "packages/language-service"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "2.3.0-alpha.5",
15
+ "@volar/language-core": "2.3.0-alpha.7",
16
16
  "vscode-languageserver-protocol": "^3.17.5",
17
17
  "vscode-languageserver-textdocument": "^1.0.11",
18
18
  "vscode-uri": "^3.0.8"
19
19
  },
20
- "gitHead": "c3f6867de39095913ceaa2256ad35a9ca1a90487"
20
+ "gitHead": "3cc2a62516113c5789e4f54766e25063099a13a5"
21
21
  }