@volar/language-service 1.1.0-alpha.2 → 1.2.0-alpha.10
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 +4 -14
- package/out/baseLanguageService.js +33 -27
- package/out/documentFeatures/colorPresentations.d.ts +2 -2
- package/out/documentFeatures/documentColors.d.ts +2 -2
- package/out/documentFeatures/documentSymbols.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/format.d.ts +2 -4
- package/out/documentFeatures/format.js +27 -124
- package/out/documentFeatures/linkedEditingRanges.d.ts +2 -2
- package/out/documentFeatures/selectionRanges.d.ts +2 -2
- package/out/index.d.ts +1 -1
- package/out/index.js +3 -3
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.d.ts +4 -4
- package/out/languageFeatures/callHierarchy.js +16 -17
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +28 -17
- package/out/languageFeatures/codeActions.d.ts +16 -7
- package/out/languageFeatures/codeActions.js +101 -21
- package/out/languageFeatures/codeLens.d.ts +11 -4
- package/out/languageFeatures/codeLens.js +31 -15
- package/out/languageFeatures/codeLensResolve.d.ts +4 -2
- package/out/languageFeatures/codeLensResolve.js +22 -8
- package/out/languageFeatures/complete.d.ts +4 -4
- package/out/languageFeatures/complete.js +39 -20
- package/out/languageFeatures/completeResolve.d.ts +2 -2
- package/out/languageFeatures/completeResolve.js +4 -17
- package/out/languageFeatures/definition.d.ts +2 -2
- package/out/languageFeatures/documentHighlights.d.ts +2 -2
- package/out/languageFeatures/documentLinks.d.ts +2 -2
- package/out/languageFeatures/documentSemanticTokens.d.ts +2 -2
- package/out/languageFeatures/fileReferences.d.ts +2 -2
- package/out/languageFeatures/fileRename.d.ts +2 -2
- package/out/languageFeatures/fileRename.js +2 -2
- package/out/languageFeatures/hover.d.ts +2 -2
- package/out/languageFeatures/inlayHints.d.ts +2 -2
- package/out/languageFeatures/references.d.ts +2 -2
- package/out/languageFeatures/rename.d.ts +3 -3
- package/out/languageFeatures/rename.js +64 -44
- package/out/languageFeatures/renamePrepare.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/validation.d.ts +12 -2
- package/out/languageFeatures/validation.js +169 -39
- package/out/languageFeatures/workspaceSymbols.d.ts +2 -2
- package/out/languageFeatures/workspaceSymbols.js +1 -1
- package/out/transformer/foldingRanges.js +6 -6
- package/out/types.d.ts +108 -24
- package/out/types.js +0 -1
- package/out/utils/featureWorkers.d.ts +4 -3
- package/out/utils/featureWorkers.js +120 -5
- package/package.json +9 -9
- package/out/languageFeatures/executeCommand.d.ts +0 -11
- package/out/languageFeatures/executeCommand.js +0 -32
|
@@ -12,29 +12,40 @@ exports.register = void 0;
|
|
|
12
12
|
const rename_1 = require("./rename");
|
|
13
13
|
function register(context) {
|
|
14
14
|
return (item) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
var _a, _b, _c;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
16
16
|
const data = item.data;
|
|
17
|
-
if (data) {
|
|
17
|
+
if ((data === null || data === void 0 ? void 0 : data.type) === 'plugin') {
|
|
18
18
|
const plugin = context.plugins[data.pluginId];
|
|
19
|
-
if (!plugin)
|
|
20
|
-
return item;
|
|
21
19
|
if (!((_a = plugin.codeAction) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
22
20
|
return item;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
Object.assign(item, data.original);
|
|
22
|
+
item = yield plugin.codeAction.resolve(item);
|
|
23
|
+
if (item.edit) {
|
|
24
|
+
item.edit = (0, rename_1.embeddedEditToSourceEdit)(item.edit, context.documents, 'codeAction', { [data.uri]: data.version });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
|
|
28
|
+
const fixes = (_d = (_c = (_b = context.ruleFixes) === null || _b === void 0 ? void 0 : _b[data.documentUri]) === null || _c === void 0 ? void 0 : _c[data.ruleId]) === null || _d === void 0 ? void 0 : _d[data.ruleFixIndex];
|
|
29
|
+
const fix = fixes === null || fixes === void 0 ? void 0 : fixes[1][data.index];
|
|
30
|
+
if (fix) {
|
|
31
|
+
let edit = (_f = yield ((_e = fix.getWorkspaceEdit) === null || _e === void 0 ? void 0 : _e.call(fix, fixes[0]))) !== null && _f !== void 0 ? _f : undefined;
|
|
32
|
+
if (!edit) {
|
|
33
|
+
const edits = yield ((_g = fix.getEdits) === null || _g === void 0 ? void 0 : _g.call(fix, fixes[0]));
|
|
34
|
+
if (edits) {
|
|
35
|
+
edit = {
|
|
36
|
+
documentChanges: [{
|
|
37
|
+
textDocument: {
|
|
38
|
+
uri: data.documentUri,
|
|
39
|
+
version: null
|
|
40
|
+
},
|
|
41
|
+
edits,
|
|
42
|
+
}],
|
|
43
|
+
};
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
if (edit) {
|
|
47
|
+
item.edit = (0, rename_1.embeddedEditToSourceEdit)(edit, context.documents, data.isFormat ? 'format' : 'codeAction', { [data.uri]: data.version });
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
51
|
return item;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
export interface PluginCodeActionData {
|
|
4
4
|
uri: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} | undefined;
|
|
5
|
+
version: number;
|
|
6
|
+
type: 'plugin';
|
|
7
|
+
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
8
|
+
pluginId: string;
|
|
10
9
|
}
|
|
11
|
-
export
|
|
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;
|
|
19
|
+
}
|
|
20
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
@@ -18,14 +18,15 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
18
18
|
const rename_1 = require("./rename");
|
|
19
19
|
function register(context) {
|
|
20
20
|
return (uri, range, codeActionContext) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var _a, _b, _c, _d, _e;
|
|
22
|
+
const sourceDocument = context.getTextDocument(uri);
|
|
23
|
+
if (!sourceDocument)
|
|
23
24
|
return;
|
|
24
25
|
const offsetRange = {
|
|
25
|
-
start:
|
|
26
|
-
end:
|
|
26
|
+
start: sourceDocument.offsetAt(range.start),
|
|
27
|
+
end: sourceDocument.offsetAt(range.end),
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
+
const pluginActions = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (_arg, map, file) => {
|
|
29
30
|
var _a, _b;
|
|
30
31
|
if (!file.capabilities.codeAction)
|
|
31
32
|
return [];
|
|
@@ -53,24 +54,39 @@ function register(context) {
|
|
|
53
54
|
}];
|
|
54
55
|
}
|
|
55
56
|
return [];
|
|
56
|
-
}, (plugin, document,
|
|
57
|
-
var
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
}, (plugin, document, { range, codeActionContext }) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
var _f, _g;
|
|
59
|
+
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
60
|
+
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {
|
|
61
|
+
const data = diagnostic.data;
|
|
62
|
+
if (data && data.version !== sourceDocument.version) {
|
|
63
|
+
console.warn('[volar/plugin-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return (data === null || data === void 0 ? void 0 : data.type) === 'plugin' && (data === null || data === void 0 ? void 0 : data.pluginOrRuleId) === pluginId;
|
|
67
|
+
}).map(diagnostic => {
|
|
68
|
+
const data = diagnostic.data;
|
|
69
|
+
return Object.assign(Object.assign({}, diagnostic), data.original);
|
|
70
|
+
});
|
|
71
|
+
const codeActions = yield ((_g = (_f = plugin.codeAction) === null || _f === void 0 ? void 0 : _f.on) === null || _g === void 0 ? void 0 : _g.call(_f, document, range, Object.assign(Object.assign({}, codeActionContext), { diagnostics })));
|
|
72
|
+
codeActions === null || codeActions === void 0 ? void 0 : codeActions.forEach(codeAction => {
|
|
73
|
+
codeAction.data = {
|
|
74
|
+
uri,
|
|
75
|
+
version: document.version,
|
|
76
|
+
type: 'plugin',
|
|
77
|
+
original: {
|
|
78
|
+
data: codeAction.data,
|
|
79
|
+
edit: codeAction.edit,
|
|
80
|
+
},
|
|
81
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
82
|
+
};
|
|
68
83
|
});
|
|
84
|
+
return codeActions;
|
|
69
85
|
}), (_codeActions, sourceMap) => _codeActions.map(_codeAction => {
|
|
70
86
|
if (!sourceMap)
|
|
71
87
|
return _codeAction;
|
|
72
88
|
if (_codeAction.edit) {
|
|
73
|
-
const edit = (0, rename_1.embeddedEditToSourceEdit)(_codeAction.edit, context.documents);
|
|
89
|
+
const edit = (0, rename_1.embeddedEditToSourceEdit)(_codeAction.edit, context.documents, 'codeAction');
|
|
74
90
|
if (edit) {
|
|
75
91
|
_codeAction.edit = edit;
|
|
76
92
|
return _codeAction;
|
|
@@ -79,11 +95,75 @@ function register(context) {
|
|
|
79
95
|
else {
|
|
80
96
|
return _codeAction;
|
|
81
97
|
}
|
|
82
|
-
}).filter(shared.notEmpty), arr => arr.flat());
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
}).filter(shared.notEmpty), arr => dedupe.withCodeAction(arr.flat()));
|
|
99
|
+
const ruleActions = [];
|
|
100
|
+
for (const diagnostic of codeActionContext.diagnostics) {
|
|
101
|
+
const data = diagnostic.data;
|
|
102
|
+
if (data && data.version !== sourceDocument.version) {
|
|
103
|
+
console.warn('[volar/rules-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
|
|
107
|
+
const fixes = (_c = (_b = (_a = context.ruleFixes) === null || _a === void 0 ? void 0 : _a[data.documentUri]) === null || _b === void 0 ? void 0 : _b[data.pluginOrRuleId]) === null || _c === void 0 ? void 0 : _c[data.ruleFixIndex];
|
|
108
|
+
if (fixes) {
|
|
109
|
+
for (let i = 0; i < fixes[1].length; i++) {
|
|
110
|
+
const fix = fixes[1][i];
|
|
111
|
+
const matchKinds = [];
|
|
112
|
+
if (!codeActionContext.only) {
|
|
113
|
+
matchKinds.push(undefined);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
for (const kind of (_d = fix.kinds) !== null && _d !== void 0 ? _d : ['quickfix']) {
|
|
117
|
+
const matchOnly = matchOnlyKind(codeActionContext.only, kind);
|
|
118
|
+
if (matchOnly) {
|
|
119
|
+
matchKinds.push(matchOnly);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const matchKind of matchKinds) {
|
|
124
|
+
const action = {
|
|
125
|
+
title: (_e = fix.title) !== null && _e !== void 0 ? _e : `Fix: ${diagnostic.message}`,
|
|
126
|
+
kind: matchKind,
|
|
127
|
+
diagnostics: [diagnostic],
|
|
128
|
+
data: {
|
|
129
|
+
uri,
|
|
130
|
+
type: 'rule',
|
|
131
|
+
version: data.version,
|
|
132
|
+
isFormat: data.isFormat,
|
|
133
|
+
ruleId: data.pluginOrRuleId,
|
|
134
|
+
documentUri: data.documentUri,
|
|
135
|
+
ruleFixIndex: data.ruleFixIndex,
|
|
136
|
+
index: i,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
ruleActions.push(action);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
85
144
|
}
|
|
145
|
+
return [
|
|
146
|
+
...pluginActions !== null && pluginActions !== void 0 ? pluginActions : [],
|
|
147
|
+
...ruleActions,
|
|
148
|
+
];
|
|
86
149
|
});
|
|
87
150
|
}
|
|
88
151
|
exports.register = register;
|
|
152
|
+
function matchOnlyKind(only, kind) {
|
|
153
|
+
const b = kind.split('.');
|
|
154
|
+
for (const onlyKind of only) {
|
|
155
|
+
const a = onlyKind.split('.');
|
|
156
|
+
if (a.length <= b.length) {
|
|
157
|
+
let matchNum = 0;
|
|
158
|
+
for (let i = 0; i < a.length; i++) {
|
|
159
|
+
if (a[i] == b[i]) {
|
|
160
|
+
matchNum++;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (matchNum === a.length) {
|
|
164
|
+
return onlyKind;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
89
169
|
//# sourceMappingURL=codeActions.js.map
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
1
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
3
|
export interface PluginCodeLensData {
|
|
4
|
+
kind: 'normal';
|
|
4
5
|
uri: string;
|
|
5
|
-
|
|
6
|
-
pluginId:
|
|
6
|
+
original: Pick<vscode.CodeLens, 'data'>;
|
|
7
|
+
pluginId: string;
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
+
export interface PluginReferencesCodeLensData {
|
|
10
|
+
kind: 'references';
|
|
11
|
+
uri: string;
|
|
12
|
+
location: vscode.Location;
|
|
13
|
+
pluginId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.CodeLens[]>;
|
|
@@ -11,23 +11,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
13
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
|
-
const
|
|
14
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
15
15
|
function register(context) {
|
|
16
16
|
return (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
var _a;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
const referencesCodeLendsEnabled = (_b = yield ((_a = context.env.configurationHost) === null || _a === void 0 ? void 0 : _a.getConfiguration('volar.codeLens.references'))) !== null && _b !== void 0 ? _b : true;
|
|
19
|
+
return (_c = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _d, _e, _f, _g;
|
|
21
|
+
let codeLens = yield ((_e = (_d = plugin.codeLens) === null || _d === void 0 ? void 0 : _d.on) === null || _e === void 0 ? void 0 : _e.call(_d, document));
|
|
22
|
+
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
23
|
+
codeLens === null || codeLens === void 0 ? void 0 : codeLens.forEach(codeLens => {
|
|
24
|
+
codeLens.data = {
|
|
25
|
+
kind: 'normal',
|
|
26
|
+
uri,
|
|
27
|
+
original: {
|
|
28
|
+
data: codeLens.data,
|
|
29
|
+
},
|
|
30
|
+
pluginId,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
if (referencesCodeLendsEnabled) {
|
|
34
|
+
const referencesCodeLensLocs = yield ((_g = (_f = plugin.referencesCodeLens) === null || _f === void 0 ? void 0 : _f.on) === null || _g === void 0 ? void 0 : _g.call(_f, document));
|
|
35
|
+
const referencesCodeLens = referencesCodeLensLocs === null || referencesCodeLensLocs === void 0 ? void 0 : referencesCodeLensLocs.map(loc => vscode.CodeLens.create(loc.range, {
|
|
36
|
+
kind: 'references',
|
|
37
|
+
uri,
|
|
38
|
+
location: loc,
|
|
39
|
+
pluginId,
|
|
40
|
+
}));
|
|
41
|
+
codeLens = [
|
|
42
|
+
...codeLens !== null && codeLens !== void 0 ? codeLens : [],
|
|
43
|
+
...referencesCodeLens !== null && referencesCodeLens !== void 0 ? referencesCodeLens : [],
|
|
44
|
+
];
|
|
30
45
|
}
|
|
46
|
+
return codeLens;
|
|
31
47
|
}), (data, map) => data.map(codeLens => {
|
|
32
48
|
if (!map)
|
|
33
49
|
return codeLens;
|
|
@@ -35,7 +51,7 @@ function register(context) {
|
|
|
35
51
|
if (range) {
|
|
36
52
|
return Object.assign(Object.assign({}, codeLens), { range });
|
|
37
53
|
}
|
|
38
|
-
}).filter(shared.notEmpty), arr => arr.flat())) !== null &&
|
|
54
|
+
}).filter(shared.notEmpty), arr => arr.flat())) !== null && _c !== void 0 ? _c : [];
|
|
39
55
|
});
|
|
40
56
|
}
|
|
41
57
|
exports.register = register;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare const showReferencesCommand: string;
|
|
4
|
+
export type ShowReferencesCommandData = [string, vscode.Position, vscode.Location[]];
|
|
5
|
+
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens) => Promise<vscode.CodeLens>;
|
|
@@ -8,20 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.register = void 0;
|
|
12
|
-
const
|
|
11
|
+
exports.register = exports.showReferencesCommand = void 0;
|
|
12
|
+
const references = require("./references");
|
|
13
|
+
exports.showReferencesCommand = `volar.${Math.random().toString(36).slice(2)}.show-references`;
|
|
13
14
|
function register(context) {
|
|
15
|
+
const findReferences = references.register(context);
|
|
14
16
|
return (item) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
var _a;
|
|
17
|
+
var _a, _b, _c;
|
|
16
18
|
const data = item.data;
|
|
17
|
-
if (data) {
|
|
19
|
+
if ((data === null || data === void 0 ? void 0 : data.kind) === 'normal') {
|
|
18
20
|
const plugin = context.plugins[data.pluginId];
|
|
19
|
-
if (!plugin)
|
|
20
|
-
return item;
|
|
21
21
|
if (!((_a = plugin.codeLens) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
22
22
|
return item;
|
|
23
|
-
|
|
24
|
-
item =
|
|
23
|
+
Object.assign(item, data.original);
|
|
24
|
+
item = yield plugin.codeLens.resolve(item);
|
|
25
|
+
// item.range already transformed in codeLens request
|
|
26
|
+
}
|
|
27
|
+
if ((data === null || data === void 0 ? void 0 : data.kind) === 'references') {
|
|
28
|
+
let references = (_b = yield findReferences(data.uri, item.range.start)) !== null && _b !== void 0 ? _b : [];
|
|
29
|
+
const plugin = context.plugins[data.pluginId];
|
|
30
|
+
const document = context.getTextDocument(data.uri);
|
|
31
|
+
if (document && ((_c = plugin.referencesCodeLens) === null || _c === void 0 ? void 0 : _c.resolve)) {
|
|
32
|
+
references = yield plugin.referencesCodeLens.resolve(document, data.location, references);
|
|
33
|
+
}
|
|
34
|
+
item.command = {
|
|
35
|
+
title: references.length === 1 ? '1 reference' : `${references.length} references`,
|
|
36
|
+
command: exports.showReferencesCommand,
|
|
37
|
+
arguments: [data.uri, data.location.range.start, references],
|
|
38
|
+
};
|
|
25
39
|
}
|
|
26
40
|
return item;
|
|
27
41
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
export interface PluginCompletionData {
|
|
4
4
|
uri: string;
|
|
5
|
-
|
|
6
|
-
pluginId:
|
|
5
|
+
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
|
6
|
+
pluginId: string;
|
|
7
7
|
map: {
|
|
8
8
|
embeddedDocumentUri: string;
|
|
9
9
|
} | undefined;
|
|
10
10
|
}
|
|
11
|
-
export declare function register(context:
|
|
11
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext) => Promise<vscode.CompletionList>;
|
|
@@ -34,8 +34,12 @@ function register(context) {
|
|
|
34
34
|
}
|
|
35
35
|
cacheData.list = transformer.asCompletionList(embeddedCompletionList, range => map.toSourceRange(range), map.virtualFileDocument, (newItem, oldItem) => newItem.data = {
|
|
36
36
|
uri,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
original: {
|
|
38
|
+
additionalTextEdits: oldItem.additionalTextEdits,
|
|
39
|
+
textEdit: oldItem.textEdit,
|
|
40
|
+
data: oldItem.data,
|
|
41
|
+
},
|
|
42
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === cacheData.plugin),
|
|
39
43
|
map: {
|
|
40
44
|
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
41
45
|
},
|
|
@@ -51,12 +55,18 @@ function register(context) {
|
|
|
51
55
|
cacheData.list.isIncomplete = false;
|
|
52
56
|
continue;
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
completionList.items.forEach(item => {
|
|
59
|
+
item.data = {
|
|
60
|
+
uri,
|
|
61
|
+
original: {
|
|
62
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
63
|
+
textEdit: item.textEdit,
|
|
64
|
+
data: item.data,
|
|
65
|
+
},
|
|
66
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === cacheData.plugin),
|
|
67
|
+
map: undefined,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
}
|
|
@@ -72,7 +82,7 @@ function register(context) {
|
|
|
72
82
|
if (rootFile) {
|
|
73
83
|
yield (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, (_, map) => __awaiter(this, void 0, void 0, function* () {
|
|
74
84
|
var _f, _g;
|
|
75
|
-
const plugins = context.plugins.sort(sortPlugins);
|
|
85
|
+
const plugins = Object.values(context.plugins).sort(sortPlugins);
|
|
76
86
|
let _data;
|
|
77
87
|
for (const mapped of map.toGeneratedPositions(position, data => {
|
|
78
88
|
_data = data;
|
|
@@ -102,8 +112,12 @@ function register(context) {
|
|
|
102
112
|
}
|
|
103
113
|
const completionList = transformer.asCompletionList(embeddedCompletionList, range => map.toSourceRange(range), map.virtualFileDocument, (newItem, oldItem) => newItem.data = {
|
|
104
114
|
uri,
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
original: {
|
|
116
|
+
additionalTextEdits: oldItem.additionalTextEdits,
|
|
117
|
+
textEdit: oldItem.textEdit,
|
|
118
|
+
data: oldItem.data,
|
|
119
|
+
},
|
|
120
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
107
121
|
map: {
|
|
108
122
|
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
109
123
|
}
|
|
@@ -122,7 +136,7 @@ function register(context) {
|
|
|
122
136
|
}));
|
|
123
137
|
}
|
|
124
138
|
if (document = context.getTextDocument(uri)) {
|
|
125
|
-
const plugins = context.plugins.sort(sortPlugins);
|
|
139
|
+
const plugins = Object.values(context.plugins).sort(sortPlugins);
|
|
126
140
|
for (const plugin of plugins) {
|
|
127
141
|
if (!((_d = plugin.complete) === null || _d === void 0 ? void 0 : _d.on))
|
|
128
142
|
continue;
|
|
@@ -141,17 +155,22 @@ function register(context) {
|
|
|
141
155
|
if (!plugin.complete.isAdditional) {
|
|
142
156
|
cache.mainCompletion = { documentUri: document.uri };
|
|
143
157
|
}
|
|
158
|
+
completionList.items.forEach(item => {
|
|
159
|
+
item.data = {
|
|
160
|
+
uri,
|
|
161
|
+
original: {
|
|
162
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
163
|
+
textEdit: item.textEdit,
|
|
164
|
+
data: item.data,
|
|
165
|
+
},
|
|
166
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
167
|
+
map: undefined,
|
|
168
|
+
};
|
|
169
|
+
});
|
|
144
170
|
cache.data.push({
|
|
145
171
|
map: undefined,
|
|
146
172
|
plugin,
|
|
147
|
-
list:
|
|
148
|
-
return Object.assign(Object.assign({}, item), { data: {
|
|
149
|
-
uri,
|
|
150
|
-
originalItem: item,
|
|
151
|
-
pluginId: context.plugins.indexOf(plugin),
|
|
152
|
-
sourceMap: undefined,
|
|
153
|
-
} });
|
|
154
|
-
}) }),
|
|
173
|
+
list: completionList,
|
|
155
174
|
});
|
|
156
175
|
}
|
|
157
176
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
|
|
@@ -16,26 +16,13 @@ function register(context) {
|
|
|
16
16
|
const data = item.data;
|
|
17
17
|
if (data) {
|
|
18
18
|
const plugin = context.plugins[data.pluginId];
|
|
19
|
-
if (!plugin)
|
|
20
|
-
return item;
|
|
21
19
|
if (!((_a = plugin.complete) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
22
20
|
return item;
|
|
23
|
-
|
|
21
|
+
item = Object.assign(item, data.original);
|
|
24
22
|
if (data.map) {
|
|
25
23
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (resolvedItem.additionalTextEdits) {
|
|
29
|
-
for (const edit of resolvedItem.additionalTextEdits) {
|
|
30
|
-
if (edit.range.start.line === 0
|
|
31
|
-
&& edit.range.start.character === 0
|
|
32
|
-
&& edit.range.end.line === 0
|
|
33
|
-
&& edit.range.end.character === 0) {
|
|
34
|
-
edit.newText = '\n' + edit.newText;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
item = transformer.asCompletionItem(resolvedItem, embeddedRange => {
|
|
24
|
+
item = yield plugin.complete.resolve(item);
|
|
25
|
+
item = transformer.asCompletionItem(item, embeddedRange => {
|
|
39
26
|
var _a;
|
|
40
27
|
let range = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange);
|
|
41
28
|
if (range)
|
|
@@ -45,7 +32,7 @@ function register(context) {
|
|
|
45
32
|
}
|
|
46
33
|
}
|
|
47
34
|
else {
|
|
48
|
-
item = yield plugin.complete.resolve(
|
|
35
|
+
item = yield plugin.complete.resolve(item);
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
38
|
// TODO: monkey fix import ts file icon
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
import { FileRangeCapabilities, MirrorBehaviorCapabilities } from '@volar/language-core';
|
|
4
|
-
export declare function register(context:
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext, api: 'findDefinition' | 'findTypeDefinition' | 'findImplementations', isValidMapping: (data: FileRangeCapabilities) => boolean, isValidMirrorPosition: (mirrorData: MirrorBehaviorCapabilities) => boolean): (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.DocumentLink[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { SemanticToken } from '@volar/language-service';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function register(context:
|
|
3
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: SemanticToken[]) => void) | undefined) => Promise<SemanticToken[] | undefined> | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import { NullableResult } from '@volar/language-service';
|
|
4
|
-
export declare function register(context:
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string) => NullableResult<vscode.Location[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
2
2
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (oldUri: string, newUri: string) => Promise<_.WorkspaceEdit | undefined>;
|
|
@@ -29,12 +29,12 @@ function register(context) {
|
|
|
29
29
|
oldUri += tsExt;
|
|
30
30
|
newUri += tsExt;
|
|
31
31
|
}
|
|
32
|
-
for (const plugin of context.plugins) {
|
|
32
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
33
33
|
if (!plugin.doFileRename)
|
|
34
34
|
continue;
|
|
35
35
|
const workspaceEdit = yield plugin.doFileRename(oldUri, newUri);
|
|
36
36
|
if (workspaceEdit) {
|
|
37
|
-
const result = (0, rename_1.embeddedEditToSourceEdit)(workspaceEdit, context.documents);
|
|
37
|
+
const result = (0, rename_1.embeddedEditToSourceEdit)(workspaceEdit, context.documents, 'fileName');
|
|
38
38
|
if (result === null || result === void 0 ? void 0 : result.documentChanges) {
|
|
39
39
|
result.documentChanges = dedupe.withDocumentChanges(result.documentChanges);
|
|
40
40
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range) => Promise<vscode.InlayHint[] | undefined>;
|