@volar/language-service 1.3.0-alpha.3 → 1.4.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/out/baseLanguageService.d.ts +37 -41
- package/out/baseLanguageService.js +26 -19
- package/out/documentFeatures/colorPresentations.d.ts +1 -1
- package/out/documentFeatures/colorPresentations.js +8 -4
- package/out/documentFeatures/documentColors.d.ts +1 -1
- package/out/documentFeatures/documentColors.js +8 -4
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +8 -15
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.js +6 -2
- package/out/documentFeatures/format.d.ts +2 -2
- package/out/documentFeatures/format.js +32 -39
- package/out/documentFeatures/linkedEditingRanges.d.ts +1 -1
- package/out/documentFeatures/linkedEditingRanges.js +8 -4
- package/out/documentFeatures/selectionRanges.d.ts +1 -1
- package/out/documentFeatures/selectionRanges.js +8 -4
- package/out/documents.js +3 -4
- package/out/index.d.ts +2 -0
- package/out/index.js +41 -1
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/autoInsert.js +12 -6
- package/out/languageFeatures/callHierarchy.d.ts +3 -3
- package/out/languageFeatures/callHierarchy.js +69 -76
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +10 -20
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +26 -31
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +19 -25
- package/out/languageFeatures/codeLensResolve.d.ts +1 -1
- package/out/languageFeatures/codeLensResolve.js +9 -19
- package/out/languageFeatures/complete.d.ts +1 -1
- package/out/languageFeatures/complete.js +35 -41
- package/out/languageFeatures/completeResolve.d.ts +1 -1
- package/out/languageFeatures/completeResolve.js +6 -17
- package/out/languageFeatures/definition.d.ts +1 -1
- package/out/languageFeatures/definition.js +41 -51
- package/out/languageFeatures/documentHighlights.d.ts +1 -1
- package/out/languageFeatures/documentHighlights.js +37 -44
- package/out/languageFeatures/documentLinks.d.ts +1 -1
- package/out/languageFeatures/documentLinks.js +13 -16
- package/out/languageFeatures/documentSemanticTokens.d.ts +1 -2
- package/out/languageFeatures/documentSemanticTokens.js +19 -8
- package/out/languageFeatures/fileReferences.d.ts +1 -1
- package/out/languageFeatures/fileReferences.js +8 -16
- package/out/languageFeatures/fileRename.d.ts +2 -1
- package/out/languageFeatures/fileRename.js +8 -16
- package/out/languageFeatures/hover.d.ts +1 -1
- package/out/languageFeatures/hover.js +10 -9
- package/out/languageFeatures/inlayHints.d.ts +1 -1
- package/out/languageFeatures/inlayHints.js +16 -21
- package/out/languageFeatures/references.d.ts +1 -1
- package/out/languageFeatures/references.js +29 -39
- package/out/languageFeatures/rename.d.ts +1 -1
- package/out/languageFeatures/rename.js +57 -69
- package/out/languageFeatures/renamePrepare.d.ts +1 -1
- package/out/languageFeatures/renamePrepare.js +6 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.js +18 -2
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +143 -165
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- package/out/languageFeatures/workspaceSymbols.js +8 -15
- package/out/transformer/completionItem.js +9 -4
- package/out/transformer/completionList.js +6 -3
- package/out/transformer/documentSymbol.js +9 -4
- package/out/transformer/foldingRanges.js +2 -3
- package/out/transformer/hover.js +5 -2
- package/out/transformer/locationLike.js +4 -1
- package/out/transformer/locationsLike.js +2 -2
- package/out/transformer/selectionRanges.js +2 -2
- package/out/transformer/textEdit.js +20 -5
- package/out/transformer/workspaceSymbol.js +4 -1
- package/out/types.d.ts +56 -80
- package/out/types.js +0 -1
- package/out/utils/SemanticTokensBuilder.d.ts +13 -0
- package/out/utils/SemanticTokensBuilder.js +42 -0
- package/out/utils/common.d.ts +3 -0
- package/out/utils/common.js +25 -1
- package/out/utils/definePlugin.js +11 -23
- package/out/utils/featureWorkers.js +127 -155
- package/package.json +5 -6
package/out/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
13
13
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.showReferencesCommand = exports.transformer = exports.mergeWorkspaceEdits = void 0;
|
|
16
|
+
exports.standardSemanticTokensLegend = exports.showReferencesCommand = exports.transformer = exports.mergeWorkspaceEdits = void 0;
|
|
17
17
|
__exportStar(require("@volar/language-core"), exports);
|
|
18
18
|
__exportStar(require("./baseLanguageService"), exports);
|
|
19
19
|
__exportStar(require("./documents"), exports);
|
|
@@ -23,4 +23,44 @@ __exportStar(require("./types"), exports);
|
|
|
23
23
|
exports.transformer = require("./transformer");
|
|
24
24
|
var codeLensResolve_1 = require("./languageFeatures/codeLensResolve");
|
|
25
25
|
Object.defineProperty(exports, "showReferencesCommand", { enumerable: true, get: function () { return codeLensResolve_1.showReferencesCommand; } });
|
|
26
|
+
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
|
|
27
|
+
exports.standardSemanticTokensLegend = {
|
|
28
|
+
tokenTypes: [
|
|
29
|
+
'namespace',
|
|
30
|
+
'class',
|
|
31
|
+
'enum',
|
|
32
|
+
'interface',
|
|
33
|
+
'struct',
|
|
34
|
+
'typeParameter',
|
|
35
|
+
'type',
|
|
36
|
+
'parameter',
|
|
37
|
+
'variable',
|
|
38
|
+
'property',
|
|
39
|
+
'enumMember',
|
|
40
|
+
'decorator',
|
|
41
|
+
'event',
|
|
42
|
+
'function',
|
|
43
|
+
'method',
|
|
44
|
+
'macro',
|
|
45
|
+
'label',
|
|
46
|
+
'comment',
|
|
47
|
+
'string',
|
|
48
|
+
'keyword',
|
|
49
|
+
'number',
|
|
50
|
+
'regexp',
|
|
51
|
+
'operator',
|
|
52
|
+
],
|
|
53
|
+
tokenModifiers: [
|
|
54
|
+
'declaration',
|
|
55
|
+
'definition',
|
|
56
|
+
'readonly',
|
|
57
|
+
'static',
|
|
58
|
+
'deprecated',
|
|
59
|
+
'abstract',
|
|
60
|
+
'async',
|
|
61
|
+
'modification',
|
|
62
|
+
'documentation',
|
|
63
|
+
'defaultLibrary',
|
|
64
|
+
],
|
|
65
|
+
};
|
|
26
66
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, autoInsertContext:
|
|
2
|
+
import type { LanguageServicePluginContext, AutoInsertionContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, autoInsertContext: AutoInsertionContext, token: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
@@ -2,24 +2,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.register = void 0;
|
|
3
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
4
|
function register(context) {
|
|
5
|
-
return (uri, position, autoInsertContext) => {
|
|
5
|
+
return (uri, position, autoInsertContext, token) => {
|
|
6
6
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, { position, autoInsertContext }, function* (arg, map) {
|
|
7
|
-
var _a;
|
|
8
7
|
for (const position of map.toGeneratedPositions(arg.position, data => !!data.completion)) {
|
|
9
|
-
const rangeOffset =
|
|
8
|
+
const rangeOffset = map.map.toGeneratedOffset(arg.autoInsertContext.lastChange.rangeOffset)?.[0];
|
|
10
9
|
const range = map.toGeneratedRange(arg.autoInsertContext.lastChange.range);
|
|
11
10
|
if (rangeOffset !== undefined && range) {
|
|
12
11
|
yield {
|
|
13
12
|
position,
|
|
14
13
|
autoInsertContext: {
|
|
15
|
-
lastChange:
|
|
16
|
-
|
|
14
|
+
lastChange: {
|
|
15
|
+
...arg.autoInsertContext.lastChange,
|
|
16
|
+
rangeOffset,
|
|
17
|
+
range,
|
|
18
|
+
},
|
|
17
19
|
},
|
|
18
20
|
};
|
|
19
21
|
break;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
}, (plugin, document, arg) => {
|
|
24
|
+
}, (plugin, document, arg) => {
|
|
25
|
+
if (token.isCancellationRequested)
|
|
26
|
+
return;
|
|
27
|
+
return plugin.provideAutoInsertionEdit?.(document, arg.position, arg.autoInsertContext, token);
|
|
28
|
+
}, (item, map) => {
|
|
23
29
|
if (!map || typeof item === 'string')
|
|
24
30
|
return item;
|
|
25
31
|
const range = map.toSourceRange(item.range);
|
|
@@ -9,7 +9,7 @@ export interface PluginCallHierarchyData {
|
|
|
9
9
|
} | undefined;
|
|
10
10
|
}
|
|
11
11
|
export declare function register(context: LanguageServicePluginContext): {
|
|
12
|
-
doPrepare(uri: string, position: vscode.Position): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
13
|
-
getIncomingCalls(item: vscode.CallHierarchyItem): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
14
|
-
getOutgoingCalls(item: vscode.CallHierarchyItem): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
12
|
+
doPrepare(uri: string, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
13
|
+
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
14
|
+
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
15
15
|
};
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
3
|
const path_1 = require("path");
|
|
4
|
+
const common_1 = require("../utils/common");
|
|
14
5
|
const dedupe = require("../utils/dedupe");
|
|
15
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
16
7
|
function register(context) {
|
|
17
8
|
return {
|
|
18
|
-
doPrepare(uri, position) {
|
|
19
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), (plugin, document, position, map) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
doPrepare(uri, position, token) {
|
|
10
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), async (plugin, document, position, map) => {
|
|
11
|
+
if (token.isCancellationRequested)
|
|
12
|
+
return;
|
|
13
|
+
const items = await plugin.provideCallHierarchyItems?.(document, position, token);
|
|
14
|
+
items?.forEach(item => {
|
|
23
15
|
item.data = {
|
|
24
16
|
uri,
|
|
25
17
|
original: {
|
|
@@ -32,35 +24,21 @@ function register(context) {
|
|
|
32
24
|
};
|
|
33
25
|
});
|
|
34
26
|
return items;
|
|
35
|
-
}
|
|
36
|
-
.map(item =>
|
|
37
|
-
.filter(
|
|
27
|
+
}, (data, sourceMap) => !sourceMap ? data : data
|
|
28
|
+
.map(item => transformCallHierarchyItem(item, [])?.[0])
|
|
29
|
+
.filter(common_1.notEmpty), arr => dedupe.withLocations(arr.flat()));
|
|
38
30
|
},
|
|
39
|
-
getIncomingCalls(item) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (data.map) {
|
|
49
|
-
|
|
50
|
-
const _calls = yield plugin.callHierarchy.onIncomingCalls(item);
|
|
51
|
-
for (const _call of _calls) {
|
|
52
|
-
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
53
|
-
if (!calls)
|
|
54
|
-
continue;
|
|
55
|
-
incomingItems.push({
|
|
56
|
-
from: calls[0],
|
|
57
|
-
fromRanges: calls[1],
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const _calls = yield plugin.callHierarchy.onIncomingCalls(item);
|
|
31
|
+
async getIncomingCalls(item, token) {
|
|
32
|
+
const data = item.data;
|
|
33
|
+
let incomingItems = [];
|
|
34
|
+
if (data) {
|
|
35
|
+
const plugin = context.plugins[data.pluginId];
|
|
36
|
+
if (!plugin.provideCallHierarchyIncomingCalls)
|
|
37
|
+
return incomingItems;
|
|
38
|
+
Object.assign(item, data.original);
|
|
39
|
+
if (data.map) {
|
|
40
|
+
if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
|
|
41
|
+
const _calls = await plugin.provideCallHierarchyIncomingCalls(item, token);
|
|
64
42
|
for (const _call of _calls) {
|
|
65
43
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
66
44
|
if (!calls)
|
|
@@ -72,34 +50,32 @@ function register(context) {
|
|
|
72
50
|
}
|
|
73
51
|
}
|
|
74
52
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return items;
|
|
86
|
-
Object.assign(item, data.original);
|
|
87
|
-
if (data.map) {
|
|
88
|
-
if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
|
|
89
|
-
const _calls = yield plugin.callHierarchy.onOutgoingCalls(item);
|
|
90
|
-
for (const call of _calls) {
|
|
91
|
-
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
92
|
-
if (!calls)
|
|
93
|
-
continue;
|
|
94
|
-
items.push({
|
|
95
|
-
to: calls[0],
|
|
96
|
-
fromRanges: calls[1],
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
53
|
+
else {
|
|
54
|
+
const _calls = await plugin.provideCallHierarchyIncomingCalls(item, token);
|
|
55
|
+
for (const _call of _calls) {
|
|
56
|
+
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
57
|
+
if (!calls)
|
|
58
|
+
continue;
|
|
59
|
+
incomingItems.push({
|
|
60
|
+
from: calls[0],
|
|
61
|
+
fromRanges: calls[1],
|
|
62
|
+
});
|
|
100
63
|
}
|
|
101
|
-
|
|
102
|
-
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return dedupe.withCallHierarchyIncomingCalls(incomingItems);
|
|
67
|
+
},
|
|
68
|
+
async getOutgoingCalls(item, token) {
|
|
69
|
+
const data = item.data;
|
|
70
|
+
let items = [];
|
|
71
|
+
if (data) {
|
|
72
|
+
const plugin = context.plugins[data.pluginId];
|
|
73
|
+
if (!plugin.provideCallHierarchyOutgoingCalls)
|
|
74
|
+
return items;
|
|
75
|
+
Object.assign(item, data.original);
|
|
76
|
+
if (data.map) {
|
|
77
|
+
if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
|
|
78
|
+
const _calls = await plugin.provideCallHierarchyOutgoingCalls(item, token);
|
|
103
79
|
for (const call of _calls) {
|
|
104
80
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
105
81
|
if (!calls)
|
|
@@ -111,8 +87,20 @@ function register(context) {
|
|
|
111
87
|
}
|
|
112
88
|
}
|
|
113
89
|
}
|
|
114
|
-
|
|
115
|
-
|
|
90
|
+
else {
|
|
91
|
+
const _calls = await plugin.provideCallHierarchyOutgoingCalls(item, token);
|
|
92
|
+
for (const call of _calls) {
|
|
93
|
+
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
94
|
+
if (!calls)
|
|
95
|
+
continue;
|
|
96
|
+
items.push({
|
|
97
|
+
to: calls[0],
|
|
98
|
+
fromRanges: calls[1],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return dedupe.withCallHierarchyOutgoingCalls(items);
|
|
116
104
|
},
|
|
117
105
|
};
|
|
118
106
|
function transformCallHierarchyItem(tsItem, tsRanges) {
|
|
@@ -130,16 +118,21 @@ function register(context) {
|
|
|
130
118
|
const selectionRange = map.toSourceRange(tsItem.selectionRange);
|
|
131
119
|
if (!selectionRange)
|
|
132
120
|
continue;
|
|
133
|
-
const vueRanges = tsRanges.map(tsRange => map.toSourceRange(tsRange)).filter(
|
|
134
|
-
const vueItem =
|
|
121
|
+
const vueRanges = tsRanges.map(tsRange => map.toSourceRange(tsRange)).filter(common_1.notEmpty);
|
|
122
|
+
const vueItem = {
|
|
123
|
+
...tsItem,
|
|
124
|
+
name: tsItem.name === path_1.posix.basename(context.uriToFileName(map.virtualFileDocument.uri)) ? path_1.posix.basename(context.uriToFileName(map.sourceFileDocument.uri)) : tsItem.name,
|
|
125
|
+
uri: map.sourceFileDocument.uri,
|
|
135
126
|
// TS Bug: `range: range` not works
|
|
136
127
|
range: {
|
|
137
128
|
start: range.start,
|
|
138
129
|
end: range.end,
|
|
139
|
-
},
|
|
130
|
+
},
|
|
131
|
+
selectionRange: {
|
|
140
132
|
start: selectionRange.start,
|
|
141
133
|
end: selectionRange.end,
|
|
142
|
-
}
|
|
134
|
+
},
|
|
135
|
+
};
|
|
143
136
|
selectionRange.end;
|
|
144
137
|
return [vueItem, vueRanges];
|
|
145
138
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (item: CodeAction) => Promise<CodeAction>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeAction, token: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
@@ -1,36 +1,26 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
3
|
const rename_1 = require("./rename");
|
|
13
4
|
function register(context) {
|
|
14
|
-
return (item) =>
|
|
15
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5
|
+
return async (item, token) => {
|
|
16
6
|
const data = item.data;
|
|
17
|
-
if (
|
|
7
|
+
if (data?.type === 'plugin') {
|
|
18
8
|
const plugin = context.plugins[data.pluginId];
|
|
19
|
-
if (!
|
|
9
|
+
if (!plugin.resolveCodeAction)
|
|
20
10
|
return item;
|
|
21
11
|
Object.assign(item, data.original);
|
|
22
|
-
item =
|
|
12
|
+
item = await plugin.resolveCodeAction(item, token);
|
|
23
13
|
if (item.edit) {
|
|
24
14
|
item.edit = (0, rename_1.embeddedEditToSourceEdit)(item.edit, context.documents, 'codeAction', { [data.uri]: data.version });
|
|
25
15
|
}
|
|
26
16
|
}
|
|
27
|
-
if (
|
|
28
|
-
const fixes =
|
|
29
|
-
const fix = fixes
|
|
17
|
+
if (data?.type === 'rule') {
|
|
18
|
+
const fixes = context.ruleFixes?.[data.documentUri]?.[data.ruleId]?.[data.ruleFixIndex];
|
|
19
|
+
const fix = fixes?.[1][data.index];
|
|
30
20
|
if (fix) {
|
|
31
|
-
let edit =
|
|
21
|
+
let edit = await fix.getWorkspaceEdit?.(fixes[0]) ?? undefined;
|
|
32
22
|
if (!edit) {
|
|
33
|
-
const edits =
|
|
23
|
+
const edits = await fix.getEdits?.(fixes[0]);
|
|
34
24
|
if (edits) {
|
|
35
25
|
edit = {
|
|
36
26
|
documentChanges: [{
|
|
@@ -49,7 +39,7 @@ function register(context) {
|
|
|
49
39
|
}
|
|
50
40
|
}
|
|
51
41
|
return item;
|
|
52
|
-
}
|
|
42
|
+
};
|
|
53
43
|
}
|
|
54
44
|
exports.register = register;
|
|
55
45
|
//# sourceMappingURL=codeActionResolve.js.map
|
|
@@ -17,4 +17,4 @@ export interface RuleCodeActionData {
|
|
|
17
17
|
ruleFixIndex: number;
|
|
18
18
|
index: number;
|
|
19
19
|
}
|
|
20
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
20
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
3
|
const transformer = require("../transformer");
|
|
14
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
15
5
|
const common_1 = require("../utils/common");
|
|
@@ -17,8 +7,7 @@ const dedupe = require("../utils/dedupe");
|
|
|
17
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
18
8
|
const rename_1 = require("./rename");
|
|
19
9
|
function register(context) {
|
|
20
|
-
return (uri, range, codeActionContext) =>
|
|
21
|
-
var _a, _b, _c, _d, _e;
|
|
10
|
+
return async (uri, range, codeActionContext, token) => {
|
|
22
11
|
const sourceDocument = context.getTextDocument(uri);
|
|
23
12
|
if (!sourceDocument)
|
|
24
13
|
return;
|
|
@@ -26,8 +15,7 @@ function register(context) {
|
|
|
26
15
|
start: sourceDocument.offsetAt(range.start),
|
|
27
16
|
end: sourceDocument.offsetAt(range.end),
|
|
28
17
|
};
|
|
29
|
-
const pluginActions =
|
|
30
|
-
var _a, _b;
|
|
18
|
+
const pluginActions = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (_arg, map, file) => {
|
|
31
19
|
if (!file.capabilities.codeAction)
|
|
32
20
|
return [];
|
|
33
21
|
const _codeActionContext = {
|
|
@@ -39,8 +27,8 @@ function register(context) {
|
|
|
39
27
|
for (const mapping of map.map.mappings) {
|
|
40
28
|
const overlapRange = (0, common_1.getOverlapRange)(offsetRange.start, offsetRange.end, mapping.sourceRange[0], mapping.sourceRange[1]);
|
|
41
29
|
if (overlapRange) {
|
|
42
|
-
const start =
|
|
43
|
-
const end =
|
|
30
|
+
const start = map.map.toGeneratedOffset(overlapRange.start)?.[0];
|
|
31
|
+
const end = map.map.toGeneratedOffset(overlapRange.end)?.[0];
|
|
44
32
|
if (start !== undefined && end !== undefined) {
|
|
45
33
|
minStart = minStart === undefined ? start : Math.min(start, minStart);
|
|
46
34
|
maxEnd = maxEnd === undefined ? end : Math.max(end, maxEnd);
|
|
@@ -54,8 +42,9 @@ function register(context) {
|
|
|
54
42
|
}];
|
|
55
43
|
}
|
|
56
44
|
return [];
|
|
57
|
-
}, (plugin, document, { range, codeActionContext }) =>
|
|
58
|
-
|
|
45
|
+
}, async (plugin, document, { range, codeActionContext }) => {
|
|
46
|
+
if (token.isCancellationRequested)
|
|
47
|
+
return;
|
|
59
48
|
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
60
49
|
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {
|
|
61
50
|
const data = diagnostic.data;
|
|
@@ -63,16 +52,22 @@ function register(context) {
|
|
|
63
52
|
// console.warn('[volar/plugin-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
64
53
|
return false;
|
|
65
54
|
}
|
|
66
|
-
return
|
|
55
|
+
return data?.type === 'plugin' && data?.pluginOrRuleId === pluginId;
|
|
67
56
|
}).map(diagnostic => {
|
|
68
57
|
const data = diagnostic.data;
|
|
69
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
...diagnostic,
|
|
60
|
+
...data.original,
|
|
61
|
+
};
|
|
70
62
|
});
|
|
71
|
-
const codeActions =
|
|
72
|
-
|
|
63
|
+
const codeActions = await plugin.provideCodeActions?.(document, range, {
|
|
64
|
+
...codeActionContext,
|
|
65
|
+
diagnostics,
|
|
66
|
+
}, token);
|
|
67
|
+
codeActions?.forEach(codeAction => {
|
|
73
68
|
codeAction.data = {
|
|
74
69
|
uri,
|
|
75
|
-
version:
|
|
70
|
+
version: sourceDocument.version,
|
|
76
71
|
type: 'plugin',
|
|
77
72
|
original: {
|
|
78
73
|
data: codeAction.data,
|
|
@@ -82,7 +77,7 @@ function register(context) {
|
|
|
82
77
|
};
|
|
83
78
|
});
|
|
84
79
|
return codeActions;
|
|
85
|
-
}
|
|
80
|
+
}, (_codeActions, sourceMap) => _codeActions.map(_codeAction => {
|
|
86
81
|
if (!sourceMap)
|
|
87
82
|
return _codeAction;
|
|
88
83
|
if (_codeAction.edit) {
|
|
@@ -95,7 +90,7 @@ function register(context) {
|
|
|
95
90
|
else {
|
|
96
91
|
return _codeAction;
|
|
97
92
|
}
|
|
98
|
-
}).filter(
|
|
93
|
+
}).filter(common_1.notEmpty), arr => dedupe.withCodeAction(arr.flat()));
|
|
99
94
|
const ruleActions = [];
|
|
100
95
|
for (const diagnostic of codeActionContext.diagnostics) {
|
|
101
96
|
const data = diagnostic.data;
|
|
@@ -103,8 +98,8 @@ function register(context) {
|
|
|
103
98
|
// console.warn('[volar/rules-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
104
99
|
continue;
|
|
105
100
|
}
|
|
106
|
-
if (
|
|
107
|
-
const fixes =
|
|
101
|
+
if (data?.type === 'rule') {
|
|
102
|
+
const fixes = context.ruleFixes?.[data.documentUri]?.[data.pluginOrRuleId]?.[data.ruleFixIndex];
|
|
108
103
|
if (fixes) {
|
|
109
104
|
for (let i = 0; i < fixes[1].length; i++) {
|
|
110
105
|
const fix = fixes[1][i];
|
|
@@ -113,7 +108,7 @@ function register(context) {
|
|
|
113
108
|
matchKinds.push(undefined);
|
|
114
109
|
}
|
|
115
110
|
else {
|
|
116
|
-
for (const kind of
|
|
111
|
+
for (const kind of fix.kinds ?? ['quickfix']) {
|
|
117
112
|
const matchOnly = matchOnlyKind(codeActionContext.only, kind);
|
|
118
113
|
if (matchOnly) {
|
|
119
114
|
matchKinds.push(matchOnly);
|
|
@@ -122,7 +117,7 @@ function register(context) {
|
|
|
122
117
|
}
|
|
123
118
|
for (const matchKind of matchKinds) {
|
|
124
119
|
const action = {
|
|
125
|
-
title:
|
|
120
|
+
title: fix.title ?? `Fix: ${diagnostic.message}`,
|
|
126
121
|
kind: matchKind,
|
|
127
122
|
diagnostics: [diagnostic],
|
|
128
123
|
data: {
|
|
@@ -143,10 +138,10 @@ function register(context) {
|
|
|
143
138
|
}
|
|
144
139
|
}
|
|
145
140
|
return [
|
|
146
|
-
...pluginActions
|
|
141
|
+
...pluginActions ?? [],
|
|
147
142
|
...ruleActions,
|
|
148
143
|
];
|
|
149
|
-
}
|
|
144
|
+
};
|
|
150
145
|
}
|
|
151
146
|
exports.register = register;
|
|
152
147
|
function matchOnlyKind(only, kind) {
|
|
@@ -12,4 +12,4 @@ export interface PluginReferencesCodeLensData {
|
|
|
12
12
|
location: vscode.Location;
|
|
13
13
|
pluginId: string;
|
|
14
14
|
}
|
|
15
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.CodeLens[]>;
|
|
15
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
+
const common_1 = require("../utils/common");
|
|
15
6
|
function register(context) {
|
|
16
|
-
return (uri) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let codeLens =
|
|
7
|
+
return async (uri, token) => {
|
|
8
|
+
const referencesCodeLendsEnabled = await context.configurationHost?.getConfiguration('volar.codeLens.references') ?? true;
|
|
9
|
+
return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], async (plugin, document) => {
|
|
10
|
+
if (token.isCancellationRequested)
|
|
11
|
+
return;
|
|
12
|
+
let codeLens = await plugin.provideCodeLenses?.(document, token);
|
|
22
13
|
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
23
|
-
codeLens
|
|
14
|
+
codeLens?.forEach(codeLens => {
|
|
24
15
|
codeLens.data = {
|
|
25
16
|
kind: 'normal',
|
|
26
17
|
uri,
|
|
@@ -31,28 +22,31 @@ function register(context) {
|
|
|
31
22
|
};
|
|
32
23
|
});
|
|
33
24
|
if (referencesCodeLendsEnabled) {
|
|
34
|
-
const referencesCodeLensLocs =
|
|
35
|
-
const referencesCodeLens = referencesCodeLensLocs
|
|
25
|
+
const referencesCodeLensLocs = await plugin.provideReferencesCodeLenses?.(document, token);
|
|
26
|
+
const referencesCodeLens = referencesCodeLensLocs?.map(loc => vscode.CodeLens.create(loc.range, {
|
|
36
27
|
kind: 'references',
|
|
37
28
|
uri,
|
|
38
29
|
location: loc,
|
|
39
30
|
pluginId,
|
|
40
31
|
}));
|
|
41
32
|
codeLens = [
|
|
42
|
-
...codeLens
|
|
43
|
-
...referencesCodeLens
|
|
33
|
+
...codeLens ?? [],
|
|
34
|
+
...referencesCodeLens ?? [],
|
|
44
35
|
];
|
|
45
36
|
}
|
|
46
37
|
return codeLens;
|
|
47
|
-
}
|
|
38
|
+
}, (data, map) => data.map(codeLens => {
|
|
48
39
|
if (!map)
|
|
49
40
|
return codeLens;
|
|
50
41
|
const range = map.toSourceRange(codeLens.range);
|
|
51
42
|
if (range) {
|
|
52
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
...codeLens,
|
|
45
|
+
range,
|
|
46
|
+
};
|
|
53
47
|
}
|
|
54
|
-
}).filter(
|
|
55
|
-
}
|
|
48
|
+
}).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
|
|
49
|
+
};
|
|
56
50
|
}
|
|
57
51
|
exports.register = register;
|
|
58
52
|
//# sourceMappingURL=codeLens.js.map
|
|
@@ -2,4 +2,4 @@ import * as vscode from 'vscode-languageserver-protocol';
|
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
export declare const showReferencesCommand: string;
|
|
4
4
|
export type ShowReferencesCommandData = [string, vscode.Position, vscode.Location[]];
|
|
5
|
-
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens) => Promise<vscode.CodeLens>;
|
|
5
|
+
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|