@volar/language-service 2.2.5 → 2.3.0-alpha.1
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 +1 -2
- package/index.js +2 -41
- package/lib/documents.d.ts +20 -18
- package/lib/documents.js +5 -3
- package/lib/features/provideAutoInsertSnippet.d.ts +8 -0
- package/lib/features/{provideAutoInsertionEdit.js → provideAutoInsertSnippet.js} +8 -17
- package/lib/features/provideCallHierarchyItems.d.ts +5 -4
- package/lib/features/provideCallHierarchyItems.js +18 -17
- package/lib/features/provideCodeActions.d.ts +4 -3
- package/lib/features/provideCodeActions.js +9 -9
- package/lib/features/provideCodeLenses.d.ts +4 -3
- package/lib/features/provideCodeLenses.js +9 -9
- package/lib/features/provideColorPresentations.d.ts +3 -2
- package/lib/features/provideColorPresentations.js +5 -5
- package/lib/features/provideCompletionItems.d.ts +4 -3
- package/lib/features/provideCompletionItems.js +26 -25
- package/lib/features/provideDefinition.d.ts +3 -2
- package/lib/features/provideDefinition.js +6 -5
- package/lib/features/provideDiagnostics.d.ts +4 -3
- package/lib/features/provideDiagnostics.js +13 -11
- package/lib/features/provideDocumentColors.d.ts +3 -2
- package/lib/features/provideDocumentColors.js +2 -2
- package/lib/features/provideDocumentDropEdits.d.ts +3 -2
- package/lib/features/provideDocumentDropEdits.js +3 -3
- package/lib/features/provideDocumentFormattingEdits.d.ts +3 -2
- package/lib/features/provideDocumentFormattingEdits.js +17 -15
- package/lib/features/provideDocumentHighlights.d.ts +3 -2
- package/lib/features/provideDocumentHighlights.js +9 -8
- package/lib/features/provideDocumentLinks.d.ts +4 -3
- package/lib/features/provideDocumentLinks.js +6 -6
- package/lib/features/provideDocumentSemanticTokens.d.ts +3 -2
- package/lib/features/provideDocumentSemanticTokens.js +3 -3
- package/lib/features/provideDocumentSymbols.d.ts +3 -2
- package/lib/features/provideDocumentSymbols.js +5 -5
- package/lib/features/provideFileReferences.d.ts +3 -2
- package/lib/features/provideFileReferences.js +8 -7
- package/lib/features/provideFileRenameEdits.d.ts +3 -2
- package/lib/features/provideFileRenameEdits.js +6 -6
- package/lib/features/provideFoldingRanges.d.ts +3 -2
- package/lib/features/provideFoldingRanges.js +4 -4
- package/lib/features/provideHover.d.ts +3 -2
- package/lib/features/provideHover.js +7 -7
- package/lib/features/provideInlayHints.d.ts +4 -3
- package/lib/features/provideInlayHints.js +6 -6
- package/lib/features/provideLinkedEditingRanges.d.ts +3 -2
- package/lib/features/provideLinkedEditingRanges.js +5 -5
- package/lib/features/provideReferences.d.ts +3 -2
- package/lib/features/provideReferences.js +9 -8
- package/lib/features/provideRenameEdits.d.ts +3 -2
- package/lib/features/provideRenameEdits.js +5 -4
- package/lib/features/provideRenameRange.d.ts +3 -2
- package/lib/features/provideRenameRange.js +4 -4
- package/lib/features/provideSelectionRanges.d.ts +3 -2
- package/lib/features/provideSelectionRanges.js +3 -3
- package/lib/features/provideSignatureHelp.d.ts +3 -2
- package/lib/features/provideSignatureHelp.js +6 -6
- package/lib/features/provideWorkspaceSymbols.d.ts +2 -2
- package/lib/features/provideWorkspaceSymbols.js +6 -5
- package/lib/features/resolveCodeAction.d.ts +2 -2
- package/lib/features/resolveCodeAction.js +4 -4
- package/lib/features/resolveCodeLens.d.ts +2 -2
- package/lib/features/resolveCodeLens.js +6 -5
- package/lib/features/resolveCompletionItem.d.ts +2 -2
- package/lib/features/resolveCompletionItem.js +7 -6
- package/lib/features/resolveDocumentLink.d.ts +2 -2
- package/lib/features/resolveDocumentLink.js +4 -4
- package/lib/features/resolveInlayHint.d.ts +2 -2
- package/lib/features/resolveInlayHint.js +3 -3
- package/lib/languageService.d.ts +37 -32
- package/lib/languageService.js +42 -29
- package/lib/types.d.ts +77 -36
- package/lib/utils/dedupe.d.ts +1 -1
- package/lib/utils/featureWorkers.d.ts +7 -6
- package/lib/utils/featureWorkers.js +25 -18
- package/lib/utils/transform.d.ts +7 -6
- package/lib/utils/transform.js +18 -15
- package/lib/utils/uriMap.d.ts +3 -0
- package/lib/utils/uriMap.js +69 -0
- package/package.json +3 -3
- package/lib/features/provideAutoInsertionEdit.d.ts +0 -7
package/index.d.ts
CHANGED
|
@@ -4,5 +4,4 @@ export * from './lib/documents';
|
|
|
4
4
|
export { mergeWorkspaceEdits } from './lib/features/provideRenameEdits';
|
|
5
5
|
export * from './lib/types';
|
|
6
6
|
export * from './lib/utils/transform';
|
|
7
|
-
|
|
8
|
-
export declare const standardSemanticTokensLegend: vscode.SemanticTokensLegend;
|
|
7
|
+
export * from './lib/utils/uriMap';
|
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ 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.
|
|
17
|
+
exports.mergeWorkspaceEdits = void 0;
|
|
18
18
|
__exportStar(require("@volar/language-core"), exports);
|
|
19
19
|
__exportStar(require("./lib/languageService"), exports);
|
|
20
20
|
__exportStar(require("./lib/documents"), exports);
|
|
@@ -22,44 +22,5 @@ var provideRenameEdits_1 = require("./lib/features/provideRenameEdits");
|
|
|
22
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
|
-
|
|
26
|
-
exports.standardSemanticTokensLegend = {
|
|
27
|
-
tokenTypes: [
|
|
28
|
-
'namespace',
|
|
29
|
-
'class',
|
|
30
|
-
'enum',
|
|
31
|
-
'interface',
|
|
32
|
-
'struct',
|
|
33
|
-
'typeParameter',
|
|
34
|
-
'type',
|
|
35
|
-
'parameter',
|
|
36
|
-
'variable',
|
|
37
|
-
'property',
|
|
38
|
-
'enumMember',
|
|
39
|
-
'decorator',
|
|
40
|
-
'event',
|
|
41
|
-
'function',
|
|
42
|
-
'method',
|
|
43
|
-
'macro',
|
|
44
|
-
'label',
|
|
45
|
-
'comment',
|
|
46
|
-
'string',
|
|
47
|
-
'keyword',
|
|
48
|
-
'number',
|
|
49
|
-
'regexp',
|
|
50
|
-
'operator',
|
|
51
|
-
],
|
|
52
|
-
tokenModifiers: [
|
|
53
|
-
'declaration',
|
|
54
|
-
'definition',
|
|
55
|
-
'readonly',
|
|
56
|
-
'static',
|
|
57
|
-
'deprecated',
|
|
58
|
-
'abstract',
|
|
59
|
-
'async',
|
|
60
|
-
'modification',
|
|
61
|
-
'documentation',
|
|
62
|
-
'defaultLibrary',
|
|
63
|
-
],
|
|
64
|
-
};
|
|
25
|
+
__exportStar(require("./lib/utils/uriMap"), exports);
|
|
65
26
|
//# sourceMappingURL=index.js.map
|
package/lib/documents.d.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import { CodeRangeKey, LinkedCodeMap, Mapping, SourceMap } from '@volar/language-core';
|
|
1
|
+
import { CodeInformation, CodeRangeKey, LinkedCodeMap, Mapping, SourceMap, VirtualCode } from '@volar/language-core';
|
|
2
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
export declare class SourceMapWithDocuments
|
|
4
|
+
export declare class SourceMapWithDocuments {
|
|
5
5
|
sourceDocument: TextDocument;
|
|
6
6
|
embeddedDocument: TextDocument;
|
|
7
|
-
map: SourceMap<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
map: SourceMap<CodeInformation>;
|
|
8
|
+
virtuaoCode?: VirtualCode | undefined;
|
|
9
|
+
constructor(sourceDocument: TextDocument, embeddedDocument: TextDocument, map: SourceMap<CodeInformation>, virtuaoCode?: VirtualCode | undefined);
|
|
10
|
+
getSourceRange(range: vscode.Range, filter?: (data: CodeInformation) => boolean): vscode.Range | undefined;
|
|
11
|
+
getGeneratedRange(range: vscode.Range, filter?: (data: CodeInformation) => boolean): vscode.Range | undefined;
|
|
12
|
+
getSourceRanges(range: vscode.Range, filter?: (data: CodeInformation) => boolean): Generator<vscode.Range, void, unknown>;
|
|
13
|
+
getGeneratedRanges(range: vscode.Range, filter?: (data: CodeInformation) => boolean): Generator<vscode.Range, void, unknown>;
|
|
14
|
+
protected findRanges(range: vscode.Range, filter: (data: CodeInformation) => boolean, api: 'getSourcePositionsBase' | 'getGeneratedPositionsBase', api2: 'matchSourcePosition' | 'matchGeneratedPosition'): Generator<vscode.Range, void, unknown>;
|
|
15
|
+
getSourcePosition(position: vscode.Position, filter?: (data: CodeInformation) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
|
|
16
|
+
getGeneratedPosition(position: vscode.Position, filter?: (data: CodeInformation) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
|
|
17
|
+
getSourcePositions(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
18
|
+
getGeneratedPositions(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
19
|
+
getSourcePositionsBase(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<CodeInformation>], void, unknown>;
|
|
20
|
+
getGeneratedPositionsBase(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<CodeInformation>], void, unknown>;
|
|
21
|
+
protected findPositions(position: vscode.Position, filter: (data: CodeInformation) => boolean, fromDoc: TextDocument, toDoc: TextDocument, from: CodeRangeKey, to: CodeRangeKey): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<CodeInformation>], void, unknown>;
|
|
21
22
|
protected matchSourcePosition(position: vscode.Position, mapping: Mapping): import("vscode-languageserver-textdocument").Position | undefined;
|
|
22
23
|
protected matchGeneratedPosition(position: vscode.Position, mapping: Mapping): import("vscode-languageserver-textdocument").Position | undefined;
|
|
23
24
|
}
|
|
24
25
|
export declare class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
|
|
25
26
|
document: TextDocument;
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
linkedMap: LinkedCodeMap;
|
|
28
|
+
virtualCode: VirtualCode;
|
|
29
|
+
constructor(document: TextDocument, linkedMap: LinkedCodeMap, virtualCode: VirtualCode);
|
|
28
30
|
getLinkedCodePositions(posotion: vscode.Position): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
29
31
|
}
|
package/lib/documents.js
CHANGED
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LinkedCodeMapWithDocument = exports.SourceMapWithDocuments = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
class SourceMapWithDocuments {
|
|
6
|
-
constructor(sourceDocument, embeddedDocument, map) {
|
|
6
|
+
constructor(sourceDocument, embeddedDocument, map, virtuaoCode) {
|
|
7
7
|
this.sourceDocument = sourceDocument;
|
|
8
8
|
this.embeddedDocument = embeddedDocument;
|
|
9
9
|
this.map = map;
|
|
10
|
+
this.virtuaoCode = virtuaoCode;
|
|
10
11
|
}
|
|
11
12
|
// Range APIs
|
|
12
13
|
getSourceRange(range, filter = () => true) {
|
|
@@ -100,10 +101,11 @@ class SourceMapWithDocuments {
|
|
|
100
101
|
}
|
|
101
102
|
exports.SourceMapWithDocuments = SourceMapWithDocuments;
|
|
102
103
|
class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
|
|
103
|
-
constructor(document, linkedMap) {
|
|
104
|
-
super(document, document, linkedMap);
|
|
104
|
+
constructor(document, linkedMap, virtualCode) {
|
|
105
|
+
super(document, document, linkedMap, virtualCode);
|
|
105
106
|
this.document = document;
|
|
106
107
|
this.linkedMap = linkedMap;
|
|
108
|
+
this.virtualCode = virtualCode;
|
|
107
109
|
}
|
|
108
110
|
*getLinkedCodePositions(posotion) {
|
|
109
111
|
for (const linkedPosition of this.linkedMap.getLinkedOffsets(this.document.offsetAt(posotion))) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, selection: vscode.Position, change: {
|
|
5
|
+
rangeOffset: number;
|
|
6
|
+
rangeLength: number;
|
|
7
|
+
text: string;
|
|
8
|
+
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
-
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
|
-
const cancellation_1 = require("../utils/cancellation");
|
|
6
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
+
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return (uri, selection, change, token = cancellation_1.NoneCancellationToken) => {
|
|
9
9
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ selection, change }), function* (map) {
|
|
10
10
|
for (const mappedPosition of map.getGeneratedPositions(selection, language_core_1.isAutoInsertEnabled)) {
|
|
11
|
-
const mapped
|
|
12
|
-
if (mapped) {
|
|
11
|
+
for (const mapped of map.map.getGeneratedOffsets(change.rangeOffset)) {
|
|
13
12
|
yield {
|
|
14
13
|
selection: mappedPosition,
|
|
15
14
|
change: {
|
|
@@ -18,24 +17,16 @@ function register(context) {
|
|
|
18
17
|
rangeLength: change.rangeLength,
|
|
19
18
|
},
|
|
20
19
|
};
|
|
20
|
+
break;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
}, (
|
|
23
|
+
}, (plugin, document, args) => {
|
|
24
24
|
if (token.isCancellationRequested) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
return
|
|
28
|
-
},
|
|
29
|
-
if (!map || typeof item === 'string') {
|
|
30
|
-
return item;
|
|
31
|
-
}
|
|
32
|
-
const range = map.getSourceRange(item.range, language_core_1.isAutoInsertEnabled);
|
|
33
|
-
if (range) {
|
|
34
|
-
item.range = range;
|
|
35
|
-
return item;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
27
|
+
return plugin[1].provideAutoInsertSnippet?.(document, args.selection, args.change, token);
|
|
28
|
+
}, snippet => snippet);
|
|
38
29
|
};
|
|
39
30
|
}
|
|
40
31
|
exports.register = register;
|
|
41
|
-
//# sourceMappingURL=
|
|
32
|
+
//# sourceMappingURL=provideAutoInsertSnippet.js.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
|
+
import { URI } from 'vscode-uri';
|
|
3
4
|
export interface PluginCallHierarchyData {
|
|
4
5
|
uri: string;
|
|
5
6
|
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
|
6
|
-
|
|
7
|
+
pluginIndex: number;
|
|
7
8
|
embeddedDocumentUri: string | undefined;
|
|
8
9
|
}
|
|
9
|
-
export declare function register(context:
|
|
10
|
-
doPrepare(uri:
|
|
10
|
+
export declare function register(context: LanguageServiceContext): {
|
|
11
|
+
doPrepare(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
11
12
|
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
12
13
|
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
13
14
|
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
4
6
|
const common_1 = require("../utils/common");
|
|
5
7
|
const dedupe = require("../utils/dedupe");
|
|
6
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
|
-
const
|
|
8
|
-
const language_core_1 = require("@volar/language-core");
|
|
9
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
9
10
|
function register(context) {
|
|
10
11
|
return {
|
|
11
12
|
doPrepare(uri, position, token = cancellation_1.NoneCancellationToken) {
|
|
12
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, data => (0, language_core_1.isCallHierarchyEnabled)(data)), async (
|
|
13
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, data => (0, language_core_1.isCallHierarchyEnabled)(data)), async (plugin, document, position, map) => {
|
|
13
14
|
if (token.isCancellationRequested) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
|
-
const items = await
|
|
17
|
+
const items = await plugin[1].provideCallHierarchyItems?.(document, position, token);
|
|
17
18
|
items?.forEach(item => {
|
|
18
19
|
item.data = {
|
|
19
|
-
uri,
|
|
20
|
+
uri: uri.toString(),
|
|
20
21
|
original: {
|
|
21
22
|
data: item.data,
|
|
22
23
|
},
|
|
23
|
-
|
|
24
|
+
pluginIndex: context.plugins.indexOf(plugin),
|
|
24
25
|
embeddedDocumentUri: map?.embeddedDocument.uri,
|
|
25
26
|
};
|
|
26
27
|
});
|
|
@@ -38,15 +39,15 @@ function register(context) {
|
|
|
38
39
|
const data = item.data;
|
|
39
40
|
let incomingItems = [];
|
|
40
41
|
if (data) {
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
42
|
+
const plugin = context.plugins[data.pluginIndex];
|
|
43
|
+
if (!plugin[1].provideCallHierarchyIncomingCalls) {
|
|
43
44
|
return incomingItems;
|
|
44
45
|
}
|
|
45
46
|
Object.assign(item, data.original);
|
|
46
47
|
if (data.embeddedDocumentUri) {
|
|
47
|
-
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(data.embeddedDocumentUri);
|
|
48
|
+
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
|
48
49
|
if (isEmbeddedContent) {
|
|
49
|
-
const _calls = await
|
|
50
|
+
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
|
|
50
51
|
for (const _call of _calls) {
|
|
51
52
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
52
53
|
if (!calls) {
|
|
@@ -60,7 +61,7 @@ function register(context) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
|
-
const _calls = await
|
|
64
|
+
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
|
|
64
65
|
for (const _call of _calls) {
|
|
65
66
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
66
67
|
if (!calls) {
|
|
@@ -79,15 +80,15 @@ function register(context) {
|
|
|
79
80
|
const data = item.data;
|
|
80
81
|
let items = [];
|
|
81
82
|
if (data) {
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
83
|
+
const plugin = context.plugins[data.pluginIndex];
|
|
84
|
+
if (!plugin[1].provideCallHierarchyOutgoingCalls) {
|
|
84
85
|
return items;
|
|
85
86
|
}
|
|
86
87
|
Object.assign(item, data.original);
|
|
87
88
|
if (data.embeddedDocumentUri) {
|
|
88
|
-
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(data.embeddedDocumentUri);
|
|
89
|
+
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
|
89
90
|
if (isEmbeddedContent) {
|
|
90
|
-
const _calls = await
|
|
91
|
+
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
91
92
|
for (const call of _calls) {
|
|
92
93
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
93
94
|
if (!calls) {
|
|
@@ -101,7 +102,7 @@ function register(context) {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
else {
|
|
104
|
-
const _calls = await
|
|
105
|
+
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
105
106
|
for (const call of _calls) {
|
|
106
107
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
107
108
|
if (!calls) {
|
|
@@ -118,7 +119,7 @@ function register(context) {
|
|
|
118
119
|
},
|
|
119
120
|
};
|
|
120
121
|
function transformCallHierarchyItem(tsItem, tsRanges) {
|
|
121
|
-
const decoded = context.decodeEmbeddedDocumentUri(tsItem.uri);
|
|
122
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsItem.uri));
|
|
122
123
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
123
124
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
124
125
|
if (!virtualCode) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
4
|
export interface ServiceCodeActionData {
|
|
4
5
|
uri: string;
|
|
5
6
|
version: number;
|
|
6
7
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
7
|
-
|
|
8
|
+
pluginIndex: number;
|
|
8
9
|
}
|
|
9
|
-
export declare function register(context:
|
|
10
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
4
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
5
6
|
const common_1 = require("../utils/common");
|
|
6
7
|
const dedupe = require("../utils/dedupe");
|
|
7
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
9
|
const transform_1 = require("../utils/transform");
|
|
9
|
-
const language_core_1 = require("@volar/language-core");
|
|
10
10
|
function register(context) {
|
|
11
11
|
return async (uri, range, codeActionContext, token = cancellation_1.NoneCancellationToken) => {
|
|
12
12
|
const sourceScript = context.language.scripts.get(uri);
|
|
@@ -29,17 +29,17 @@ function register(context) {
|
|
|
29
29
|
codeActionContext: _codeActionContext,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
}, async (
|
|
32
|
+
}, async (plugin, document, { range, codeActionContext }) => {
|
|
33
33
|
if (token.isCancellationRequested) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const pluginIndex = context.plugins.indexOf(plugin);
|
|
37
37
|
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {
|
|
38
38
|
const data = diagnostic.data;
|
|
39
39
|
if (data && data.version !== document.version) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
return data?.serviceIndex ===
|
|
42
|
+
return data?.serviceIndex === pluginIndex;
|
|
43
43
|
}).map(diagnostic => {
|
|
44
44
|
const data = diagnostic.data;
|
|
45
45
|
return {
|
|
@@ -47,24 +47,24 @@ function register(context) {
|
|
|
47
47
|
...data.original,
|
|
48
48
|
};
|
|
49
49
|
});
|
|
50
|
-
const codeActions = await
|
|
50
|
+
const codeActions = await plugin[1].provideCodeActions?.(document, range, {
|
|
51
51
|
...codeActionContext,
|
|
52
52
|
diagnostics,
|
|
53
53
|
}, token);
|
|
54
54
|
codeActions?.forEach(codeAction => {
|
|
55
55
|
codeAction.data = {
|
|
56
|
-
uri,
|
|
56
|
+
uri: uri.toString(),
|
|
57
57
|
version: document.version,
|
|
58
58
|
original: {
|
|
59
59
|
data: codeAction.data,
|
|
60
60
|
edit: codeAction.edit,
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
pluginIndex: context.plugins.indexOf(plugin),
|
|
63
63
|
};
|
|
64
64
|
});
|
|
65
|
-
if (codeActions &&
|
|
65
|
+
if (codeActions && plugin[1].transformCodeAction) {
|
|
66
66
|
for (let i = 0; i < codeActions.length; i++) {
|
|
67
|
-
const transformed =
|
|
67
|
+
const transformed = plugin[1].transformCodeAction(codeActions[i]);
|
|
68
68
|
if (transformed) {
|
|
69
69
|
codeActions[i] = transformed;
|
|
70
70
|
transformedCodeActions.add(transformed);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
4
|
export interface ServiceCodeLensData {
|
|
4
5
|
kind: 'normal';
|
|
5
6
|
uri: string;
|
|
6
7
|
original: Pick<vscode.CodeLens, 'data'>;
|
|
7
|
-
|
|
8
|
+
pluginIndex: number;
|
|
8
9
|
}
|
|
9
10
|
export interface ServiceReferencesCodeLensData {
|
|
10
11
|
kind: 'references';
|
|
@@ -13,4 +14,4 @@ export interface ServiceReferencesCodeLensData {
|
|
|
13
14
|
workerFileRange: vscode.Range;
|
|
14
15
|
serviceIndex: number;
|
|
15
16
|
}
|
|
16
|
-
export declare function register(context:
|
|
17
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
4
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
5
6
|
const common_1 = require("../utils/common");
|
|
6
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
|
-
const language_core_1 = require("@volar/language-core");
|
|
8
8
|
function register(context) {
|
|
9
9
|
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
10
|
-
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (
|
|
10
|
+
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (plugin, document) => {
|
|
11
11
|
if (token.isCancellationRequested) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
let codeLens = await
|
|
15
|
-
const
|
|
14
|
+
let codeLens = await plugin[1].provideCodeLenses?.(document, token);
|
|
15
|
+
const pluginIndex = context.plugins.indexOf(plugin);
|
|
16
16
|
codeLens?.forEach(codeLens => {
|
|
17
17
|
codeLens.data = {
|
|
18
18
|
kind: 'normal',
|
|
19
|
-
uri,
|
|
19
|
+
uri: uri.toString(),
|
|
20
20
|
original: {
|
|
21
21
|
data: codeLens.data,
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
pluginIndex,
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
|
-
const ranges = await
|
|
26
|
+
const ranges = await plugin[1].provideReferencesCodeLensRanges?.(document, token);
|
|
27
27
|
const referencesCodeLens = ranges?.map(range => ({
|
|
28
28
|
range,
|
|
29
29
|
data: {
|
|
30
30
|
kind: 'references',
|
|
31
|
-
sourceFileUri: uri,
|
|
31
|
+
sourceFileUri: uri.toString(),
|
|
32
32
|
workerFileUri: document.uri,
|
|
33
33
|
workerFileRange: range,
|
|
34
|
-
serviceIndex,
|
|
34
|
+
serviceIndex: pluginIndex,
|
|
35
35
|
},
|
|
36
36
|
}));
|
|
37
37
|
codeLens = [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { ServiceContext } from '../types';
|
|
2
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
-
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
|
-
const common_1 = require("../utils/common");
|
|
6
|
-
const cancellation_1 = require("../utils/cancellation");
|
|
7
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
+
const common_1 = require("../utils/common");
|
|
7
|
+
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
8
|
function register(context) {
|
|
9
9
|
return (uri, color, range, token = cancellation_1.NoneCancellationToken) => {
|
|
10
10
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (map) {
|
|
11
11
|
for (const mappedRange of map.getGeneratedRanges(range, language_core_1.isColorEnabled)) {
|
|
12
12
|
yield mappedRange;
|
|
13
13
|
}
|
|
14
|
-
}, (
|
|
14
|
+
}, (plugin, document, range) => {
|
|
15
15
|
if (token.isCancellationRequested) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return plugin[1].provideColorPresentations?.(document, color, range, token);
|
|
19
19
|
}, (data, map) => {
|
|
20
20
|
if (!map) {
|
|
21
21
|
return data;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import
|
|
2
|
+
import { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
4
|
export interface ServiceCompletionData {
|
|
4
5
|
uri: string;
|
|
5
6
|
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
|
6
|
-
|
|
7
|
+
pluginIndex: number;
|
|
7
8
|
embeddedDocumentUri: string | undefined;
|
|
8
9
|
}
|
|
9
|
-
export declare function register(context:
|
|
10
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|