@volar/language-service 1.4.0-alpha.2 → 1.4.0-alpha.4
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 +50 -0
- package/out/documentFeatures/colorPresentations.js +1 -0
- package/out/documentFeatures/documentColors.js +1 -0
- package/out/documentFeatures/documentSymbols.js +1 -0
- package/out/documentFeatures/foldingRanges.js +1 -0
- package/out/documentFeatures/format.js +1 -0
- package/out/documentFeatures/linkedEditingRanges.js +1 -0
- package/out/documentFeatures/selectionRanges.js +1 -0
- package/out/documents.d.ts +1 -1
- package/out/documents.js +2 -1
- package/out/index.d.ts +0 -1
- package/out/index.js +2 -3
- package/out/languageFeatures/autoInsert.js +1 -0
- package/out/languageFeatures/callHierarchy.js +4 -3
- package/out/languageFeatures/codeActionResolve.js +1 -0
- package/out/languageFeatures/codeActions.js +10 -11
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +4 -3
- package/out/languageFeatures/codeLensResolve.d.ts +0 -2
- package/out/languageFeatures/codeLensResolve.js +5 -9
- package/out/languageFeatures/complete.js +1 -0
- package/out/languageFeatures/completeResolve.js +1 -0
- package/out/languageFeatures/definition.js +2 -1
- package/out/languageFeatures/documentHighlights.js +1 -0
- package/out/languageFeatures/documentLinks.js +1 -0
- package/out/languageFeatures/documentSemanticTokens.js +1 -0
- package/out/languageFeatures/fileReferences.js +2 -1
- package/out/languageFeatures/fileRename.js +1 -0
- package/out/languageFeatures/hover.js +1 -0
- package/out/languageFeatures/inlayHints.js +1 -0
- package/out/languageFeatures/references.js +2 -1
- package/out/languageFeatures/rename.js +6 -5
- package/out/languageFeatures/renamePrepare.js +1 -0
- package/out/languageFeatures/signatureHelp.js +1 -0
- package/out/languageFeatures/validation.js +8 -17
- package/out/languageFeatures/workspaceSymbols.js +2 -1
- package/out/transformer/completionItem.js +1 -0
- package/out/transformer/completionList.js +1 -0
- package/out/transformer/documentSymbol.js +1 -0
- package/out/transformer/foldingRanges.js +1 -0
- package/out/transformer/hover.js +1 -0
- package/out/transformer/index.js +1 -0
- package/out/transformer/locationLike.js +1 -0
- package/out/transformer/locationsLike.js +1 -0
- package/out/transformer/selectionRange.js +1 -0
- package/out/transformer/selectionRanges.js +1 -0
- package/out/transformer/textEdit.js +1 -0
- package/out/transformer/workspaceSymbol.js +1 -0
- package/out/types.d.ts +10 -4
- package/out/types.js +1 -0
- package/out/utils/SemanticTokensBuilder.js +1 -0
- package/out/utils/common.d.ts +1 -0
- package/out/utils/common.js +1 -0
- package/out/utils/dedupe.js +1 -0
- package/out/utils/definePlugin.js +1 -0
- package/out/utils/featureWorkers.js +1 -0
- 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: "
|
|
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: "semantic" | "all" | "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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.createLanguageService = void 0;
|
|
3
4
|
const language_core_1 = require("@volar/language-core");
|
|
@@ -33,6 +34,8 @@ const foldingRanges = require("./documentFeatures/foldingRanges");
|
|
|
33
34
|
const format = require("./documentFeatures/format");
|
|
34
35
|
const linkedEditingRanges = require("./documentFeatures/linkedEditingRanges");
|
|
35
36
|
const selectionRanges = require("./documentFeatures/selectionRanges");
|
|
37
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
38
|
+
// fix build
|
|
36
39
|
const common_1 = require("./utils/common");
|
|
37
40
|
function createLanguageService(ctx, documentRegistry) {
|
|
38
41
|
const languageContext = (0, language_core_1.createLanguageContext)(ctx.host, Object.values(ctx.config.languages ?? {}).filter(common_1.notEmpty));
|
|
@@ -59,6 +62,36 @@ function createLanguageServiceContext(ctx, languageContext, documentRegistry) {
|
|
|
59
62
|
languageService: tsLs,
|
|
60
63
|
} : undefined,
|
|
61
64
|
documents: textDocumentMapper,
|
|
65
|
+
commands: {
|
|
66
|
+
createRenameCommand(uri, position) {
|
|
67
|
+
const source = toSourceLocation(uri, position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename);
|
|
68
|
+
if (!source) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
return vscode.Command.create('', 'editor.action.rename', source.uri, source.position);
|
|
72
|
+
},
|
|
73
|
+
createShowReferencesCommand(uri, position, locations) {
|
|
74
|
+
const source = toSourceLocation(uri, position);
|
|
75
|
+
if (!source) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const sourceReferences = [];
|
|
79
|
+
for (const reference of locations) {
|
|
80
|
+
if (context.documents.isVirtualFileUri(reference.uri)) {
|
|
81
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
82
|
+
const range = map.toSourceRange(reference.range);
|
|
83
|
+
if (range) {
|
|
84
|
+
sourceReferences.push({ uri: map.sourceFileDocument.uri, range });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
sourceReferences.push(reference);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return vscode.Command.create(locations.length === 1 ? '1 reference' : `${locations.length} references`, 'editor.action.showReferences', source.uri, source.position, sourceReferences);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
62
95
|
getTextDocument,
|
|
63
96
|
};
|
|
64
97
|
for (const pluginId in ctx.config.plugins ?? {}) {
|
|
@@ -72,6 +105,23 @@ function createLanguageServiceContext(ctx, languageContext, documentRegistry) {
|
|
|
72
105
|
}
|
|
73
106
|
}
|
|
74
107
|
return context;
|
|
108
|
+
function toSourceLocation(uri, position, filter) {
|
|
109
|
+
if (!textDocumentMapper.isVirtualFileUri(uri)) {
|
|
110
|
+
return { uri, position };
|
|
111
|
+
}
|
|
112
|
+
const map = textDocumentMapper.getVirtualFileByUri(uri);
|
|
113
|
+
if (map) {
|
|
114
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(uri)) {
|
|
115
|
+
const sourcePosition = map.toSourcePosition(position, filter);
|
|
116
|
+
if (sourcePosition) {
|
|
117
|
+
return {
|
|
118
|
+
uri: map.sourceFileDocument.uri,
|
|
119
|
+
position: sourcePosition,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
75
125
|
function getTextDocument(uri) {
|
|
76
126
|
const fileName = ctx.uriToFileName(uri);
|
|
77
127
|
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.createDocumentsAndSourceMaps = exports.MirrorMapWithDocument = exports.SourceMapWithDocuments = void 0;
|
|
3
4
|
const language_core_1 = require("@volar/language-core");
|
|
@@ -138,7 +139,7 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
138
139
|
getSourceByUri(sourceFileUri) {
|
|
139
140
|
return mapper.getSource(ctx.uriToFileName(sourceFileUri));
|
|
140
141
|
},
|
|
141
|
-
|
|
142
|
+
isVirtualFileUri(virtualFileUri) {
|
|
142
143
|
return mapper.hasVirtualFile(ctx.uriToFileName(virtualFileUri));
|
|
143
144
|
},
|
|
144
145
|
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
3
|
if (k2 === undefined) k2 = k;
|
|
3
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -13,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
13
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
15
|
};
|
|
15
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.standardSemanticTokensLegend = exports.
|
|
17
|
+
exports.standardSemanticTokensLegend = exports.transformer = exports.mergeWorkspaceEdits = void 0;
|
|
17
18
|
__exportStar(require("@volar/language-core"), exports);
|
|
18
19
|
__exportStar(require("./baseLanguageService"), exports);
|
|
19
20
|
__exportStar(require("./documents"), exports);
|
|
@@ -21,8 +22,6 @@ var rename_1 = require("./languageFeatures/rename");
|
|
|
21
22
|
Object.defineProperty(exports, "mergeWorkspaceEdits", { enumerable: true, get: function () { return rename_1.mergeWorkspaceEdits; } });
|
|
22
23
|
__exportStar(require("./types"), exports);
|
|
23
24
|
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
25
|
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
|
|
27
26
|
exports.standardSemanticTokensLegend = {
|
|
28
27
|
tokenTypes: [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const path_1 = require("path");
|
|
@@ -38,7 +39,7 @@ function register(context) {
|
|
|
38
39
|
return incomingItems;
|
|
39
40
|
Object.assign(item, data.original);
|
|
40
41
|
if (data.map) {
|
|
41
|
-
if (context.documents.
|
|
42
|
+
if (context.documents.isVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
42
43
|
const _calls = await plugin.provideCallHierarchyIncomingCalls(item, token);
|
|
43
44
|
for (const _call of _calls) {
|
|
44
45
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
@@ -75,7 +76,7 @@ function register(context) {
|
|
|
75
76
|
return items;
|
|
76
77
|
Object.assign(item, data.original);
|
|
77
78
|
if (data.map) {
|
|
78
|
-
if (context.documents.
|
|
79
|
+
if (context.documents.isVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
79
80
|
const _calls = await plugin.provideCallHierarchyOutgoingCalls(item, token);
|
|
80
81
|
for (const call of _calls) {
|
|
81
82
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
@@ -105,7 +106,7 @@ function register(context) {
|
|
|
105
106
|
},
|
|
106
107
|
};
|
|
107
108
|
function transformCallHierarchyItem(tsItem, tsRanges) {
|
|
108
|
-
if (!context.documents.
|
|
109
|
+
if (!context.documents.isVirtualFileUri(tsItem.uri))
|
|
109
110
|
return [tsItem, tsRanges];
|
|
110
111
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(tsItem.uri)) {
|
|
111
112
|
let range = map.toSourceRange(tsItem.range);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const transformer = require("../transformer");
|
|
@@ -77,19 +78,17 @@ function register(context) {
|
|
|
77
78
|
};
|
|
78
79
|
});
|
|
79
80
|
return codeActions;
|
|
80
|
-
}, (
|
|
81
|
-
if (!
|
|
82
|
-
return
|
|
83
|
-
if (
|
|
84
|
-
const edit = (0, rename_1.embeddedEditToSourceEdit)(
|
|
85
|
-
if (edit) {
|
|
86
|
-
|
|
87
|
-
return _codeAction;
|
|
81
|
+
}, (actions, map) => actions.map(action => {
|
|
82
|
+
if (!map)
|
|
83
|
+
return action;
|
|
84
|
+
if (action.edit) {
|
|
85
|
+
const edit = (0, rename_1.embeddedEditToSourceEdit)(action.edit, context.documents, 'codeAction');
|
|
86
|
+
if (!edit) {
|
|
87
|
+
return;
|
|
88
88
|
}
|
|
89
|
+
action.edit = edit;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
return _codeAction;
|
|
92
|
-
}
|
|
91
|
+
return action;
|
|
93
92
|
}).filter(common_1.notEmpty), arr => dedupe.withCodeAction(arr.flat()));
|
|
94
93
|
const ruleActions = [];
|
|
95
94
|
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[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
@@ -22,11 +23,11 @@ function register(context) {
|
|
|
22
23
|
};
|
|
23
24
|
});
|
|
24
25
|
if (referencesCodeLendsEnabled) {
|
|
25
|
-
const
|
|
26
|
-
const referencesCodeLens =
|
|
26
|
+
const ranges = await plugin.provideReferencesCodeLensRanges?.(document, token);
|
|
27
|
+
const referencesCodeLens = ranges?.map(range => vscode.CodeLens.create(range, {
|
|
27
28
|
kind: 'references',
|
|
28
29
|
uri,
|
|
29
|
-
|
|
30
|
+
range,
|
|
30
31
|
pluginId,
|
|
31
32
|
}));
|
|
32
33
|
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,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.register =
|
|
3
|
+
exports.register = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
4
5
|
const references = require("./references");
|
|
5
|
-
exports.showReferencesCommand = `volar.${Math.random().toString(36).slice(2)}.show-references`;
|
|
6
6
|
function register(context) {
|
|
7
7
|
const findReferences = references.register(context);
|
|
8
8
|
return async (item, token = vscode.CancellationToken.None) => {
|
|
@@ -19,14 +19,10 @@ function register(context) {
|
|
|
19
19
|
let references = await findReferences(data.uri, item.range.start, token) ?? [];
|
|
20
20
|
const plugin = context.plugins[data.pluginId];
|
|
21
21
|
const document = context.getTextDocument(data.uri);
|
|
22
|
-
if (document && plugin.
|
|
23
|
-
references = await plugin.
|
|
22
|
+
if (document && plugin.resolveReferencesCodeLensLocations) {
|
|
23
|
+
references = await plugin.resolveReferencesCodeLensLocations(document, data.range, references, token);
|
|
24
24
|
}
|
|
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
|
-
};
|
|
25
|
+
item.command = context.commands.createShowReferencesCommand(data.uri, data.range.start, references);
|
|
30
26
|
}
|
|
31
27
|
return item;
|
|
32
28
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
@@ -67,7 +68,7 @@ function register(context, apiName, isValidMapping, isValidMirrorPosition) {
|
|
|
67
68
|
link.targetRange = targetRange ?? targetSelectionRange;
|
|
68
69
|
link.targetSelectionRange = targetSelectionRange;
|
|
69
70
|
}
|
|
70
|
-
if (context.documents.
|
|
71
|
+
if (context.documents.isVirtualFileUri(link.targetUri) && !foundTargetSelectionRange) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
return link;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
@@ -13,7 +14,7 @@ function register(context) {
|
|
|
13
14
|
return;
|
|
14
15
|
return await plugin.provideFileReferences?.(document, token) ?? [];
|
|
15
16
|
}, (data) => data.map(reference => {
|
|
16
|
-
if (!context.documents.
|
|
17
|
+
if (!context.documents.isVirtualFileUri(reference.uri)) {
|
|
17
18
|
return reference;
|
|
18
19
|
}
|
|
19
20
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
@@ -41,7 +42,7 @@ function register(context) {
|
|
|
41
42
|
}, (data) => {
|
|
42
43
|
const results = [];
|
|
43
44
|
for (const reference of data) {
|
|
44
|
-
if (context.documents.
|
|
45
|
+
if (context.documents.isVirtualFileUri(reference.uri)) {
|
|
45
46
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
46
47
|
const range = map.toSourceRange(reference.range, data => !!data.references);
|
|
47
48
|
if (range) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.embeddedEditToSourceEdit = exports.mergeWorkspaceEdits = exports.register = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
@@ -127,7 +128,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
127
128
|
for (const tsUri in tsResult.changeAnnotations) {
|
|
128
129
|
sourceResult.changeAnnotations ??= {};
|
|
129
130
|
const tsAnno = tsResult.changeAnnotations[tsUri];
|
|
130
|
-
if (!documents.
|
|
131
|
+
if (!documents.isVirtualFileUri(tsUri)) {
|
|
131
132
|
sourceResult.changeAnnotations[tsUri] = tsAnno;
|
|
132
133
|
}
|
|
133
134
|
else {
|
|
@@ -140,7 +141,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
140
141
|
}
|
|
141
142
|
for (const tsUri in tsResult.changes) {
|
|
142
143
|
sourceResult.changes ??= {};
|
|
143
|
-
if (!documents.
|
|
144
|
+
if (!documents.isVirtualFileUri(tsUri)) {
|
|
144
145
|
sourceResult.changes[tsUri] = tsResult.changes[tsUri];
|
|
145
146
|
hasResult = true;
|
|
146
147
|
continue;
|
|
@@ -180,7 +181,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
180
181
|
sourceResult.documentChanges ??= [];
|
|
181
182
|
let sourceEdit;
|
|
182
183
|
if (vscode.TextDocumentEdit.is(tsDocEdit)) {
|
|
183
|
-
if (documents.
|
|
184
|
+
if (documents.isVirtualFileUri(tsDocEdit.textDocument.uri)) {
|
|
184
185
|
for (const [_, map] of documents.getMapsByVirtualFileUri(tsDocEdit.textDocument.uri)) {
|
|
185
186
|
sourceEdit = vscode.TextDocumentEdit.create({
|
|
186
187
|
uri: map.sourceFileDocument.uri,
|
|
@@ -230,7 +231,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
230
231
|
sourceEdit = tsDocEdit; // TODO: remove .ts?
|
|
231
232
|
}
|
|
232
233
|
else if (vscode.RenameFile.is(tsDocEdit)) {
|
|
233
|
-
if (!documents.
|
|
234
|
+
if (!documents.isVirtualFileUri(tsDocEdit.oldUri)) {
|
|
234
235
|
sourceEdit = tsDocEdit;
|
|
235
236
|
}
|
|
236
237
|
else {
|
|
@@ -241,7 +242,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
else if (vscode.DeleteFile.is(tsDocEdit)) {
|
|
244
|
-
if (!documents.
|
|
245
|
+
if (!documents.isVirtualFileUri(tsDocEdit.uri)) {
|
|
245
246
|
sourceEdit = tsDocEdit;
|
|
246
247
|
}
|
|
247
248
|
else {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = exports.updateRange = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
@@ -283,28 +284,18 @@ function register(context) {
|
|
|
283
284
|
}
|
|
284
285
|
};
|
|
285
286
|
function transformFormatErrorRange(errors, map) {
|
|
286
|
-
|
|
287
|
-
for (const error of errors) {
|
|
288
|
-
// clone it to avoid modify cache
|
|
289
|
-
let _error = { ...error };
|
|
290
|
-
if (map) {
|
|
291
|
-
const range = map.toSourceRange(error.range);
|
|
292
|
-
if (!range) {
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
_error.range = range;
|
|
296
|
-
}
|
|
297
|
-
result.push(_error);
|
|
298
|
-
}
|
|
299
|
-
return result;
|
|
287
|
+
return transformErrorRangeBase(errors, map, () => true);
|
|
300
288
|
}
|
|
301
289
|
function transformErrorRange(errors, map) {
|
|
290
|
+
return transformErrorRangeBase(errors, map, data => !!data.diagnostic);
|
|
291
|
+
}
|
|
292
|
+
function transformErrorRangeBase(errors, map, filter) {
|
|
302
293
|
const result = [];
|
|
303
294
|
for (const error of errors) {
|
|
304
295
|
// clone it to avoid modify cache
|
|
305
296
|
let _error = { ...error };
|
|
306
297
|
if (map) {
|
|
307
|
-
const range = map.toSourceRange(error.range,
|
|
298
|
+
const range = map.toSourceRange(error.range, filter);
|
|
308
299
|
if (!range) {
|
|
309
300
|
continue;
|
|
310
301
|
}
|
|
@@ -313,9 +304,9 @@ function register(context) {
|
|
|
313
304
|
if (_error.relatedInformation) {
|
|
314
305
|
const relatedInfos = [];
|
|
315
306
|
for (const info of _error.relatedInformation) {
|
|
316
|
-
if (context.documents.
|
|
307
|
+
if (context.documents.isVirtualFileUri(info.location.uri)) {
|
|
317
308
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(info.location.uri)) {
|
|
318
|
-
const range = map.toSourceRange(info.location.range,
|
|
309
|
+
const range = map.toSourceRange(info.location.range, filter);
|
|
319
310
|
if (range) {
|
|
320
311
|
relatedInfos.push({
|
|
321
312
|
location: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.register = void 0;
|
|
3
4
|
const transformer = require("../transformer");
|
|
@@ -15,7 +16,7 @@ function register(context) {
|
|
|
15
16
|
if (!embeddedSymbols)
|
|
16
17
|
continue;
|
|
17
18
|
const symbols = embeddedSymbols.map(symbol => transformer.asWorkspaceSymbol(symbol, loc => {
|
|
18
|
-
if (context.documents.
|
|
19
|
+
if (context.documents.isVirtualFileUri(loc.uri)) {
|
|
19
20
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(loc.uri)) {
|
|
20
21
|
const range = map.toSourceRange(loc.range);
|
|
21
22
|
if (range) {
|
package/out/transformer/hover.js
CHANGED
package/out/transformer/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.asWorkspaceSymbol = exports.asDocumentSymbol = exports.asTextEdit = exports.asSelectionRanges = exports.asSelectionRange = exports.asLocations = exports.asLocation = exports.asHover = exports.asFoldingRanges = exports.asCompletionList = exports.asCompletionItem = void 0;
|
|
3
4
|
var completionItem_1 = require("./completionItem");
|
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/out/types.js
CHANGED
package/out/utils/common.d.ts
CHANGED
package/out/utils/common.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.notEmpty = exports.sleep = exports.syntaxToLanguageId = exports.stringToSnapshot = exports.isInsideRange = exports.getOverlapRange = void 0;
|
|
3
4
|
function getOverlapRange(range1Start, range1End, range2Start, range2End) {
|
package/out/utils/dedupe.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.withRanges = exports.withCallHierarchyOutgoingCalls = exports.withCallHierarchyIncomingCalls = exports.withLocationLinks = exports.withLocations = exports.withDiagnostics = exports.withDocumentChanges = exports.withTextEdits = exports.withCodeAction = exports.createLocationSet = void 0;
|
|
3
4
|
function createLocationSet() {
|
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.4",
|
|
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.4",
|
|
17
|
+
"@volar/source-map": "1.4.0-alpha.4",
|
|
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": "b78ceb0a7d185d1e2073c960486d7924f9cda403"
|
|
26
26
|
}
|