@volar/language-service 1.4.0-alpha.2 → 1.4.0-alpha.3
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/out/baseLanguageService.d.ts +36 -36
- package/out/baseLanguageService.js +49 -0
- package/out/documents.d.ts +1 -1
- package/out/documents.js +1 -1
- package/out/index.d.ts +0 -1
- package/out/index.js +1 -3
- package/out/languageFeatures/callHierarchy.js +3 -3
- package/out/languageFeatures/codeActions.js +9 -11
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +3 -3
- package/out/languageFeatures/codeLensResolve.d.ts +0 -2
- package/out/languageFeatures/codeLensResolve.js +4 -9
- package/out/languageFeatures/definition.js +1 -1
- package/out/languageFeatures/fileReferences.js +1 -1
- package/out/languageFeatures/references.js +1 -1
- package/out/languageFeatures/rename.js +5 -5
- package/out/languageFeatures/validation.js +1 -1
- package/out/languageFeatures/workspaceSymbols.js +1 -1
- package/out/transformer/command.d.ts +0 -0
- package/out/transformer/command.js +1 -0
- package/out/types.d.ts +10 -4
- package/package.json +4 -4
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
import { LanguageServicePluginContext, LanguageServiceOptions } from './types';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
import
|
|
3
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
export type LanguageService = ReturnType<typeof createLanguageService>;
|
|
5
5
|
export declare function createLanguageService(ctx: LanguageServiceOptions, documentRegistry?: ts.DocumentRegistry): {
|
|
6
6
|
triggerCharacters: string[];
|
|
7
7
|
autoFormatTriggerCharacters: string[];
|
|
8
8
|
signatureHelpTriggerCharacters: string[];
|
|
9
9
|
signatureHelpRetriggerCharacters: string[];
|
|
10
|
-
format: (uri: string, options:
|
|
10
|
+
format: (uri: string, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
11
11
|
ch: string;
|
|
12
|
-
position:
|
|
13
|
-
} | undefined, token?:
|
|
14
|
-
getFoldingRanges: (uri: string, token?:
|
|
15
|
-
getSelectionRanges: (uri: string, positions:
|
|
16
|
-
findLinkedEditingRanges: (uri: string, position:
|
|
17
|
-
findDocumentSymbols: (uri: string, token?:
|
|
18
|
-
findDocumentColors: (uri: string, token?:
|
|
19
|
-
getColorPresentations: (uri: string, color:
|
|
20
|
-
doValidation: (uri: string, mode: "all" | "semantic" | "syntactic", token?:
|
|
21
|
-
findReferences: (uri: string, position:
|
|
22
|
-
findFileReferences: (uri: string, token?:
|
|
23
|
-
findDefinition: (uri: string, position:
|
|
24
|
-
findTypeDefinition: (uri: string, position:
|
|
25
|
-
findImplementations: (uri: string, position:
|
|
26
|
-
prepareRename: (uri: string, position:
|
|
27
|
-
doRename: (uri: string, position:
|
|
28
|
-
getEditsForFileRename: (oldUri: string, newUri: string, token?:
|
|
29
|
-
getSemanticTokens: (uri: string, range:
|
|
30
|
-
doHover: (uri: string, position:
|
|
31
|
-
doComplete: (uri: string, position:
|
|
32
|
-
doCodeActions: (uri: string, range:
|
|
33
|
-
doCodeActionResolve: (item:
|
|
34
|
-
doCompletionResolve: (item:
|
|
35
|
-
getSignatureHelp: (uri: string, position:
|
|
36
|
-
doCodeLens: (uri: string, token?:
|
|
37
|
-
doCodeLensResolve: (item:
|
|
38
|
-
findDocumentHighlights: (uri: string, position:
|
|
39
|
-
findDocumentLinks: (uri: string, token?:
|
|
40
|
-
findWorkspaceSymbols: (query: string, token?:
|
|
41
|
-
doAutoInsert: (uri: string, position:
|
|
42
|
-
getInlayHints: (uri: string, range:
|
|
12
|
+
position: vscode.Position;
|
|
13
|
+
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
|
|
14
|
+
getFoldingRanges: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.FoldingRange[] | undefined>;
|
|
15
|
+
getSelectionRanges: (uri: string, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
|
|
16
|
+
findLinkedEditingRanges: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
|
|
17
|
+
findDocumentSymbols: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
18
|
+
findDocumentColors: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
19
|
+
getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
20
|
+
doValidation: (uri: string, mode: "all" | "semantic" | "syntactic", token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
21
|
+
findReferences: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
22
|
+
findFileReferences: (uri: string, token?: vscode.CancellationToken) => import("./types").NullableResult<vscode.Location[]>;
|
|
23
|
+
findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
24
|
+
findTypeDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
25
|
+
findImplementations: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
26
|
+
prepareRename: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
27
|
+
doRename: (uri: string, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
28
|
+
getEditsForFileRename: (oldUri: string, newUri: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
29
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
|
|
30
|
+
doHover: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
|
31
|
+
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
|
32
|
+
doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
33
|
+
doCodeActionResolve: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
34
|
+
doCompletionResolve: (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
|
35
|
+
getSignatureHelp: (uri: string, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
|
36
|
+
doCodeLens: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
37
|
+
doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
38
|
+
findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
39
|
+
findDocumentLinks: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
40
|
+
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
41
|
+
doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("./types").AutoInsertionContext, token?: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
42
|
+
getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
43
43
|
callHierarchy: {
|
|
44
|
-
doPrepare(uri: string, position:
|
|
45
|
-
getIncomingCalls(item:
|
|
46
|
-
getOutgoingCalls(item:
|
|
44
|
+
doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
45
|
+
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
46
|
+
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
47
47
|
};
|
|
48
48
|
dispose: () => void | undefined;
|
|
49
49
|
context: LanguageServicePluginContext;
|
|
@@ -33,6 +33,8 @@ const foldingRanges = require("./documentFeatures/foldingRanges");
|
|
|
33
33
|
const format = require("./documentFeatures/format");
|
|
34
34
|
const linkedEditingRanges = require("./documentFeatures/linkedEditingRanges");
|
|
35
35
|
const selectionRanges = require("./documentFeatures/selectionRanges");
|
|
36
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
37
|
+
// fix build
|
|
36
38
|
const common_1 = require("./utils/common");
|
|
37
39
|
function createLanguageService(ctx, documentRegistry) {
|
|
38
40
|
const languageContext = (0, language_core_1.createLanguageContext)(ctx.host, Object.values(ctx.config.languages ?? {}).filter(common_1.notEmpty));
|
|
@@ -59,6 +61,36 @@ function createLanguageServiceContext(ctx, languageContext, documentRegistry) {
|
|
|
59
61
|
languageService: tsLs,
|
|
60
62
|
} : undefined,
|
|
61
63
|
documents: textDocumentMapper,
|
|
64
|
+
commands: {
|
|
65
|
+
createRenameCommand(uri, position) {
|
|
66
|
+
const source = toSourceLocation(uri, position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename);
|
|
67
|
+
if (!source) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
return vscode.Command.create('', 'editor.action.rename', source.uri, source.position);
|
|
71
|
+
},
|
|
72
|
+
createShowReferencesCommand(uri, position, locations) {
|
|
73
|
+
const source = toSourceLocation(uri, position);
|
|
74
|
+
if (!source) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const sourceReferences = [];
|
|
78
|
+
for (const reference of locations) {
|
|
79
|
+
if (context.documents.isVirtualFileUri(reference.uri)) {
|
|
80
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
81
|
+
const range = map.toSourceRange(reference.range);
|
|
82
|
+
if (range) {
|
|
83
|
+
sourceReferences.push({ uri: map.sourceFileDocument.uri, range });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
sourceReferences.push(reference);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return vscode.Command.create(locations.length === 1 ? '1 reference' : `${locations.length} references`, 'editor.action.showReferences', source.uri, source.position, sourceReferences);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
62
94
|
getTextDocument,
|
|
63
95
|
};
|
|
64
96
|
for (const pluginId in ctx.config.plugins ?? {}) {
|
|
@@ -72,6 +104,23 @@ function createLanguageServiceContext(ctx, languageContext, documentRegistry) {
|
|
|
72
104
|
}
|
|
73
105
|
}
|
|
74
106
|
return context;
|
|
107
|
+
function toSourceLocation(uri, position, filter) {
|
|
108
|
+
if (!textDocumentMapper.isVirtualFileUri(uri)) {
|
|
109
|
+
return { uri, position };
|
|
110
|
+
}
|
|
111
|
+
const map = textDocumentMapper.getVirtualFileByUri(uri);
|
|
112
|
+
if (map) {
|
|
113
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(uri)) {
|
|
114
|
+
const sourcePosition = map.toSourcePosition(position, filter);
|
|
115
|
+
if (sourcePosition) {
|
|
116
|
+
return {
|
|
117
|
+
uri: map.sourceFileDocument.uri,
|
|
118
|
+
position: sourcePosition,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
75
124
|
function getTextDocument(uri) {
|
|
76
125
|
const fileName = ctx.uriToFileName(uri);
|
|
77
126
|
const scriptSnapshot = ctx.host.getScriptSnapshot(fileName);
|
package/out/documents.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class MirrorMapWithDocument extends SourceMapWithDocuments<[Mirro
|
|
|
32
32
|
}
|
|
33
33
|
export declare function createDocumentsAndSourceMaps(ctx: LanguageServiceOptions, mapper: VirtualFiles): {
|
|
34
34
|
getSourceByUri(sourceFileUri: string): import("@volar/language-core").Source | undefined;
|
|
35
|
-
|
|
35
|
+
isVirtualFileUri(virtualFileUri: string): boolean;
|
|
36
36
|
getVirtualFileByUri(virtualFileUri: string): readonly [VirtualFile, import("@volar/language-core").Source] | readonly [undefined, undefined];
|
|
37
37
|
getMirrorMapByUri(virtualFileUri: string): [VirtualFile, MirrorMapWithDocument] | undefined;
|
|
38
38
|
getMapsBySourceFileUri(uri: string): {
|
package/out/documents.js
CHANGED
|
@@ -138,7 +138,7 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
138
138
|
getSourceByUri(sourceFileUri) {
|
|
139
139
|
return mapper.getSource(ctx.uriToFileName(sourceFileUri));
|
|
140
140
|
},
|
|
141
|
-
|
|
141
|
+
isVirtualFileUri(virtualFileUri) {
|
|
142
142
|
return mapper.hasVirtualFile(ctx.uriToFileName(virtualFileUri));
|
|
143
143
|
},
|
|
144
144
|
getVirtualFileByUri(virtualFileUri) {
|
package/out/index.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ export * from './documents';
|
|
|
4
4
|
export { mergeWorkspaceEdits } from './languageFeatures/rename';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * as transformer from './transformer';
|
|
7
|
-
export { showReferencesCommand, ShowReferencesCommandData } from './languageFeatures/codeLensResolve';
|
|
8
7
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
9
8
|
export declare const standardSemanticTokensLegend: vscode.SemanticTokensLegend;
|
package/out/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
13
13
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.standardSemanticTokensLegend = exports.
|
|
16
|
+
exports.standardSemanticTokensLegend = exports.transformer = exports.mergeWorkspaceEdits = void 0;
|
|
17
17
|
__exportStar(require("@volar/language-core"), exports);
|
|
18
18
|
__exportStar(require("./baseLanguageService"), exports);
|
|
19
19
|
__exportStar(require("./documents"), exports);
|
|
@@ -21,8 +21,6 @@ var rename_1 = require("./languageFeatures/rename");
|
|
|
21
21
|
Object.defineProperty(exports, "mergeWorkspaceEdits", { enumerable: true, get: function () { return rename_1.mergeWorkspaceEdits; } });
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
23
|
exports.transformer = require("./transformer");
|
|
24
|
-
var codeLensResolve_1 = require("./languageFeatures/codeLensResolve");
|
|
25
|
-
Object.defineProperty(exports, "showReferencesCommand", { enumerable: true, get: function () { return codeLensResolve_1.showReferencesCommand; } });
|
|
26
24
|
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
|
|
27
25
|
exports.standardSemanticTokensLegend = {
|
|
28
26
|
tokenTypes: [
|
|
@@ -38,7 +38,7 @@ function register(context) {
|
|
|
38
38
|
return incomingItems;
|
|
39
39
|
Object.assign(item, data.original);
|
|
40
40
|
if (data.map) {
|
|
41
|
-
if (context.documents.
|
|
41
|
+
if (context.documents.isVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
42
42
|
const _calls = await plugin.provideCallHierarchyIncomingCalls(item, token);
|
|
43
43
|
for (const _call of _calls) {
|
|
44
44
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
@@ -75,7 +75,7 @@ function register(context) {
|
|
|
75
75
|
return items;
|
|
76
76
|
Object.assign(item, data.original);
|
|
77
77
|
if (data.map) {
|
|
78
|
-
if (context.documents.
|
|
78
|
+
if (context.documents.isVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
79
79
|
const _calls = await plugin.provideCallHierarchyOutgoingCalls(item, token);
|
|
80
80
|
for (const call of _calls) {
|
|
81
81
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
@@ -105,7 +105,7 @@ function register(context) {
|
|
|
105
105
|
},
|
|
106
106
|
};
|
|
107
107
|
function transformCallHierarchyItem(tsItem, tsRanges) {
|
|
108
|
-
if (!context.documents.
|
|
108
|
+
if (!context.documents.isVirtualFileUri(tsItem.uri))
|
|
109
109
|
return [tsItem, tsRanges];
|
|
110
110
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(tsItem.uri)) {
|
|
111
111
|
let range = map.toSourceRange(tsItem.range);
|
|
@@ -77,19 +77,17 @@ function register(context) {
|
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
79
|
return codeActions;
|
|
80
|
-
}, (
|
|
81
|
-
if (!
|
|
82
|
-
return
|
|
83
|
-
if (
|
|
84
|
-
const edit = (0, rename_1.embeddedEditToSourceEdit)(
|
|
85
|
-
if (edit) {
|
|
86
|
-
|
|
87
|
-
return _codeAction;
|
|
80
|
+
}, (actions, map) => actions.map(action => {
|
|
81
|
+
if (!map)
|
|
82
|
+
return action;
|
|
83
|
+
if (action.edit) {
|
|
84
|
+
const edit = (0, rename_1.embeddedEditToSourceEdit)(action.edit, context.documents, 'codeAction');
|
|
85
|
+
if (!edit) {
|
|
86
|
+
return;
|
|
88
87
|
}
|
|
88
|
+
action.edit = edit;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
return _codeAction;
|
|
92
|
-
}
|
|
90
|
+
return action;
|
|
93
91
|
}).filter(common_1.notEmpty), arr => dedupe.withCodeAction(arr.flat()));
|
|
94
92
|
const ruleActions = [];
|
|
95
93
|
for (const diagnostic of codeActionContext.diagnostics) {
|
|
@@ -9,7 +9,7 @@ export interface PluginCodeLensData {
|
|
|
9
9
|
export interface PluginReferencesCodeLensData {
|
|
10
10
|
kind: 'references';
|
|
11
11
|
uri: string;
|
|
12
|
-
|
|
12
|
+
range: vscode.Range;
|
|
13
13
|
pluginId: string;
|
|
14
14
|
}
|
|
15
15
|
export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
@@ -22,11 +22,11 @@ function register(context) {
|
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
24
|
if (referencesCodeLendsEnabled) {
|
|
25
|
-
const
|
|
26
|
-
const referencesCodeLens =
|
|
25
|
+
const ranges = await plugin.provideReferencesCodeLensRanges?.(document, token);
|
|
26
|
+
const referencesCodeLens = ranges?.map(range => vscode.CodeLens.create(range, {
|
|
27
27
|
kind: 'references',
|
|
28
28
|
uri,
|
|
29
|
-
|
|
29
|
+
range,
|
|
30
30
|
pluginId,
|
|
31
31
|
}));
|
|
32
32
|
codeLens = [
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare const showReferencesCommand: string;
|
|
4
|
-
export type ShowReferencesCommandData = [string, vscode.Position, vscode.Location[]];
|
|
5
3
|
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.register =
|
|
2
|
+
exports.register = void 0;
|
|
3
3
|
const vscode = require("vscode-languageserver-protocol");
|
|
4
4
|
const references = require("./references");
|
|
5
|
-
exports.showReferencesCommand = `volar.${Math.random().toString(36).slice(2)}.show-references`;
|
|
6
5
|
function register(context) {
|
|
7
6
|
const findReferences = references.register(context);
|
|
8
7
|
return async (item, token = vscode.CancellationToken.None) => {
|
|
@@ -19,14 +18,10 @@ function register(context) {
|
|
|
19
18
|
let references = await findReferences(data.uri, item.range.start, token) ?? [];
|
|
20
19
|
const plugin = context.plugins[data.pluginId];
|
|
21
20
|
const document = context.getTextDocument(data.uri);
|
|
22
|
-
if (document && plugin.
|
|
23
|
-
references = await plugin.
|
|
21
|
+
if (document && plugin.resolveReferencesCodeLensLocations) {
|
|
22
|
+
references = await plugin.resolveReferencesCodeLensLocations(document, data.range, references, token);
|
|
24
23
|
}
|
|
25
|
-
item.command =
|
|
26
|
-
title: references.length === 1 ? '1 reference' : `${references.length} references`,
|
|
27
|
-
command: exports.showReferencesCommand,
|
|
28
|
-
arguments: [data.uri, data.location.range.start, references],
|
|
29
|
-
};
|
|
24
|
+
item.command = context.commands.createShowReferencesCommand(data.uri, data.range.start, references);
|
|
30
25
|
}
|
|
31
26
|
return item;
|
|
32
27
|
};
|
|
@@ -67,7 +67,7 @@ function register(context, apiName, isValidMapping, isValidMirrorPosition) {
|
|
|
67
67
|
link.targetRange = targetRange ?? targetSelectionRange;
|
|
68
68
|
link.targetSelectionRange = targetSelectionRange;
|
|
69
69
|
}
|
|
70
|
-
if (context.documents.
|
|
70
|
+
if (context.documents.isVirtualFileUri(link.targetUri) && !foundTargetSelectionRange) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
return link;
|
|
@@ -13,7 +13,7 @@ function register(context) {
|
|
|
13
13
|
return;
|
|
14
14
|
return await plugin.provideFileReferences?.(document, token) ?? [];
|
|
15
15
|
}, (data) => data.map(reference => {
|
|
16
|
-
if (!context.documents.
|
|
16
|
+
if (!context.documents.isVirtualFileUri(reference.uri)) {
|
|
17
17
|
return reference;
|
|
18
18
|
}
|
|
19
19
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
@@ -41,7 +41,7 @@ function register(context) {
|
|
|
41
41
|
}, (data) => {
|
|
42
42
|
const results = [];
|
|
43
43
|
for (const reference of data) {
|
|
44
|
-
if (context.documents.
|
|
44
|
+
if (context.documents.isVirtualFileUri(reference.uri)) {
|
|
45
45
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
46
46
|
const range = map.toSourceRange(reference.range, data => !!data.references);
|
|
47
47
|
if (range) {
|
|
@@ -127,7 +127,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
127
127
|
for (const tsUri in tsResult.changeAnnotations) {
|
|
128
128
|
sourceResult.changeAnnotations ??= {};
|
|
129
129
|
const tsAnno = tsResult.changeAnnotations[tsUri];
|
|
130
|
-
if (!documents.
|
|
130
|
+
if (!documents.isVirtualFileUri(tsUri)) {
|
|
131
131
|
sourceResult.changeAnnotations[tsUri] = tsAnno;
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
@@ -140,7 +140,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
140
140
|
}
|
|
141
141
|
for (const tsUri in tsResult.changes) {
|
|
142
142
|
sourceResult.changes ??= {};
|
|
143
|
-
if (!documents.
|
|
143
|
+
if (!documents.isVirtualFileUri(tsUri)) {
|
|
144
144
|
sourceResult.changes[tsUri] = tsResult.changes[tsUri];
|
|
145
145
|
hasResult = true;
|
|
146
146
|
continue;
|
|
@@ -180,7 +180,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
180
180
|
sourceResult.documentChanges ??= [];
|
|
181
181
|
let sourceEdit;
|
|
182
182
|
if (vscode.TextDocumentEdit.is(tsDocEdit)) {
|
|
183
|
-
if (documents.
|
|
183
|
+
if (documents.isVirtualFileUri(tsDocEdit.textDocument.uri)) {
|
|
184
184
|
for (const [_, map] of documents.getMapsByVirtualFileUri(tsDocEdit.textDocument.uri)) {
|
|
185
185
|
sourceEdit = vscode.TextDocumentEdit.create({
|
|
186
186
|
uri: map.sourceFileDocument.uri,
|
|
@@ -230,7 +230,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
230
230
|
sourceEdit = tsDocEdit; // TODO: remove .ts?
|
|
231
231
|
}
|
|
232
232
|
else if (vscode.RenameFile.is(tsDocEdit)) {
|
|
233
|
-
if (!documents.
|
|
233
|
+
if (!documents.isVirtualFileUri(tsDocEdit.oldUri)) {
|
|
234
234
|
sourceEdit = tsDocEdit;
|
|
235
235
|
}
|
|
236
236
|
else {
|
|
@@ -241,7 +241,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
else if (vscode.DeleteFile.is(tsDocEdit)) {
|
|
244
|
-
if (!documents.
|
|
244
|
+
if (!documents.isVirtualFileUri(tsDocEdit.uri)) {
|
|
245
245
|
sourceEdit = tsDocEdit;
|
|
246
246
|
}
|
|
247
247
|
else {
|
|
@@ -313,7 +313,7 @@ function register(context) {
|
|
|
313
313
|
if (_error.relatedInformation) {
|
|
314
314
|
const relatedInfos = [];
|
|
315
315
|
for (const info of _error.relatedInformation) {
|
|
316
|
-
if (context.documents.
|
|
316
|
+
if (context.documents.isVirtualFileUri(info.location.uri)) {
|
|
317
317
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(info.location.uri)) {
|
|
318
318
|
const range = map.toSourceRange(info.location.range, data => !!data.diagnostic);
|
|
319
319
|
if (range) {
|
|
@@ -15,7 +15,7 @@ function register(context) {
|
|
|
15
15
|
if (!embeddedSymbols)
|
|
16
16
|
continue;
|
|
17
17
|
const symbols = embeddedSymbols.map(symbol => transformer.asWorkspaceSymbol(symbol, loc => {
|
|
18
|
-
if (context.documents.
|
|
18
|
+
if (context.documents.isVirtualFileUri(loc.uri)) {
|
|
19
19
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(loc.uri)) {
|
|
20
20
|
const range = map.toSourceRange(loc.range);
|
|
21
21
|
if (range) {
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=command.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -8,23 +8,29 @@ import { URI } from 'vscode-uri';
|
|
|
8
8
|
import { DocumentsAndSourceMaps } from './documents';
|
|
9
9
|
export * from 'vscode-languageserver-protocol';
|
|
10
10
|
export interface LanguageServiceOptions {
|
|
11
|
+
locale?: string;
|
|
12
|
+
rootUri: URI;
|
|
13
|
+
capabilities?: vscode.ClientCapabilities;
|
|
11
14
|
host: LanguageServiceHost;
|
|
12
15
|
config: Config;
|
|
13
16
|
uriToFileName(uri: string): string;
|
|
14
17
|
fileNameToUri(fileName: string): string;
|
|
15
|
-
rootUri: URI;
|
|
16
|
-
locale?: string;
|
|
17
18
|
configurationHost?: ConfigurationHost;
|
|
18
19
|
documentContext?: DocumentContext;
|
|
19
20
|
fileSystemProvider?: FileSystemProvider;
|
|
20
21
|
schemaRequestService?: SchemaRequestService;
|
|
21
22
|
}
|
|
23
|
+
export interface Commands {
|
|
24
|
+
createShowReferencesCommand(uri: string, position: vscode.Position, locations: vscode.Location[]): vscode.Command | undefined;
|
|
25
|
+
createRenameCommand(uri: string, position: vscode.Position): vscode.Command | undefined;
|
|
26
|
+
}
|
|
22
27
|
export interface LanguageServicePluginContext extends LanguageServiceOptions {
|
|
23
28
|
typescript: {
|
|
24
29
|
module: typeof import('typescript/lib/tsserverlibrary');
|
|
25
30
|
languageServiceHost: ts.LanguageServiceHost;
|
|
26
31
|
languageService: ts.LanguageService;
|
|
27
32
|
} | undefined;
|
|
33
|
+
commands: Commands;
|
|
28
34
|
/** @private */
|
|
29
35
|
core: LanguageContext;
|
|
30
36
|
/** @private */
|
|
@@ -101,14 +107,14 @@ export interface LanguageServicePluginInstance {
|
|
|
101
107
|
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
102
108
|
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
103
109
|
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
104
|
-
|
|
110
|
+
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
105
111
|
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
|
106
112
|
provideFileRenameEdits?(oldUri: string, newUri: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
|
|
107
113
|
provideFormattingIndentSensitiveLines?(document: TextDocument, token: vscode.CancellationToken): NullableResult<number[]>;
|
|
108
114
|
resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Result<vscode.CodeLens>;
|
|
109
115
|
resolveCodeAction?(codeAction: vscode.CodeAction, token: vscode.CancellationToken): Result<vscode.CodeAction>;
|
|
110
116
|
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): Result<vscode.CompletionItem>;
|
|
111
|
-
|
|
117
|
+
resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
|
|
112
118
|
resolveRuleContext?(context: RuleContext, ruleType: 'format' | 'syntax' | 'semantic'): Result<RuleContext>;
|
|
113
119
|
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
114
120
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.3",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.4.0-alpha.
|
|
17
|
-
"@volar/source-map": "1.4.0-alpha.
|
|
16
|
+
"@volar/language-core": "1.4.0-alpha.3",
|
|
17
|
+
"@volar/source-map": "1.4.0-alpha.3",
|
|
18
18
|
"typescript-auto-import-cache": "^0.0.1",
|
|
19
19
|
"vscode-html-languageservice": "^5.0.4",
|
|
20
20
|
"vscode-json-languageservice": "^5.2.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
23
23
|
"vscode-uri": "^3.0.7"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "033129d71b355a0f5bbf514c6887ed3a6e083c21"
|
|
26
26
|
}
|