@volar/language-service 1.11.1 → 2.0.0-alpha.0
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/index.d.ts +3 -4
- package/index.js +5 -5
- package/lib/documents.d.ts +26 -40
- package/lib/documents.js +66 -113
- package/lib/features/provideAutoInsertionEdit.d.ts +6 -0
- package/lib/features/provideAutoInsertionEdit.js +40 -0
- package/lib/{languageFeatures/callHierarchy.d.ts → features/provideCallHierarchyItems.d.ts} +1 -2
- package/lib/{languageFeatures/callHierarchy.js → features/provideCallHierarchyItems.js} +33 -23
- package/lib/{languageFeatures/codeActions.d.ts → features/provideCodeActions.d.ts} +1 -13
- package/lib/features/provideCodeActions.js +111 -0
- package/lib/{languageFeatures/codeLens.d.ts → features/provideCodeLenses.d.ts} +6 -6
- package/lib/features/provideCodeLenses.js +61 -0
- package/lib/{documentFeatures/colorPresentations.d.ts → features/provideColorPresentations.d.ts} +0 -1
- package/lib/features/provideColorPresentations.js +46 -0
- package/lib/{languageFeatures/complete.d.ts → features/provideCompletionItems.d.ts} +1 -2
- package/lib/{languageFeatures/complete.js → features/provideCompletionItems.js} +45 -37
- package/lib/features/provideDefinition.d.ts +4 -0
- package/lib/{languageFeatures/definition.js → features/provideDefinition.js} +48 -45
- package/lib/{languageFeatures/validation.d.ts → features/provideDiagnostics.d.ts} +2 -4
- package/lib/{languageFeatures/validation.js → features/provideDiagnostics.js} +30 -124
- package/lib/{documentFeatures/documentColors.d.ts → features/provideDocumentColors.d.ts} +1 -2
- package/lib/features/provideDocumentColors.js +34 -0
- package/lib/features/provideDocumentDropEdits.d.ts +3 -0
- package/lib/features/provideDocumentDropEdits.js +27 -0
- package/lib/{documentFeatures/format.d.ts → features/provideDocumentFormattingEdits.d.ts} +0 -1
- package/lib/{documentFeatures/format.js → features/provideDocumentFormattingEdits.js} +76 -71
- package/lib/{languageFeatures/documentHighlights.d.ts → features/provideDocumentHighlights.d.ts} +0 -1
- package/lib/{languageFeatures/documentHighlights.js → features/provideDocumentHighlights.js} +17 -16
- package/lib/{languageFeatures/documentLinks.d.ts → features/provideDocumentLinks.d.ts} +1 -2
- package/lib/features/provideDocumentLinks.js +50 -0
- package/lib/{languageFeatures/documentSemanticTokens.d.ts → features/provideDocumentSemanticTokens.d.ts} +1 -2
- package/lib/features/provideDocumentSemanticTokens.js +84 -0
- package/lib/{documentFeatures/documentSymbols.d.ts → features/provideDocumentSymbols.d.ts} +0 -1
- package/lib/{documentFeatures/documentSymbols.js → features/provideDocumentSymbols.js} +15 -10
- package/lib/{languageFeatures/fileReferences.d.ts → features/provideFileReferences.d.ts} +0 -1
- package/lib/features/provideFileReferences.js +35 -0
- package/lib/{languageFeatures/fileRename.d.ts → features/provideFileRenameEdits.d.ts} +0 -1
- package/lib/{languageFeatures/fileRename.js → features/provideFileRenameEdits.js} +12 -12
- package/lib/{documentFeatures/foldingRanges.d.ts → features/provideFoldingRanges.d.ts} +0 -1
- package/lib/features/provideFoldingRanges.js +24 -0
- package/lib/{languageFeatures/hover.d.ts → features/provideHover.d.ts} +0 -1
- package/lib/{languageFeatures/hover.js → features/provideHover.js} +11 -11
- package/lib/{languageFeatures/inlayHints.d.ts → features/provideInlayHints.d.ts} +1 -2
- package/lib/features/provideInlayHints.js +84 -0
- package/lib/{documentFeatures/linkedEditingRanges.d.ts → features/provideLinkedEditingRanges.d.ts} +0 -1
- package/lib/features/provideLinkedEditingRanges.js +32 -0
- package/lib/{languageFeatures/references.d.ts → features/provideReferences.d.ts} +0 -1
- package/lib/{languageFeatures/references.js → features/provideReferences.js} +14 -13
- package/lib/{languageFeatures/rename.d.ts → features/provideRenameEdits.d.ts} +0 -3
- package/lib/features/provideRenameEdits.js +126 -0
- package/lib/{languageFeatures/renamePrepare.d.ts → features/provideRenameRange.d.ts} +2 -3
- package/lib/{languageFeatures/renamePrepare.js → features/provideRenameRange.js} +7 -5
- package/lib/{documentFeatures/selectionRanges.d.ts → features/provideSelectionRanges.d.ts} +1 -2
- package/lib/{documentFeatures/selectionRanges.js → features/provideSelectionRanges.js} +18 -15
- package/lib/{languageFeatures/signatureHelp.d.ts → features/provideSignatureHelp.d.ts} +0 -1
- package/lib/{languageFeatures/signatureHelp.js → features/provideSignatureHelp.js} +8 -6
- package/lib/{languageFeatures/workspaceSymbols.d.ts → features/provideWorkspaceSymbols.d.ts} +0 -1
- package/lib/{languageFeatures/workspaceSymbols.js → features/provideWorkspaceSymbols.js} +15 -11
- package/lib/{languageFeatures/codeActionResolve.d.ts → features/resolveCodeAction.d.ts} +0 -1
- package/lib/features/resolveCodeAction.js +27 -0
- package/lib/{languageFeatures/codeLensResolve.d.ts → features/resolveCodeLens.d.ts} +0 -1
- package/lib/features/resolveCodeLens.js +39 -0
- package/lib/{languageFeatures/completeResolve.d.ts → features/resolveCompletionItem.d.ts} +0 -1
- package/lib/features/resolveCompletionItem.js +35 -0
- package/lib/{languageFeatures/documentLinkResolve.d.ts → features/resolveDocumentLink.d.ts} +0 -1
- package/lib/{languageFeatures/documentLinkResolve.js → features/resolveDocumentLink.js} +12 -10
- package/lib/{languageFeatures/inlayHintResolve.d.ts → features/resolveInlayHint.d.ts} +0 -1
- package/lib/{languageFeatures/inlayHintResolve.js → features/resolveInlayHint.js} +4 -4
- package/lib/languageService.d.ts +61 -0
- package/lib/languageService.js +158 -0
- package/lib/types.d.ts +88 -137
- package/lib/types.js +1 -8
- package/lib/utils/SemanticTokensBuilder.d.ts +0 -1
- package/lib/utils/cancellation.d.ts +0 -1
- package/lib/utils/common.d.ts +0 -2
- package/lib/utils/common.js +1 -18
- package/lib/utils/dedupe.d.ts +0 -1
- package/lib/utils/featureWorkers.d.ts +7 -8
- package/lib/utils/featureWorkers.js +37 -93
- package/lib/utils/transform.d.ts +19 -0
- package/lib/utils/transform.js +375 -0
- package/package.json +3 -4
- package/lib/baseLanguageService.d.ts +0 -112
- package/lib/baseLanguageService.js +0 -231
- package/lib/documentFeatures/colorPresentations.js +0 -37
- package/lib/documentFeatures/documentColors.js +0 -26
- package/lib/documentFeatures/foldingRanges.js +0 -17
- package/lib/documentFeatures/linkedEditingRanges.js +0 -20
- package/lib/languageFeatures/autoInsert.d.ts +0 -4
- package/lib/languageFeatures/autoInsert.js +0 -42
- package/lib/languageFeatures/codeActionResolve.js +0 -51
- package/lib/languageFeatures/codeActions.js +0 -177
- package/lib/languageFeatures/codeLens.js +0 -53
- package/lib/languageFeatures/codeLensResolve.js +0 -31
- package/lib/languageFeatures/completeResolve.js +0 -32
- package/lib/languageFeatures/definition.d.ts +0 -5
- package/lib/languageFeatures/documentLinks.js +0 -66
- package/lib/languageFeatures/documentSemanticTokens.js +0 -70
- package/lib/languageFeatures/fileReferences.js +0 -32
- package/lib/languageFeatures/inlayHints.js +0 -75
- package/lib/languageFeatures/rename.js +0 -291
- package/lib/transformer/completionItem.d.ts +0 -3
- package/lib/transformer/completionItem.js +0 -18
- package/lib/transformer/completionList.d.ts +0 -3
- package/lib/transformer/completionList.js +0 -27
- package/lib/transformer/documentSymbol.d.ts +0 -3
- package/lib/transformer/documentSymbol.js +0 -24
- package/lib/transformer/foldingRanges.d.ts +0 -3
- package/lib/transformer/foldingRanges.js +0 -24
- package/lib/transformer/hover.d.ts +0 -3
- package/lib/transformer/hover.js +0 -17
- package/lib/transformer/index.d.ts +0 -12
- package/lib/transformer/index.js +0 -26
- package/lib/transformer/locationLike.d.ts +0 -5
- package/lib/transformer/locationLike.js +0 -14
- package/lib/transformer/locationsLike.d.ts +0 -5
- package/lib/transformer/locationsLike.js +0 -12
- package/lib/transformer/selectionRange.d.ts +0 -3
- package/lib/transformer/selectionRange.js +0 -15
- package/lib/transformer/selectionRanges.d.ts +0 -3
- package/lib/transformer/selectionRanges.js +0 -12
- package/lib/transformer/textEdit.d.ts +0 -3
- package/lib/transformer/textEdit.js +0 -72
- package/lib/transformer/workspaceSymbol.d.ts +0 -3
- package/lib/transformer/workspaceSymbol.js +0 -18
- package/lib/utils/definePlugin.d.ts +0 -4
- package/lib/utils/definePlugin.js +0 -20
package/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from '@volar/language-core';
|
|
2
|
-
export * from './lib/
|
|
2
|
+
export * from './lib/languageService';
|
|
3
3
|
export * from './lib/documents';
|
|
4
|
-
export { mergeWorkspaceEdits } from './lib/
|
|
4
|
+
export { mergeWorkspaceEdits } from './lib/features/provideRenameEdits';
|
|
5
5
|
export * from './lib/types';
|
|
6
|
-
export *
|
|
6
|
+
export * from './lib/utils/transform';
|
|
7
7
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
8
8
|
export declare const standardSemanticTokensLegend: vscode.SemanticTokensLegend;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -14,14 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.standardSemanticTokensLegend = exports.
|
|
17
|
+
exports.standardSemanticTokensLegend = exports.mergeWorkspaceEdits = void 0;
|
|
18
18
|
__exportStar(require("@volar/language-core"), exports);
|
|
19
|
-
__exportStar(require("./lib/
|
|
19
|
+
__exportStar(require("./lib/languageService"), exports);
|
|
20
20
|
__exportStar(require("./lib/documents"), exports);
|
|
21
|
-
var
|
|
22
|
-
Object.defineProperty(exports, "mergeWorkspaceEdits", { enumerable: true, get: function () { return
|
|
21
|
+
var provideRenameEdits_1 = require("./lib/features/provideRenameEdits");
|
|
22
|
+
Object.defineProperty(exports, "mergeWorkspaceEdits", { enumerable: true, get: function () { return provideRenameEdits_1.mergeWorkspaceEdits; } });
|
|
23
23
|
__exportStar(require("./lib/types"), exports);
|
|
24
|
-
|
|
24
|
+
__exportStar(require("./lib/utils/transform"), exports);
|
|
25
25
|
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
|
|
26
26
|
exports.standardSemanticTokensLegend = {
|
|
27
27
|
tokenTypes: [
|
package/lib/documents.d.ts
CHANGED
|
@@ -1,51 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { FileProvider, CodeInformation, LinkedCodeMap, SourceFile, VirtualFile, SourceMap, Mapping, CodeRangeKey } from '@volar/language-core';
|
|
2
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
-
|
|
6
|
-
import { ServiceEnvironment } from './types';
|
|
7
|
-
export type DocumentsAndSourceMaps = ReturnType<typeof createDocumentsAndSourceMaps>;
|
|
5
|
+
export type DocumentProvider = ReturnType<typeof createDocumentProvider>;
|
|
8
6
|
export declare class SourceMapWithDocuments<Data = any> {
|
|
9
7
|
sourceFileDocument: TextDocument;
|
|
10
8
|
virtualFileDocument: TextDocument;
|
|
11
9
|
map: SourceMap<Data>;
|
|
12
10
|
constructor(sourceFileDocument: TextDocument, virtualFileDocument: TextDocument, map: SourceMap<Data>);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
protected
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
protected
|
|
25
|
-
protected matchSourcePosition(position: vscode.Position, mapping: Mapping
|
|
26
|
-
protected matchGeneratedPosition(position: vscode.Position, mapping: Mapping
|
|
11
|
+
getSourceRange(range: vscode.Range, filter?: (data: Data) => boolean): vscode.Range | undefined;
|
|
12
|
+
getGeneratedRange(range: vscode.Range, filter?: (data: Data) => boolean): vscode.Range | undefined;
|
|
13
|
+
getSourceRanges(range: vscode.Range, filter?: (data: Data) => boolean): Generator<vscode.Range, void, unknown>;
|
|
14
|
+
getGeneratedRanges(range: vscode.Range, filter?: (data: Data) => boolean): Generator<vscode.Range, void, unknown>;
|
|
15
|
+
protected findRanges(range: vscode.Range, filter: (data: Data) => boolean, api: 'getSourcePositionsBase' | 'getGeneratedPositionsBase', api2: 'matchSourcePosition' | 'matchGeneratedPosition'): Generator<vscode.Range, void, unknown>;
|
|
16
|
+
getSourcePosition(position: vscode.Position, filter?: (data: Data) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
|
|
17
|
+
getGeneratedPosition(position: vscode.Position, filter?: (data: Data) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
|
|
18
|
+
getSourcePositions(position: vscode.Position, filter?: (data: Data) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
19
|
+
getGeneratedPositions(position: vscode.Position, filter?: (data: Data) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
20
|
+
getSourcePositionsBase(position: vscode.Position, filter?: (data: Data) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<Data>], void, unknown>;
|
|
21
|
+
getGeneratedPositionsBase(position: vscode.Position, filter?: (data: Data) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<Data>], void, unknown>;
|
|
22
|
+
protected findPositions(position: vscode.Position, filter: (data: Data) => boolean, fromDoc: TextDocument, toDoc: TextDocument, from: CodeRangeKey, to: CodeRangeKey): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<Data>], void, unknown>;
|
|
23
|
+
protected matchSourcePosition(position: vscode.Position, mapping: Mapping): import("vscode-languageserver-textdocument").Position | undefined;
|
|
24
|
+
protected matchGeneratedPosition(position: vscode.Position, mapping: Mapping): import("vscode-languageserver-textdocument").Position | undefined;
|
|
27
25
|
}
|
|
28
|
-
export declare class
|
|
26
|
+
export declare class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
|
|
29
27
|
document: TextDocument;
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
private linkedMap;
|
|
29
|
+
constructor(document: TextDocument, linkedMap: LinkedCodeMap);
|
|
30
|
+
getLinkedCodePositions(posotion: vscode.Position): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
32
31
|
}
|
|
33
|
-
export declare function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
getMapsBySourceFileUri(uri: string): {
|
|
39
|
-
snapshot: ts.IScriptSnapshot;
|
|
40
|
-
maps: [VirtualFile, SourceMapWithDocuments<FileRangeCapabilities>][];
|
|
41
|
-
} | undefined;
|
|
42
|
-
getMapsBySourceFileName(fileName: string): {
|
|
43
|
-
snapshot: ts.IScriptSnapshot;
|
|
44
|
-
maps: [VirtualFile, SourceMapWithDocuments<FileRangeCapabilities>][];
|
|
45
|
-
} | undefined;
|
|
46
|
-
getMapsByVirtualFileUri(virtualFileUri: string): IterableIterator<[VirtualFile, SourceMapWithDocuments<FileRangeCapabilities>]>;
|
|
47
|
-
getMapsByVirtualFileName(virtualFileName: string): IterableIterator<[VirtualFile, SourceMapWithDocuments<FileRangeCapabilities>]>;
|
|
48
|
-
getDocumentByUri(snapshot: ts.IScriptSnapshot, uri: string): TextDocument;
|
|
49
|
-
getDocumentByFileName: (snapshot: ts.IScriptSnapshot, fileName: string) => TextDocument;
|
|
32
|
+
export declare function createDocumentProvider(files: FileProvider): {
|
|
33
|
+
get: (uri: string, languageId: string, snapshot: ts.IScriptSnapshot) => TextDocument;
|
|
34
|
+
getSourceFileMaps(source: SourceFile): [VirtualFile, SourceMapWithDocuments<CodeInformation>][] | undefined;
|
|
35
|
+
getMaps(virtualFile: VirtualFile): Generator<SourceMapWithDocuments<CodeInformation>, void, unknown>;
|
|
36
|
+
getLinkedCodeMap(virtualFile: VirtualFile): LinkedCodeMapWithDocument | undefined;
|
|
50
37
|
};
|
|
51
|
-
//# sourceMappingURL=documents.d.ts.map
|
package/lib/documents.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createDocumentProvider = exports.LinkedCodeMapWithDocument = exports.SourceMapWithDocuments = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
6
|
-
const common_1 = require("./utils/common");
|
|
7
6
|
class SourceMapWithDocuments {
|
|
8
7
|
constructor(sourceFileDocument, virtualFileDocument, map) {
|
|
9
8
|
this.sourceFileDocument = sourceFileDocument;
|
|
@@ -11,30 +10,30 @@ class SourceMapWithDocuments {
|
|
|
11
10
|
this.map = map;
|
|
12
11
|
}
|
|
13
12
|
// Range APIs
|
|
14
|
-
|
|
15
|
-
for (const result of this.
|
|
13
|
+
getSourceRange(range, filter = () => true) {
|
|
14
|
+
for (const result of this.getSourceRanges(range, filter)) {
|
|
16
15
|
return result;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
for (const result of this.
|
|
18
|
+
getGeneratedRange(range, filter = () => true) {
|
|
19
|
+
for (const result of this.getGeneratedRanges(range, filter)) {
|
|
21
20
|
return result;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
*
|
|
25
|
-
for (const result of this.
|
|
23
|
+
*getSourceRanges(range, filter = () => true) {
|
|
24
|
+
for (const result of this.findRanges(range, filter, 'getSourcePositionsBase', 'matchSourcePosition')) {
|
|
26
25
|
yield result;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
*
|
|
30
|
-
for (const result of this.
|
|
28
|
+
*getGeneratedRanges(range, filter = () => true) {
|
|
29
|
+
for (const result of this.findRanges(range, filter, 'getGeneratedPositionsBase', 'matchGeneratedPosition')) {
|
|
31
30
|
yield result;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
*
|
|
33
|
+
*findRanges(range, filter, api, api2) {
|
|
35
34
|
const failedLookUps = [];
|
|
36
|
-
for (const mapped of this[api](range.start, filter
|
|
37
|
-
const end = this[api2](range.end, mapped[1]
|
|
35
|
+
for (const mapped of this[api](range.start, filter)) {
|
|
36
|
+
const end = this[api2](range.end, mapped[1]);
|
|
38
37
|
if (end) {
|
|
39
38
|
yield { start: mapped[0], end };
|
|
40
39
|
}
|
|
@@ -43,174 +42,128 @@ class SourceMapWithDocuments {
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
for (const failedLookUp of failedLookUps) {
|
|
46
|
-
for (const mapped of this[api](range.end, filter
|
|
45
|
+
for (const mapped of this[api](range.end, filter)) {
|
|
47
46
|
yield { start: failedLookUp[0], end: mapped[0] };
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
// Position APIs
|
|
52
|
-
|
|
53
|
-
for (const mapped of this.
|
|
51
|
+
getSourcePosition(position, filter = () => true) {
|
|
52
|
+
for (const mapped of this.getSourcePositions(position, filter)) {
|
|
54
53
|
return mapped;
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
for (const mapped of this.
|
|
56
|
+
getGeneratedPosition(position, filter = () => true) {
|
|
57
|
+
for (const mapped of this.getGeneratedPositions(position, filter)) {
|
|
59
58
|
return mapped;
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
*
|
|
63
|
-
for (const mapped of this.
|
|
61
|
+
*getSourcePositions(position, filter = () => true) {
|
|
62
|
+
for (const mapped of this.getSourcePositionsBase(position, filter)) {
|
|
64
63
|
yield mapped[0];
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
|
-
*
|
|
68
|
-
for (const mapped of this.
|
|
66
|
+
*getGeneratedPositions(position, filter = () => true) {
|
|
67
|
+
for (const mapped of this.getGeneratedPositionsBase(position, filter)) {
|
|
69
68
|
yield mapped[0];
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
for (const mapped of this.toPositions(position, filter, this.virtualFileDocument, this.sourceFileDocument, 'generatedRange', 'sourceRange', baseOffset ?? 'left')) {
|
|
75
|
-
hasResult = true;
|
|
71
|
+
*getSourcePositionsBase(position, filter = () => true) {
|
|
72
|
+
for (const mapped of this.findPositions(position, filter, this.virtualFileDocument, this.sourceFileDocument, 'generatedOffsets', 'sourceOffsets')) {
|
|
76
73
|
yield mapped;
|
|
77
74
|
}
|
|
78
|
-
if (!hasResult && baseOffset === undefined) {
|
|
79
|
-
for (const mapped of this.toPositions(position, filter, this.virtualFileDocument, this.sourceFileDocument, 'generatedRange', 'sourceRange', 'right')) {
|
|
80
|
-
yield mapped;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
75
|
}
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
for (const mapped of this.toPositions(position, filter, this.sourceFileDocument, this.virtualFileDocument, 'sourceRange', 'generatedRange', baseOffset ?? 'left')) {
|
|
87
|
-
hasResult = true;
|
|
76
|
+
*getGeneratedPositionsBase(position, filter = () => true) {
|
|
77
|
+
for (const mapped of this.findPositions(position, filter, this.sourceFileDocument, this.virtualFileDocument, 'sourceOffsets', 'generatedOffsets')) {
|
|
88
78
|
yield mapped;
|
|
89
79
|
}
|
|
90
|
-
if (!hasResult && baseOffset === undefined) {
|
|
91
|
-
for (const mapped of this.toPositions(position, filter, this.sourceFileDocument, this.virtualFileDocument, 'sourceRange', 'generatedRange', 'right')) {
|
|
92
|
-
yield mapped;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
80
|
}
|
|
96
|
-
*
|
|
97
|
-
for (const mapped of this.map.
|
|
81
|
+
*findPositions(position, filter, fromDoc, toDoc, from, to) {
|
|
82
|
+
for (const mapped of this.map.findMatching(fromDoc.offsetAt(position), from, to)) {
|
|
98
83
|
if (!filter(mapped[1].data)) {
|
|
99
84
|
continue;
|
|
100
85
|
}
|
|
101
86
|
yield [toDoc.positionAt(mapped[0]), mapped[1]];
|
|
102
87
|
}
|
|
103
88
|
}
|
|
104
|
-
matchSourcePosition(position, mapping
|
|
105
|
-
let offset =
|
|
89
|
+
matchSourcePosition(position, mapping) {
|
|
90
|
+
let offset = (0, language_core_1.translateOffset)(this.virtualFileDocument.offsetAt(position), mapping.generatedOffsets, mapping.sourceOffsets, mapping.lengths);
|
|
106
91
|
if (offset !== undefined) {
|
|
107
92
|
return this.sourceFileDocument.positionAt(offset);
|
|
108
93
|
}
|
|
109
94
|
}
|
|
110
|
-
matchGeneratedPosition(position, mapping
|
|
111
|
-
let offset =
|
|
95
|
+
matchGeneratedPosition(position, mapping) {
|
|
96
|
+
let offset = (0, language_core_1.translateOffset)(this.sourceFileDocument.offsetAt(position), mapping.sourceOffsets, mapping.generatedOffsets, mapping.lengths);
|
|
112
97
|
if (offset !== undefined) {
|
|
113
98
|
return this.virtualFileDocument.positionAt(offset);
|
|
114
99
|
}
|
|
115
100
|
}
|
|
116
101
|
}
|
|
117
102
|
exports.SourceMapWithDocuments = SourceMapWithDocuments;
|
|
118
|
-
class
|
|
119
|
-
constructor(document,
|
|
120
|
-
super(document, document,
|
|
103
|
+
class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
|
|
104
|
+
constructor(document, linkedMap) {
|
|
105
|
+
super(document, document, linkedMap);
|
|
121
106
|
this.document = document;
|
|
107
|
+
this.linkedMap = linkedMap;
|
|
122
108
|
}
|
|
123
|
-
*
|
|
124
|
-
for (const
|
|
125
|
-
yield
|
|
126
|
-
}
|
|
127
|
-
for (const mapped of this.toSourcePositionsBase(start)) {
|
|
128
|
-
yield [mapped[0], mapped[1].data[0]];
|
|
109
|
+
*getLinkedCodePositions(posotion) {
|
|
110
|
+
for (const linkedPosition of this.linkedMap.getLinkedOffsets(this.document.offsetAt(posotion))) {
|
|
111
|
+
yield this.document.positionAt(linkedPosition);
|
|
129
112
|
}
|
|
130
113
|
}
|
|
131
114
|
}
|
|
132
|
-
exports.
|
|
133
|
-
function
|
|
115
|
+
exports.LinkedCodeMapWithDocument = LinkedCodeMapWithDocument;
|
|
116
|
+
function createDocumentProvider(files) {
|
|
134
117
|
let version = 0;
|
|
135
118
|
const map2DocMap = new WeakMap();
|
|
136
119
|
const mirrorMap2DocMirrorMap = new WeakMap();
|
|
137
120
|
const snapshot2Doc = new WeakMap();
|
|
138
121
|
return {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
isVirtualFileUri(virtualFileUri) {
|
|
143
|
-
return mapper.hasVirtualFile(env.uriToFileName(virtualFileUri));
|
|
144
|
-
},
|
|
145
|
-
getVirtualFileByUri(virtualFileUri) {
|
|
146
|
-
return mapper.getVirtualFile(env.uriToFileName(virtualFileUri));
|
|
147
|
-
},
|
|
148
|
-
getMirrorMapByUri(virtualFileUri) {
|
|
149
|
-
const fileName = env.uriToFileName(virtualFileUri);
|
|
150
|
-
const [virtualFile] = mapper.getVirtualFile(fileName);
|
|
151
|
-
if (virtualFile) {
|
|
152
|
-
const map = mapper.getMirrorMap(virtualFile);
|
|
153
|
-
if (map) {
|
|
154
|
-
if (!mirrorMap2DocMirrorMap.has(map)) {
|
|
155
|
-
mirrorMap2DocMirrorMap.set(map, new MirrorMapWithDocument(getDocumentByFileName(virtualFile.snapshot, fileName), map));
|
|
156
|
-
}
|
|
157
|
-
return [virtualFile, mirrorMap2DocMirrorMap.get(map)];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
getMapsBySourceFileUri(uri) {
|
|
162
|
-
return this.getMapsBySourceFileName(env.uriToFileName(uri));
|
|
163
|
-
},
|
|
164
|
-
getMapsBySourceFileName(fileName) {
|
|
165
|
-
const source = mapper.getSource(fileName);
|
|
166
|
-
if (source) {
|
|
122
|
+
get,
|
|
123
|
+
getSourceFileMaps(source) {
|
|
124
|
+
if (source.virtualFile) {
|
|
167
125
|
const result = [];
|
|
168
|
-
(0, language_core_1.forEachEmbeddedFile)(source.
|
|
169
|
-
for (const [
|
|
126
|
+
for (const virtualFile of (0, language_core_1.forEachEmbeddedFile)(source.virtualFile[0])) {
|
|
127
|
+
for (const [sourceUri, [sourceSnapshot, map]] of files.getMaps(virtualFile)) {
|
|
170
128
|
if (sourceSnapshot === source.snapshot) {
|
|
171
129
|
if (!map2DocMap.has(map)) {
|
|
172
|
-
map2DocMap.set(map, new SourceMapWithDocuments(
|
|
130
|
+
map2DocMap.set(map, new SourceMapWithDocuments(get(sourceUri, source.languageId, sourceSnapshot), get(virtualFile.id, virtualFile.languageId, virtualFile.snapshot), map));
|
|
173
131
|
}
|
|
174
132
|
result.push([virtualFile, map2DocMap.get(map)]);
|
|
175
133
|
}
|
|
176
134
|
}
|
|
177
|
-
}
|
|
178
|
-
return
|
|
179
|
-
snapshot: source.snapshot,
|
|
180
|
-
maps: result,
|
|
181
|
-
};
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
182
137
|
}
|
|
183
138
|
},
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const [virtualFile] = mapper.getVirtualFile(virtualFileName);
|
|
189
|
-
if (virtualFile) {
|
|
190
|
-
for (const [sourceFileName, [sourceSnapshot, map]] of mapper.getMaps(virtualFile)) {
|
|
191
|
-
if (!map2DocMap.has(map)) {
|
|
192
|
-
map2DocMap.set(map, new SourceMapWithDocuments(getDocumentByFileName(sourceSnapshot, sourceFileName), getDocumentByFileName(virtualFile.snapshot, virtualFileName), map));
|
|
193
|
-
}
|
|
194
|
-
yield [virtualFile, map2DocMap.get(map)];
|
|
139
|
+
*getMaps(virtualFile) {
|
|
140
|
+
for (const [sourceUri, [sourceSnapshot, map]] of files.getMaps(virtualFile)) {
|
|
141
|
+
if (!map2DocMap.has(map)) {
|
|
142
|
+
map2DocMap.set(map, new SourceMapWithDocuments(get(sourceUri, files.getSourceFile(sourceUri).languageId, sourceSnapshot), get(virtualFile.id, virtualFile.languageId, virtualFile.snapshot), map));
|
|
195
143
|
}
|
|
144
|
+
yield map2DocMap.get(map);
|
|
196
145
|
}
|
|
197
146
|
},
|
|
198
|
-
|
|
199
|
-
|
|
147
|
+
getLinkedCodeMap(virtualFile) {
|
|
148
|
+
const map = files.getLinkedCodeMap(virtualFile);
|
|
149
|
+
if (map) {
|
|
150
|
+
if (!mirrorMap2DocMirrorMap.has(map)) {
|
|
151
|
+
mirrorMap2DocMirrorMap.set(map, new LinkedCodeMapWithDocument(get(virtualFile.id, virtualFile.languageId, virtualFile.snapshot), map));
|
|
152
|
+
}
|
|
153
|
+
return mirrorMap2DocMirrorMap.get(map);
|
|
154
|
+
}
|
|
200
155
|
},
|
|
201
|
-
getDocumentByFileName,
|
|
202
156
|
};
|
|
203
|
-
function
|
|
157
|
+
function get(uri, languageId, snapshot) {
|
|
204
158
|
if (!snapshot2Doc.has(snapshot)) {
|
|
205
159
|
snapshot2Doc.set(snapshot, new Map());
|
|
206
160
|
}
|
|
207
161
|
const map = snapshot2Doc.get(snapshot);
|
|
208
|
-
if (!map.has(
|
|
209
|
-
|
|
210
|
-
map.set(fileName, vscode_languageserver_textdocument_1.TextDocument.create(uri, host.getLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), version++, snapshot.getText(0, snapshot.getLength())));
|
|
162
|
+
if (!map.has(uri)) {
|
|
163
|
+
map.set(uri, vscode_languageserver_textdocument_1.TextDocument.create(uri, languageId, version++, snapshot.getText(0, snapshot.getLength())));
|
|
211
164
|
}
|
|
212
|
-
return map.get(
|
|
165
|
+
return map.get(uri);
|
|
213
166
|
}
|
|
214
167
|
}
|
|
215
|
-
exports.
|
|
168
|
+
exports.createDocumentProvider = createDocumentProvider;
|
|
216
169
|
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, lastChange: {
|
|
4
|
+
range: vscode.Range;
|
|
5
|
+
text: string;
|
|
6
|
+
}, token?: vscode.CancellationToken) => Promise<string | vscode.TextEdit | undefined>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
+
const language_core_1 = require("@volar/language-core");
|
|
7
|
+
function register(context) {
|
|
8
|
+
return (uri, position, lastChange, token = cancellation_1.NoneCancellationToken) => {
|
|
9
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ position, lastChange }), function* (map) {
|
|
10
|
+
for (const mappedPosition of map.getGeneratedPositions(position, language_core_1.isAutoInsertEnabled)) {
|
|
11
|
+
const range = map.getGeneratedRange(lastChange.range);
|
|
12
|
+
if (range) {
|
|
13
|
+
yield {
|
|
14
|
+
position: mappedPosition,
|
|
15
|
+
lastChange: {
|
|
16
|
+
text: lastChange.text,
|
|
17
|
+
range,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}, (service, document, args) => {
|
|
23
|
+
if (token.isCancellationRequested) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return service[1].provideAutoInsertionEdit?.(document, args.position, args.lastChange, token);
|
|
27
|
+
}, (item, map) => {
|
|
28
|
+
if (!map || typeof item === 'string') {
|
|
29
|
+
return item;
|
|
30
|
+
}
|
|
31
|
+
const range = map.getSourceRange(item.range, language_core_1.isAutoInsertEnabled);
|
|
32
|
+
if (range) {
|
|
33
|
+
item.range = range;
|
|
34
|
+
return item;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.register = register;
|
|
40
|
+
//# sourceMappingURL=provideAutoInsertionEdit.js.map
|
|
@@ -3,7 +3,7 @@ import type { ServiceContext } from '../types';
|
|
|
3
3
|
export interface PluginCallHierarchyData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
|
6
|
-
|
|
6
|
+
serviceIndex: number;
|
|
7
7
|
virtualDocumentUri: string | undefined;
|
|
8
8
|
}
|
|
9
9
|
export declare function register(context: ServiceContext): {
|
|
@@ -11,4 +11,3 @@ export declare function register(context: ServiceContext): {
|
|
|
11
11
|
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
12
12
|
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=callHierarchy.d.ts.map
|
|
@@ -5,39 +5,47 @@ const common_1 = require("../utils/common");
|
|
|
5
5
|
const dedupe = require("../utils/dedupe");
|
|
6
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
7
|
const cancellation_1 = require("../utils/cancellation");
|
|
8
|
+
const language_core_1 = require("@volar/language-core");
|
|
8
9
|
function register(context) {
|
|
9
10
|
return {
|
|
10
11
|
doPrepare(uri, position, token = cancellation_1.NoneCancellationToken) {
|
|
11
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri,
|
|
12
|
-
if (token.isCancellationRequested)
|
|
12
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, data => (0, language_core_1.isCallHierarchyEnabled)(data)), async (service, document, position, map) => {
|
|
13
|
+
if (token.isCancellationRequested) {
|
|
13
14
|
return;
|
|
14
|
-
|
|
15
|
+
}
|
|
16
|
+
const items = await service[1].provideCallHierarchyItems?.(document, position, token);
|
|
15
17
|
items?.forEach(item => {
|
|
16
18
|
item.data = {
|
|
17
19
|
uri,
|
|
18
20
|
original: {
|
|
19
21
|
data: item.data,
|
|
20
22
|
},
|
|
21
|
-
|
|
23
|
+
serviceIndex: context.services.indexOf(service),
|
|
22
24
|
virtualDocumentUri: map?.virtualFileDocument.uri,
|
|
23
25
|
};
|
|
24
26
|
});
|
|
25
27
|
return items;
|
|
26
|
-
}, (data,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
}, (data, map) => {
|
|
29
|
+
if (!map) {
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
return data
|
|
33
|
+
.map(item => transformCallHierarchyItem(item, [])?.[0])
|
|
34
|
+
.filter(common_1.notEmpty);
|
|
35
|
+
}, arr => dedupe.withLocations(arr.flat()));
|
|
29
36
|
},
|
|
30
37
|
async getIncomingCalls(item, token) {
|
|
31
38
|
const data = item.data;
|
|
32
39
|
let incomingItems = [];
|
|
33
40
|
if (data) {
|
|
34
|
-
const service = context.services[data.
|
|
35
|
-
if (!service.provideCallHierarchyIncomingCalls)
|
|
41
|
+
const service = context.services[data.serviceIndex];
|
|
42
|
+
if (!service[1].provideCallHierarchyIncomingCalls)
|
|
36
43
|
return incomingItems;
|
|
37
44
|
Object.assign(item, data.original);
|
|
38
45
|
if (data.virtualDocumentUri) {
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
const [virtualFile] = context.language.files.getVirtualFile(data.virtualDocumentUri);
|
|
47
|
+
if (virtualFile) {
|
|
48
|
+
const _calls = await service[1].provideCallHierarchyIncomingCalls(item, token);
|
|
41
49
|
for (const _call of _calls) {
|
|
42
50
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
43
51
|
if (!calls)
|
|
@@ -50,7 +58,7 @@ function register(context) {
|
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
else {
|
|
53
|
-
const _calls = await service.provideCallHierarchyIncomingCalls(item, token);
|
|
61
|
+
const _calls = await service[1].provideCallHierarchyIncomingCalls(item, token);
|
|
54
62
|
for (const _call of _calls) {
|
|
55
63
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
56
64
|
if (!calls)
|
|
@@ -68,13 +76,14 @@ function register(context) {
|
|
|
68
76
|
const data = item.data;
|
|
69
77
|
let items = [];
|
|
70
78
|
if (data) {
|
|
71
|
-
const service = context.services[data.
|
|
72
|
-
if (!service.provideCallHierarchyOutgoingCalls)
|
|
79
|
+
const service = context.services[data.serviceIndex];
|
|
80
|
+
if (!service[1].provideCallHierarchyOutgoingCalls)
|
|
73
81
|
return items;
|
|
74
82
|
Object.assign(item, data.original);
|
|
75
83
|
if (data.virtualDocumentUri) {
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
const [virtualFile] = context.language.files.getVirtualFile(data.virtualDocumentUri);
|
|
85
|
+
if (virtualFile) {
|
|
86
|
+
const _calls = await service[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
78
87
|
for (const call of _calls) {
|
|
79
88
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
80
89
|
if (!calls)
|
|
@@ -87,7 +96,7 @@ function register(context) {
|
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
98
|
else {
|
|
90
|
-
const _calls = await service.provideCallHierarchyOutgoingCalls(item, token);
|
|
99
|
+
const _calls = await service[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
91
100
|
for (const call of _calls) {
|
|
92
101
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
93
102
|
if (!calls)
|
|
@@ -103,10 +112,11 @@ function register(context) {
|
|
|
103
112
|
},
|
|
104
113
|
};
|
|
105
114
|
function transformCallHierarchyItem(tsItem, tsRanges) {
|
|
106
|
-
|
|
115
|
+
const [virtualFile] = context.language.files.getVirtualFile(tsItem.uri);
|
|
116
|
+
if (!virtualFile)
|
|
107
117
|
return [tsItem, tsRanges];
|
|
108
|
-
for (const
|
|
109
|
-
let range = map.
|
|
118
|
+
for (const map of context.documents.getMaps(virtualFile)) {
|
|
119
|
+
let range = map.getSourceRange(tsItem.range);
|
|
110
120
|
if (!range) {
|
|
111
121
|
// TODO: <script> range
|
|
112
122
|
range = {
|
|
@@ -114,10 +124,10 @@ function register(context) {
|
|
|
114
124
|
end: map.sourceFileDocument.positionAt(map.sourceFileDocument.getText().length),
|
|
115
125
|
};
|
|
116
126
|
}
|
|
117
|
-
const selectionRange = map.
|
|
127
|
+
const selectionRange = map.getSourceRange(tsItem.selectionRange);
|
|
118
128
|
if (!selectionRange)
|
|
119
129
|
continue;
|
|
120
|
-
const vueRanges = tsRanges.map(tsRange => map.
|
|
130
|
+
const vueRanges = tsRanges.map(tsRange => map.getSourceRange(tsRange)).filter(common_1.notEmpty);
|
|
121
131
|
const vueItem = {
|
|
122
132
|
...tsItem,
|
|
123
133
|
name: tsItem.name === map.virtualFileDocument.uri.substring(map.virtualFileDocument.uri.lastIndexOf('/') + 1)
|
|
@@ -140,4 +150,4 @@ function register(context) {
|
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
exports.register = register;
|
|
143
|
-
//# sourceMappingURL=
|
|
153
|
+
//# sourceMappingURL=provideCallHierarchyItems.js.map
|
|
@@ -3,19 +3,7 @@ import type { ServiceContext } from '../types';
|
|
|
3
3
|
export interface ServiceCodeActionData {
|
|
4
4
|
uri: string;
|
|
5
5
|
version: number;
|
|
6
|
-
type: 'service';
|
|
7
6
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export interface RuleCodeActionData {
|
|
11
|
-
uri: string;
|
|
12
|
-
version: number;
|
|
13
|
-
documentUri: string;
|
|
14
|
-
type: 'rule';
|
|
15
|
-
isFormat: boolean;
|
|
16
|
-
ruleId: string;
|
|
17
|
-
ruleFixIndex: number;
|
|
18
|
-
index: number;
|
|
7
|
+
serviceIndex: number;
|
|
19
8
|
}
|
|
20
9
|
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
21
|
-
//# sourceMappingURL=codeActions.d.ts.map
|