@volar/language-service 2.0.0-alpha.13 → 2.0.0-alpha.14
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/documents.d.ts +6 -6
- package/lib/documents.js +18 -23
- package/lib/features/provideCallHierarchyItems.js +22 -15
- package/lib/features/provideCodeActions.js +5 -3
- package/lib/features/provideColorPresentations.js +4 -2
- package/lib/features/provideCompletionItems.js +40 -22
- package/lib/features/provideDefinition.js +13 -8
- package/lib/features/provideDiagnostics.js +6 -5
- package/lib/features/provideDocumentDropEdits.js +1 -1
- package/lib/features/provideDocumentFormattingEdits.js +49 -37
- package/lib/features/provideDocumentHighlights.js +10 -6
- package/lib/features/provideDocumentSemanticTokens.js +5 -3
- package/lib/features/provideDocumentSymbols.js +2 -1
- package/lib/features/provideFileReferences.js +4 -4
- package/lib/features/provideFileRenameEdits.js +4 -17
- package/lib/features/provideInlayHints.js +3 -2
- package/lib/features/provideLinkedEditingRanges.js +2 -1
- package/lib/features/provideReferences.js +14 -10
- package/lib/features/provideRenameEdits.js +22 -13
- package/lib/features/provideSelectionRanges.js +2 -1
- package/lib/features/provideSignatureHelp.js +1 -1
- package/lib/features/provideWorkspaceSymbols.js +3 -3
- package/lib/features/resolveCodeAction.js +2 -1
- package/lib/features/resolveCodeLens.js +2 -1
- package/lib/features/resolveCompletionItem.js +5 -4
- package/lib/features/resolveDocumentLink.js +5 -4
- package/lib/features/resolveInlayHint.js +2 -1
- package/lib/languageService.d.ts +2 -2
- package/lib/languageService.js +5 -6
- package/lib/types.d.ts +15 -16
- package/lib/utils/common.js +10 -5
- package/lib/utils/featureWorkers.d.ts +3 -3
- package/lib/utils/featureWorkers.js +25 -17
- package/lib/utils/transform.d.ts +1 -1
- package/lib/utils/transform.js +26 -21
- package/package.json +3 -3
package/lib/languageService.js
CHANGED
|
@@ -35,7 +35,7 @@ const codeLensResolve = require("./features/resolveCodeLens");
|
|
|
35
35
|
const completionResolve = require("./features/resolveCompletionItem");
|
|
36
36
|
const documentLinkResolve = require("./features/resolveDocumentLink");
|
|
37
37
|
const inlayHintResolve = require("./features/resolveInlayHint");
|
|
38
|
-
function createLanguageService(
|
|
38
|
+
function createLanguageService(languageContext, servicePlugins, env) {
|
|
39
39
|
const context = createServiceContext();
|
|
40
40
|
return {
|
|
41
41
|
getTriggerCharacters: () => servicePlugins.map(service => service.triggerCharacters ?? []).flat(),
|
|
@@ -80,10 +80,10 @@ function createLanguageService(language, servicePlugins, env) {
|
|
|
80
80
|
context,
|
|
81
81
|
};
|
|
82
82
|
function createServiceContext() {
|
|
83
|
-
const documents = (0, documents_1.createDocumentProvider)(env, language.files);
|
|
84
83
|
const context = {
|
|
84
|
+
...languageContext,
|
|
85
|
+
documents: (0, documents_1.createDocumentProvider)(languageContext.files),
|
|
85
86
|
env,
|
|
86
|
-
language: language,
|
|
87
87
|
inject: (key, ...args) => {
|
|
88
88
|
for (const service of context.services) {
|
|
89
89
|
if (context.disabledServicePlugins.has(service[1])) {
|
|
@@ -97,7 +97,6 @@ function createLanguageService(language, servicePlugins, env) {
|
|
|
97
97
|
throw `No service provide ${key}`;
|
|
98
98
|
},
|
|
99
99
|
services: [],
|
|
100
|
-
documents: documents,
|
|
101
100
|
commands: {
|
|
102
101
|
rename: {
|
|
103
102
|
create(uri, position) {
|
|
@@ -147,10 +146,10 @@ function createLanguageService(language, servicePlugins, env) {
|
|
|
147
146
|
},
|
|
148
147
|
is(command) {
|
|
149
148
|
return command.command === 'setSelection';
|
|
150
|
-
}
|
|
149
|
+
},
|
|
151
150
|
},
|
|
152
151
|
},
|
|
153
|
-
|
|
152
|
+
disabledVirtualFileUris: new Set(),
|
|
154
153
|
disabledServicePlugins: new WeakSet(),
|
|
155
154
|
};
|
|
156
155
|
for (const servicePlugin of servicePlugins) {
|
package/lib/types.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageContext } from '@volar/language-core';
|
|
2
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
4
|
import type { URI } from 'vscode-uri';
|
|
5
5
|
import type { DocumentProvider } from './documents';
|
|
6
6
|
export type * from 'vscode-languageserver-protocol';
|
|
7
|
-
export interface ServiceEnvironment
|
|
7
|
+
export interface ServiceEnvironment {
|
|
8
|
+
typescript: {
|
|
9
|
+
uriToFileName(uri: string): string;
|
|
10
|
+
fileNameToUri(fileName: string): string;
|
|
11
|
+
};
|
|
8
12
|
workspaceFolder: URI;
|
|
9
13
|
locale?: string;
|
|
10
14
|
clientCapabilities?: vscode.ClientCapabilities;
|
|
15
|
+
fs?: FileSystem;
|
|
16
|
+
console?: Console;
|
|
11
17
|
getConfiguration?<T>(section: string, scopeUri?: string): Promise<T | undefined>;
|
|
12
18
|
onDidChangeConfiguration?(cb: () => void): vscode.Disposable;
|
|
13
19
|
onDidChangeWatchedFiles?(cb: (params: vscode.DidChangeWatchedFilesParams) => void): vscode.Disposable;
|
|
14
20
|
}
|
|
15
|
-
export interface RuntimeEnvironment {
|
|
16
|
-
uriToFileName(uri: string): string;
|
|
17
|
-
fileNameToUri(fileName: string): string;
|
|
18
|
-
fs?: FileSystem;
|
|
19
|
-
console?: Console;
|
|
20
|
-
}
|
|
21
21
|
export interface Console {
|
|
22
22
|
error(message: string): void;
|
|
23
23
|
info(message: string): void;
|
|
@@ -41,22 +41,21 @@ export declare enum FileType {
|
|
|
41
41
|
Directory = 2,
|
|
42
42
|
SymbolicLink = 64
|
|
43
43
|
}
|
|
44
|
-
interface
|
|
45
|
-
create: T;
|
|
44
|
+
export interface ServiceCommand<T extends any[]> {
|
|
45
|
+
create(...args: T): vscode.Command | undefined;
|
|
46
46
|
is(value: vscode.Command): boolean;
|
|
47
47
|
}
|
|
48
|
-
export interface ServiceContext {
|
|
48
|
+
export interface ServiceContext extends LanguageContext {
|
|
49
49
|
env: ServiceEnvironment;
|
|
50
|
-
language: Language;
|
|
51
50
|
inject<Provide, K extends keyof Provide = keyof Provide>(key: K, ...args: Provide[K] extends (...args: any) => any ? Parameters<Provide[K]> : never): ReturnType<Provide[K] extends (...args: any) => any ? Provide[K] : never>;
|
|
52
51
|
commands: {
|
|
53
|
-
showReferences:
|
|
54
|
-
rename:
|
|
55
|
-
setSelection:
|
|
52
|
+
showReferences: ServiceCommand<[uri: string, position: vscode.Position, locations: vscode.Location[]]>;
|
|
53
|
+
rename: ServiceCommand<[uri: string, position: vscode.Position]>;
|
|
54
|
+
setSelection: ServiceCommand<[position: vscode.Position]>;
|
|
56
55
|
};
|
|
57
56
|
documents: DocumentProvider;
|
|
58
57
|
services: [ServicePlugin, ServicePluginInstance][];
|
|
59
|
-
|
|
58
|
+
disabledVirtualFileUris: Set<string>;
|
|
60
59
|
disabledServicePlugins: WeakSet<ServicePluginInstance>;
|
|
61
60
|
}
|
|
62
61
|
export type Result<T> = T | Thenable<T>;
|
package/lib/utils/common.js
CHANGED
|
@@ -4,8 +4,9 @@ exports.notEmpty = exports.sleep = exports.stringToSnapshot = exports.isInsideRa
|
|
|
4
4
|
function getOverlapRange(range1Start, range1End, range2Start, range2End) {
|
|
5
5
|
const start = Math.max(range1Start, range2Start);
|
|
6
6
|
const end = Math.min(range1End, range2End);
|
|
7
|
-
if (start > end)
|
|
7
|
+
if (start > end) {
|
|
8
8
|
return undefined;
|
|
9
|
+
}
|
|
9
10
|
return {
|
|
10
11
|
start,
|
|
11
12
|
end,
|
|
@@ -13,14 +14,18 @@ function getOverlapRange(range1Start, range1End, range2Start, range2End) {
|
|
|
13
14
|
}
|
|
14
15
|
exports.getOverlapRange = getOverlapRange;
|
|
15
16
|
function isInsideRange(parent, child) {
|
|
16
|
-
if (child.start.line < parent.start.line)
|
|
17
|
+
if (child.start.line < parent.start.line) {
|
|
17
18
|
return false;
|
|
18
|
-
|
|
19
|
+
}
|
|
20
|
+
if (child.end.line > parent.end.line) {
|
|
19
21
|
return false;
|
|
20
|
-
|
|
22
|
+
}
|
|
23
|
+
if (child.start.line === parent.start.line && child.start.character < parent.start.character) {
|
|
21
24
|
return false;
|
|
22
|
-
|
|
25
|
+
}
|
|
26
|
+
if (child.end.line === parent.end.line && child.end.character > parent.end.character) {
|
|
23
27
|
return false;
|
|
28
|
+
}
|
|
24
29
|
return true;
|
|
25
30
|
}
|
|
26
31
|
exports.isInsideRange = isInsideRange;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { CodeInformation,
|
|
1
|
+
import type { CodeInformation, VirtualCode } from '@volar/language-core';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import type { SourceMapWithDocuments } from '../documents';
|
|
4
4
|
import type { ServiceContext, ServicePluginInstance, ServicePlugin } from '../types';
|
|
5
5
|
export declare function documentFeatureWorker<T>(context: ServiceContext, uri: string, valid: (map: SourceMapWithDocuments<CodeInformation>) => boolean, worker: (service: [ServicePlugin, ServicePluginInstance], document: TextDocument) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments<CodeInformation>) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
|
|
6
6
|
export declare function languageFeatureWorker<T, K>(context: ServiceContext, uri: string, getReadDocParams: () => K, eachVirtualDocParams: (map: SourceMapWithDocuments<CodeInformation>) => Generator<K>, worker: (service: [ServicePlugin, ServicePluginInstance], document: TextDocument, params: K, map?: SourceMapWithDocuments<CodeInformation>) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments<CodeInformation>) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
|
|
7
7
|
export declare function safeCall<T>(cb: () => Thenable<T> | T, errorMsg?: string): Promise<T | undefined>;
|
|
8
|
-
export declare function visitEmbedded(context: ServiceContext, current:
|
|
9
|
-
export declare function getEmbeddedFilesByLevel(context: ServiceContext, rootFile:
|
|
8
|
+
export declare function visitEmbedded(context: ServiceContext, current: VirtualCode, cb: (file: VirtualCode, sourceMap: SourceMapWithDocuments<CodeInformation>) => Promise<boolean>, rootFile?: VirtualCode<string>): Promise<boolean>;
|
|
9
|
+
export declare function getEmbeddedFilesByLevel(context: ServiceContext, sourceFileUri: string, rootFile: VirtualCode, level: number): VirtualCode<string>[];
|
|
@@ -10,26 +10,30 @@ async function documentFeatureWorker(context, uri, valid, worker, transformResul
|
|
|
10
10
|
}
|
|
11
11
|
exports.documentFeatureWorker = documentFeatureWorker;
|
|
12
12
|
async function languageFeatureWorker(context, uri, getReadDocParams, eachVirtualDocParams, worker, transformResult, combineResult) {
|
|
13
|
-
const sourceFile = context.
|
|
14
|
-
if (!sourceFile)
|
|
13
|
+
const sourceFile = context.files.get(uri);
|
|
14
|
+
if (!sourceFile) {
|
|
15
15
|
return;
|
|
16
|
+
}
|
|
16
17
|
let results = [];
|
|
17
|
-
if (sourceFile.
|
|
18
|
-
await visitEmbedded(context, sourceFile.
|
|
18
|
+
if (sourceFile.generated) {
|
|
19
|
+
await visitEmbedded(context, sourceFile.generated.code, async (_file, map) => {
|
|
19
20
|
for (const mappedArg of eachVirtualDocParams(map)) {
|
|
20
21
|
for (const [serviceId, service] of Object.entries(context.services)) {
|
|
21
22
|
if (context.disabledServicePlugins.has(service[1])) {
|
|
22
23
|
continue;
|
|
23
24
|
}
|
|
24
25
|
const embeddedResult = await safeCall(() => worker(service, map.virtualFileDocument, mappedArg, map), 'service ' + serviceId + ' crashed on ' + map.virtualFileDocument.uri);
|
|
25
|
-
if (!embeddedResult)
|
|
26
|
+
if (!embeddedResult) {
|
|
26
27
|
continue;
|
|
28
|
+
}
|
|
27
29
|
const result = transformResult(embeddedResult, map);
|
|
28
|
-
if (!result)
|
|
30
|
+
if (!result) {
|
|
29
31
|
continue;
|
|
32
|
+
}
|
|
30
33
|
results.push(result);
|
|
31
|
-
if (!combineResult)
|
|
34
|
+
if (!combineResult) {
|
|
32
35
|
return false;
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
return true;
|
|
@@ -43,14 +47,17 @@ async function languageFeatureWorker(context, uri, getReadDocParams, eachVirtual
|
|
|
43
47
|
continue;
|
|
44
48
|
}
|
|
45
49
|
const embeddedResult = await safeCall(() => worker(service, document, params, undefined), 'service ' + serviceId + ' crashed on ' + uri);
|
|
46
|
-
if (!embeddedResult)
|
|
50
|
+
if (!embeddedResult) {
|
|
47
51
|
continue;
|
|
52
|
+
}
|
|
48
53
|
const result = transformResult(embeddedResult, undefined);
|
|
49
|
-
if (!result)
|
|
54
|
+
if (!result) {
|
|
50
55
|
continue;
|
|
56
|
+
}
|
|
51
57
|
results.push(result);
|
|
52
|
-
if (!combineResult)
|
|
58
|
+
if (!combineResult) {
|
|
53
59
|
break;
|
|
60
|
+
}
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
if (combineResult && results.length > 0) {
|
|
@@ -71,15 +78,15 @@ async function safeCall(cb, errorMsg) {
|
|
|
71
78
|
}
|
|
72
79
|
exports.safeCall = safeCall;
|
|
73
80
|
async function visitEmbedded(context, current, cb, rootFile = current) {
|
|
74
|
-
for (const embedded of current.
|
|
81
|
+
for (const embedded of current.embeddedCodes) {
|
|
75
82
|
if (!await visitEmbedded(context, embedded, cb, rootFile)) {
|
|
76
83
|
return false;
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
for (const map of context.documents.getMaps(current)) {
|
|
80
|
-
const sourceFile = context.
|
|
81
|
-
if (sourceFile?.
|
|
82
|
-
&& !context.
|
|
87
|
+
const sourceFile = context.files.get(map.sourceFileDocument.uri);
|
|
88
|
+
if (sourceFile?.generated?.code === rootFile
|
|
89
|
+
&& !context.disabledVirtualFileUris.has(context.documents.getVirtualCodeUri(context.files.getByVirtualCode(current).id, current.id))
|
|
83
90
|
&& !await cb(current, map)) {
|
|
84
91
|
return false;
|
|
85
92
|
}
|
|
@@ -87,14 +94,15 @@ async function visitEmbedded(context, current, cb, rootFile = current) {
|
|
|
87
94
|
return true;
|
|
88
95
|
}
|
|
89
96
|
exports.visitEmbedded = visitEmbedded;
|
|
90
|
-
function getEmbeddedFilesByLevel(context, rootFile, level) {
|
|
97
|
+
function getEmbeddedFilesByLevel(context, sourceFileUri, rootFile, level) {
|
|
91
98
|
const embeddedFilesByLevel = [[rootFile]];
|
|
92
99
|
while (true) {
|
|
93
|
-
if (embeddedFilesByLevel.length > level)
|
|
100
|
+
if (embeddedFilesByLevel.length > level) {
|
|
94
101
|
return embeddedFilesByLevel[level];
|
|
102
|
+
}
|
|
95
103
|
let nextLevel = [];
|
|
96
104
|
for (const file of embeddedFilesByLevel[embeddedFilesByLevel.length - 1]) {
|
|
97
|
-
nextLevel = nextLevel.concat(file.
|
|
105
|
+
nextLevel = nextLevel.concat(file.embeddedCodes.filter(file => !context.disabledVirtualFileUris.has(context.documents.getVirtualCodeUri(sourceFileUri, file.id))));
|
|
98
106
|
}
|
|
99
107
|
embeddedFilesByLevel.push(nextLevel);
|
|
100
108
|
}
|
package/lib/utils/transform.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export declare function transformSelectionRange<T extends vscode.SelectionRange>
|
|
|
15
15
|
export declare function transformSelectionRanges<T extends vscode.SelectionRange>(locations: T[], getOtherRange: (range: vscode.Range) => vscode.Range | undefined): T[];
|
|
16
16
|
export declare function transformTextEdit<T extends vscode.TextEdit | vscode.InsertReplaceEdit>(textEdit: T, getOtherRange: (range: vscode.Range) => vscode.Range | undefined, document: vscode.TextDocument): T | undefined;
|
|
17
17
|
export declare function transformWorkspaceSymbol(symbol: vscode.WorkspaceSymbol, getOtherLocation: (location: vscode.Location) => vscode.Location | undefined): vscode.WorkspaceSymbol | undefined;
|
|
18
|
-
export declare function transformWorkspaceEdit(edit: vscode.WorkspaceEdit, { documents
|
|
18
|
+
export declare function transformWorkspaceEdit(edit: vscode.WorkspaceEdit, { documents }: ServiceContext, mode: 'fileName' | 'rename' | 'codeAction' | undefined, versions?: Record<string, number>): vscode.WorkspaceEdit | undefined;
|
|
19
19
|
export declare function pushEditToDocumentChanges(arr: NonNullable<vscode.WorkspaceEdit['documentChanges']>, item: NonNullable<vscode.WorkspaceEdit['documentChanges']>[number]): void;
|
package/lib/utils/transform.js
CHANGED
|
@@ -66,10 +66,12 @@ function transformFoldingRanges(ranges, getOtherRange) {
|
|
|
66
66
|
if (otherRange) {
|
|
67
67
|
range.startLine = otherRange.start.line;
|
|
68
68
|
range.endLine = otherRange.end.line;
|
|
69
|
-
if (range.startCharacter !== undefined)
|
|
69
|
+
if (range.startCharacter !== undefined) {
|
|
70
70
|
range.startCharacter = otherRange.start.character;
|
|
71
|
-
|
|
71
|
+
}
|
|
72
|
+
if (range.endCharacter !== undefined) {
|
|
72
73
|
range.endCharacter = otherRange.end.character;
|
|
74
|
+
}
|
|
73
75
|
result.push(range);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
@@ -81,8 +83,9 @@ function transformHover(hover, getOtherRange) {
|
|
|
81
83
|
return hover;
|
|
82
84
|
}
|
|
83
85
|
const range = getOtherRange(hover.range);
|
|
84
|
-
if (!range)
|
|
86
|
+
if (!range) {
|
|
85
87
|
return;
|
|
88
|
+
}
|
|
86
89
|
return {
|
|
87
90
|
...hover,
|
|
88
91
|
range,
|
|
@@ -91,8 +94,9 @@ function transformHover(hover, getOtherRange) {
|
|
|
91
94
|
exports.transformHover = transformHover;
|
|
92
95
|
function transformLocation(location, getOtherRange) {
|
|
93
96
|
const range = getOtherRange(location.range);
|
|
94
|
-
if (!range)
|
|
97
|
+
if (!range) {
|
|
95
98
|
return;
|
|
99
|
+
}
|
|
96
100
|
return {
|
|
97
101
|
...location,
|
|
98
102
|
range,
|
|
@@ -107,8 +111,9 @@ function transformLocations(locations, getOtherRange) {
|
|
|
107
111
|
exports.transformLocations = transformLocations;
|
|
108
112
|
function transformSelectionRange(location, getOtherRange) {
|
|
109
113
|
const range = getOtherRange(location.range);
|
|
110
|
-
if (!range)
|
|
114
|
+
if (!range) {
|
|
111
115
|
return;
|
|
116
|
+
}
|
|
112
117
|
const parent = location.parent ? transformSelectionRange(location.parent, getOtherRange) : undefined;
|
|
113
118
|
return {
|
|
114
119
|
range,
|
|
@@ -204,15 +209,15 @@ function transformWorkspaceSymbol(symbol, getOtherLocation) {
|
|
|
204
209
|
};
|
|
205
210
|
}
|
|
206
211
|
exports.transformWorkspaceSymbol = transformWorkspaceSymbol;
|
|
207
|
-
function transformWorkspaceEdit(edit, { documents
|
|
212
|
+
function transformWorkspaceEdit(edit, { documents }, mode, versions = {}) {
|
|
208
213
|
const sourceResult = {};
|
|
209
214
|
let hasResult = false;
|
|
210
215
|
for (const tsUri in edit.changeAnnotations) {
|
|
211
216
|
sourceResult.changeAnnotations ??= {};
|
|
212
217
|
const tsAnno = edit.changeAnnotations[tsUri];
|
|
213
|
-
const [
|
|
214
|
-
if (
|
|
215
|
-
for (const map of documents.getMaps(
|
|
218
|
+
const [virtualCode] = documents.getVirtualCodeByUri(tsUri);
|
|
219
|
+
if (virtualCode) {
|
|
220
|
+
for (const map of documents.getMaps(virtualCode)) {
|
|
216
221
|
// TODO: check capability?
|
|
217
222
|
const uri = map.sourceFileDocument.uri;
|
|
218
223
|
sourceResult.changeAnnotations[uri] = tsAnno;
|
|
@@ -224,9 +229,9 @@ function transformWorkspaceEdit(edit, { documents, language: project, env }, mod
|
|
|
224
229
|
}
|
|
225
230
|
for (const tsUri in edit.changes) {
|
|
226
231
|
sourceResult.changes ??= {};
|
|
227
|
-
const [
|
|
228
|
-
if (
|
|
229
|
-
for (const map of documents.getMaps(
|
|
232
|
+
const [virtualCode] = documents.getVirtualCodeByUri(tsUri);
|
|
233
|
+
if (virtualCode) {
|
|
234
|
+
for (const map of documents.getMaps(virtualCode)) {
|
|
230
235
|
const tsEdits = edit.changes[tsUri];
|
|
231
236
|
for (const tsEdit of tsEdits) {
|
|
232
237
|
if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
|
|
@@ -265,9 +270,9 @@ function transformWorkspaceEdit(edit, { documents, language: project, env }, mod
|
|
|
265
270
|
sourceResult.documentChanges ??= [];
|
|
266
271
|
let sourceEdit;
|
|
267
272
|
if ('textDocument' in tsDocEdit) {
|
|
268
|
-
const [
|
|
269
|
-
if (
|
|
270
|
-
for (const map of documents.getMaps(
|
|
273
|
+
const [virtualCode] = documents.getVirtualCodeByUri(tsDocEdit.textDocument.uri);
|
|
274
|
+
if (virtualCode) {
|
|
275
|
+
for (const map of documents.getMaps(virtualCode)) {
|
|
271
276
|
sourceEdit = {
|
|
272
277
|
textDocument: {
|
|
273
278
|
uri: map.sourceFileDocument.uri,
|
|
@@ -315,9 +320,9 @@ function transformWorkspaceEdit(edit, { documents, language: project, env }, mod
|
|
|
315
320
|
sourceEdit = tsDocEdit; // TODO: remove .ts?
|
|
316
321
|
}
|
|
317
322
|
else if (tsDocEdit.kind === 'rename') {
|
|
318
|
-
const [
|
|
319
|
-
if (
|
|
320
|
-
for (const map of documents.getMaps(
|
|
323
|
+
const [virtualCode] = documents.getVirtualCodeByUri(tsDocEdit.oldUri);
|
|
324
|
+
if (virtualCode) {
|
|
325
|
+
for (const map of documents.getMaps(virtualCode)) {
|
|
321
326
|
// TODO: check capability?
|
|
322
327
|
sourceEdit = {
|
|
323
328
|
kind: 'rename',
|
|
@@ -333,9 +338,9 @@ function transformWorkspaceEdit(edit, { documents, language: project, env }, mod
|
|
|
333
338
|
}
|
|
334
339
|
}
|
|
335
340
|
else if (tsDocEdit.kind === 'delete') {
|
|
336
|
-
const [
|
|
337
|
-
if (
|
|
338
|
-
for (const map of documents.getMaps(
|
|
341
|
+
const [virtualCode] = documents.getVirtualCodeByUri(tsDocEdit.uri);
|
|
342
|
+
if (virtualCode) {
|
|
343
|
+
for (const map of documents.getMaps(virtualCode)) {
|
|
339
344
|
// TODO: check capability?
|
|
340
345
|
sourceEdit = {
|
|
341
346
|
kind: 'delete',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.14",
|
|
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.0.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.0.0-alpha.14",
|
|
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": "
|
|
20
|
+
"gitHead": "83eb6a4a4475a3680f14fb3808e48ec4dbe62cc1"
|
|
21
21
|
}
|