@volar/language-service 1.2.0-alpha.8 → 1.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/baseLanguageService.d.ts +6 -7
- package/out/baseLanguageService.js +7 -10
- 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/documentSymbols.js +34 -6
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/format.d.ts +2 -4
- package/out/documentFeatures/format.js +113 -151
- 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 +2 -2
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +9 -3
- package/out/languageFeatures/codeActions.d.ts +5 -2
- package/out/languageFeatures/codeActions.js +17 -6
- package/out/languageFeatures/codeLens.d.ts +11 -4
- package/out/languageFeatures/codeLens.js +22 -14
- package/out/languageFeatures/codeLensResolve.d.ts +4 -2
- package/out/languageFeatures/codeLensResolve.js +19 -11
- package/out/languageFeatures/complete.d.ts +2 -2
- package/out/languageFeatures/completeResolve.d.ts +2 -2
- 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/documentLinks.js +1 -1
- 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 +1 -1
- package/out/languageFeatures/hover.d.ts +2 -2
- package/out/languageFeatures/inlayHints.d.ts +2 -2
- package/out/languageFeatures/inlayHints.js +2 -3
- package/out/languageFeatures/references.d.ts +2 -2
- package/out/languageFeatures/rename.d.ts +3 -3
- package/out/languageFeatures/rename.js +54 -34
- package/out/languageFeatures/renamePrepare.d.ts +2 -2
- package/out/languageFeatures/renamePrepare.js +9 -13
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/validation.d.ts +4 -2
- package/out/languageFeatures/validation.js +42 -9
- package/out/languageFeatures/workspaceSymbols.d.ts +2 -2
- package/out/languageFeatures/workspaceSymbols.js +3 -2
- package/out/transformer/documentSymbol.d.ts +2 -0
- package/out/transformer/documentSymbol.js +18 -0
- package/out/transformer/index.d.ts +2 -2
- package/out/transformer/index.js +5 -5
- package/out/transformer/workspaceSymbol.d.ts +2 -0
- package/out/transformer/workspaceSymbol.js +15 -0
- package/out/types.d.ts +65 -43
- package/out/utils/dedupe.d.ts +0 -1
- package/out/utils/dedupe.js +1 -13
- package/out/utils/featureWorkers.d.ts +4 -4
- package/out/utils/featureWorkers.js +27 -17
- package/package.json +9 -9
- package/out/languageFeatures/executeCommand.d.ts +0 -11
- package/out/languageFeatures/executeCommand.js +0 -32
|
@@ -21,7 +21,7 @@ function register(context) {
|
|
|
21
21
|
Object.assign(item, data.original);
|
|
22
22
|
item = yield plugin.codeAction.resolve(item);
|
|
23
23
|
if (item.edit) {
|
|
24
|
-
item.edit = (0, rename_1.embeddedEditToSourceEdit)(item.edit, context.documents);
|
|
24
|
+
item.edit = (0, rename_1.embeddedEditToSourceEdit)(item.edit, context.documents, 'codeAction', { [data.uri]: data.version });
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
|
|
@@ -33,12 +33,18 @@ function register(context) {
|
|
|
33
33
|
const edits = yield ((_g = fix.getEdits) === null || _g === void 0 ? void 0 : _g.call(fix, fixes[0]));
|
|
34
34
|
if (edits) {
|
|
35
35
|
edit = {
|
|
36
|
-
|
|
36
|
+
documentChanges: [{
|
|
37
|
+
textDocument: {
|
|
38
|
+
uri: data.documentUri,
|
|
39
|
+
version: null
|
|
40
|
+
},
|
|
41
|
+
edits,
|
|
42
|
+
}],
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
if (edit) {
|
|
41
|
-
item.edit = (0, rename_1.embeddedEditToSourceEdit)(edit, context.documents);
|
|
47
|
+
item.edit = (0, rename_1.embeddedEditToSourceEdit)(edit, context.documents, data.isFormat ? 'format' : 'codeAction', { [data.uri]: data.version });
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
}
|
|
@@ -1,17 +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
|
+
version: number;
|
|
5
6
|
type: 'plugin';
|
|
6
7
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
7
8
|
pluginId: string;
|
|
8
9
|
}
|
|
9
10
|
export interface RuleCodeActionData {
|
|
10
11
|
uri: string;
|
|
12
|
+
version: number;
|
|
11
13
|
documentUri: string;
|
|
12
14
|
type: 'rule';
|
|
15
|
+
isFormat: boolean;
|
|
13
16
|
ruleId: string;
|
|
14
17
|
ruleFixIndex: number;
|
|
15
18
|
index: number;
|
|
16
19
|
}
|
|
17
|
-
export declare function register(context:
|
|
20
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
@@ -19,12 +19,12 @@ const rename_1 = require("./rename");
|
|
|
19
19
|
function register(context) {
|
|
20
20
|
return (uri, range, codeActionContext) => __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
var _a, _b, _c, _d, _e;
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
22
|
+
const sourceDocument = context.getTextDocument(uri);
|
|
23
|
+
if (!sourceDocument)
|
|
24
24
|
return;
|
|
25
25
|
const offsetRange = {
|
|
26
|
-
start:
|
|
27
|
-
end:
|
|
26
|
+
start: sourceDocument.offsetAt(range.start),
|
|
27
|
+
end: sourceDocument.offsetAt(range.end),
|
|
28
28
|
};
|
|
29
29
|
const pluginActions = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (_arg, map, file) => {
|
|
30
30
|
var _a, _b;
|
|
@@ -59,6 +59,10 @@ function register(context) {
|
|
|
59
59
|
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
60
60
|
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {
|
|
61
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
|
+
}
|
|
62
66
|
return (data === null || data === void 0 ? void 0 : data.type) === 'plugin' && (data === null || data === void 0 ? void 0 : data.pluginOrRuleId) === pluginId;
|
|
63
67
|
}).map(diagnostic => {
|
|
64
68
|
const data = diagnostic.data;
|
|
@@ -68,6 +72,7 @@ function register(context) {
|
|
|
68
72
|
codeActions === null || codeActions === void 0 ? void 0 : codeActions.forEach(codeAction => {
|
|
69
73
|
codeAction.data = {
|
|
70
74
|
uri,
|
|
75
|
+
version: document.version,
|
|
71
76
|
type: 'plugin',
|
|
72
77
|
original: {
|
|
73
78
|
data: codeAction.data,
|
|
@@ -81,7 +86,7 @@ function register(context) {
|
|
|
81
86
|
if (!sourceMap)
|
|
82
87
|
return _codeAction;
|
|
83
88
|
if (_codeAction.edit) {
|
|
84
|
-
const edit = (0, rename_1.embeddedEditToSourceEdit)(_codeAction.edit, context.documents);
|
|
89
|
+
const edit = (0, rename_1.embeddedEditToSourceEdit)(_codeAction.edit, context.documents, 'codeAction');
|
|
85
90
|
if (edit) {
|
|
86
91
|
_codeAction.edit = edit;
|
|
87
92
|
return _codeAction;
|
|
@@ -94,6 +99,10 @@ function register(context) {
|
|
|
94
99
|
const ruleActions = [];
|
|
95
100
|
for (const diagnostic of codeActionContext.diagnostics) {
|
|
96
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
|
+
}
|
|
97
106
|
if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
|
|
98
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];
|
|
99
108
|
if (fixes) {
|
|
@@ -104,7 +113,7 @@ function register(context) {
|
|
|
104
113
|
matchKinds.push(undefined);
|
|
105
114
|
}
|
|
106
115
|
else {
|
|
107
|
-
for (const kind of (_d = fix.kinds) !== null && _d !== void 0 ? _d : ['quickfix'
|
|
116
|
+
for (const kind of (_d = fix.kinds) !== null && _d !== void 0 ? _d : ['quickfix']) {
|
|
108
117
|
const matchOnly = matchOnlyKind(codeActionContext.only, kind);
|
|
109
118
|
if (matchOnly) {
|
|
110
119
|
matchKinds.push(matchOnly);
|
|
@@ -119,6 +128,8 @@ function register(context) {
|
|
|
119
128
|
data: {
|
|
120
129
|
uri,
|
|
121
130
|
type: 'rule',
|
|
131
|
+
version: data.version,
|
|
132
|
+
isFormat: data.isFormat,
|
|
122
133
|
ruleId: data.pluginOrRuleId,
|
|
123
134
|
documentUri: data.documentUri,
|
|
124
135
|
ruleFixIndex: data.ruleFixIndex,
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
2
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
export interface PluginCodeLensData {
|
|
4
|
+
kind: 'normal';
|
|
4
5
|
uri: string;
|
|
5
|
-
original: Pick<
|
|
6
|
+
original: Pick<vscode.CodeLens, 'data'>;
|
|
6
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,18 @@ 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
|
-
|
|
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);
|
|
21
23
|
codeLens === null || codeLens === void 0 ? void 0 : codeLens.forEach(codeLens => {
|
|
22
|
-
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
23
|
-
if (codeLens.command) {
|
|
24
|
-
codeLens.command = {
|
|
25
|
-
title: codeLens.command.title,
|
|
26
|
-
command: executeCommand_1.executePluginCommand,
|
|
27
|
-
arguments: [uri, pluginId, codeLens.command],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
24
|
codeLens.data = {
|
|
25
|
+
kind: 'normal',
|
|
31
26
|
uri,
|
|
32
27
|
original: {
|
|
33
28
|
data: codeLens.data,
|
|
@@ -35,6 +30,19 @@ function register(context) {
|
|
|
35
30
|
pluginId,
|
|
36
31
|
};
|
|
37
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
|
+
];
|
|
45
|
+
}
|
|
38
46
|
return codeLens;
|
|
39
47
|
}), (data, map) => data.map(codeLens => {
|
|
40
48
|
if (!map)
|
|
@@ -43,7 +51,7 @@ function register(context) {
|
|
|
43
51
|
if (range) {
|
|
44
52
|
return Object.assign(Object.assign({}, codeLens), { range });
|
|
45
53
|
}
|
|
46
|
-
}).filter(shared.notEmpty), arr => arr.flat())) !== null &&
|
|
54
|
+
}).filter(shared.notEmpty), arr => arr.flat())) !== null && _c !== void 0 ? _c : [];
|
|
47
55
|
});
|
|
48
56
|
}
|
|
49
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,27 +8,35 @@ 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
21
|
if (!((_a = plugin.codeLens) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
20
22
|
return item;
|
|
21
23
|
Object.assign(item, data.original);
|
|
22
24
|
item = yield plugin.codeLens.resolve(item);
|
|
23
|
-
if (item.command) {
|
|
24
|
-
item.command = {
|
|
25
|
-
title: item.command.title,
|
|
26
|
-
command: executeCommand_1.executePluginCommand,
|
|
27
|
-
arguments: [data.uri, data.pluginId, item.command],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
25
|
// item.range already transformed in codeLens request
|
|
31
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
|
+
};
|
|
39
|
+
}
|
|
32
40
|
return item;
|
|
33
41
|
});
|
|
34
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
|
@@ -8,4 +8,4 @@ export interface PluginCompletionData {
|
|
|
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>;
|
|
@@ -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>;
|
|
@@ -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[]>;
|
|
@@ -14,7 +14,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
14
14
|
function register(context) {
|
|
15
15
|
return (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a;
|
|
17
|
-
const pluginLinks = (_a = yield (0, featureWorkers_1.
|
|
17
|
+
const pluginLinks = (_a = yield (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => { var _a; return (_a = plugin.findDocumentLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => data.map(link => {
|
|
18
18
|
if (!map)
|
|
19
19
|
return link;
|
|
20
20
|
const range = map.toSourceRange(link.range);
|
|
@@ -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>;
|
|
@@ -34,7 +34,7 @@ function register(context) {
|
|
|
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>;
|
|
@@ -50,15 +50,14 @@ function register(context) {
|
|
|
50
50
|
}, (plugin, document, arg) => {
|
|
51
51
|
var _a, _b;
|
|
52
52
|
return (_b = (_a = plugin.inlayHints) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, document, arg);
|
|
53
|
-
}, (inlayHints, map) => inlayHints.map(_inlayHint => {
|
|
53
|
+
}, (inlayHints, map) => inlayHints.map((_inlayHint) => {
|
|
54
54
|
var _a;
|
|
55
55
|
if (!map)
|
|
56
56
|
return _inlayHint;
|
|
57
57
|
const position = map.toSourcePosition(_inlayHint.position);
|
|
58
58
|
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument)).filter(shared.notEmpty);
|
|
59
59
|
if (position) {
|
|
60
|
-
return Object.assign(Object.assign({}, _inlayHint), { position,
|
|
61
|
-
edits });
|
|
60
|
+
return Object.assign(Object.assign({}, _inlayHint), { position, textEdits: edits });
|
|
62
61
|
}
|
|
63
62
|
}).filter(shared.notEmpty), arr => arr.flat());
|
|
64
63
|
});
|
|
@@ -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.Location[] | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
import { DocumentsAndSourceMaps } from '../documents';
|
|
4
|
-
export declare function register(context:
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
5
5
|
export declare function mergeWorkspaceEdits(original: vscode.WorkspaceEdit, ...others: vscode.WorkspaceEdit[]): void;
|
|
6
|
-
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, documents: DocumentsAndSourceMaps): vscode.WorkspaceEdit | undefined;
|
|
6
|
+
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, documents: DocumentsAndSourceMaps, mode: 'fileName' | 'rename' | 'codeAction' | 'format', versions?: Record<string, number>): vscode.WorkspaceEdit | undefined;
|
|
@@ -87,7 +87,7 @@ function register(context) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
}), (data) => {
|
|
90
|
-
return embeddedEditToSourceEdit(data, context.documents);
|
|
90
|
+
return embeddedEditToSourceEdit(data, context.documents, 'rename');
|
|
91
91
|
}, (workspaceEdits) => {
|
|
92
92
|
const mainEdit = workspaceEdits[0];
|
|
93
93
|
const otherEdits = workspaceEdits.slice(1);
|
|
@@ -131,8 +131,9 @@ function mergeWorkspaceEdits(original, ...others) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
exports.mergeWorkspaceEdits = mergeWorkspaceEdits;
|
|
134
|
-
function embeddedEditToSourceEdit(tsResult, documents) {
|
|
135
|
-
var _a, _b, _c;
|
|
134
|
+
function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
135
|
+
var _a, _b, _c, _d, _e, _f;
|
|
136
|
+
var _g, _h, _j, _k;
|
|
136
137
|
const sourceResult = {};
|
|
137
138
|
let hasResult = false;
|
|
138
139
|
for (const tsUri in tsResult.changeAnnotations) {
|
|
@@ -159,54 +160,73 @@ function embeddedEditToSourceEdit(tsResult, documents) {
|
|
|
159
160
|
for (const [_, map] of documents.getMapsByVirtualFileUri(tsUri)) {
|
|
160
161
|
const tsEdits = tsResult.changes[tsUri];
|
|
161
162
|
for (const tsEdit of tsEdits) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
if (mode === 'rename' || mode === 'fileName') {
|
|
164
|
+
let _data;
|
|
165
|
+
const range = map.toSourceRange(tsEdit.range, data => {
|
|
166
|
+
_data = data;
|
|
167
|
+
return typeof data.rename === 'object' ? !!data.rename.apply : !!data.rename;
|
|
168
|
+
});
|
|
169
|
+
if (range) {
|
|
170
|
+
let newText = tsEdit.newText;
|
|
171
|
+
if (_data && typeof _data.rename === 'object' && _data.rename.apply) {
|
|
172
|
+
newText = _data.rename.apply(tsEdit.newText);
|
|
173
|
+
}
|
|
174
|
+
(_c = (_g = sourceResult.changes)[_h = map.sourceFileDocument.uri]) !== null && _c !== void 0 ? _c : (_g[_h] = []);
|
|
175
|
+
sourceResult.changes[map.sourceFileDocument.uri].push({ newText, range });
|
|
176
|
+
hasResult = true;
|
|
171
177
|
}
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const range = map.toSourceRange(tsEdit.range);
|
|
181
|
+
if (range) {
|
|
182
|
+
(_d = (_j = sourceResult.changes)[_k = map.sourceFileDocument.uri]) !== null && _d !== void 0 ? _d : (_j[_k] = []);
|
|
183
|
+
sourceResult.changes[map.sourceFileDocument.uri].push({ newText: tsEdit.newText, range });
|
|
184
|
+
hasResult = true;
|
|
174
185
|
}
|
|
175
|
-
sourceResult.changes[map.sourceFileDocument.uri].push({ newText, range });
|
|
176
|
-
hasResult = true;
|
|
177
186
|
}
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
}
|
|
181
190
|
if (tsResult.documentChanges) {
|
|
182
191
|
for (const tsDocEdit of tsResult.documentChanges) {
|
|
183
|
-
(
|
|
192
|
+
(_e = sourceResult.documentChanges) !== null && _e !== void 0 ? _e : (sourceResult.documentChanges = []);
|
|
184
193
|
let sourceEdit;
|
|
185
194
|
if (vscode.TextDocumentEdit.is(tsDocEdit)) {
|
|
186
195
|
if (documents.hasVirtualFileByUri(tsDocEdit.textDocument.uri)) {
|
|
187
196
|
for (const [_, map] of documents.getMapsByVirtualFileUri(tsDocEdit.textDocument.uri)) {
|
|
188
197
|
sourceEdit = vscode.TextDocumentEdit.create({
|
|
189
198
|
uri: map.sourceFileDocument.uri,
|
|
190
|
-
|
|
191
|
-
version: null, // fix https://github.com/johnsoncodehk/volar/issues/1490
|
|
199
|
+
version: (_f = versions[map.sourceFileDocument.uri]) !== null && _f !== void 0 ? _f : null,
|
|
192
200
|
}, []);
|
|
193
201
|
for (const tsEdit of tsDocEdit.edits) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (range) {
|
|
201
|
-
let newText = tsEdit.newText;
|
|
202
|
-
if (_data && typeof _data.rename === 'object' && _data.rename.apply) {
|
|
203
|
-
newText = _data.rename.apply(tsEdit.newText);
|
|
204
|
-
}
|
|
205
|
-
sourceEdit.edits.push({
|
|
206
|
-
annotationId: vscode.AnnotatedTextEdit.is(tsEdit.range) ? tsEdit.range.annotationId : undefined,
|
|
207
|
-
newText,
|
|
208
|
-
range,
|
|
202
|
+
if (mode === 'rename' || mode === 'fileName') {
|
|
203
|
+
let _data;
|
|
204
|
+
const range = map.toSourceRange(tsEdit.range, data => {
|
|
205
|
+
_data = data;
|
|
206
|
+
// fix https://github.com/johnsoncodehk/volar/issues/1091
|
|
207
|
+
return typeof data.rename === 'object' ? !!data.rename.apply : !!data.rename;
|
|
209
208
|
});
|
|
209
|
+
if (range) {
|
|
210
|
+
let newText = tsEdit.newText;
|
|
211
|
+
if (_data && typeof _data.rename === 'object' && _data.rename.apply) {
|
|
212
|
+
newText = _data.rename.apply(tsEdit.newText);
|
|
213
|
+
}
|
|
214
|
+
sourceEdit.edits.push({
|
|
215
|
+
annotationId: vscode.AnnotatedTextEdit.is(tsEdit.range) ? tsEdit.range.annotationId : undefined,
|
|
216
|
+
newText,
|
|
217
|
+
range,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
const range = map.toSourceRange(tsEdit.range);
|
|
223
|
+
if (range) {
|
|
224
|
+
sourceEdit.edits.push({
|
|
225
|
+
annotationId: vscode.AnnotatedTextEdit.is(tsEdit.range) ? tsEdit.range.annotationId : undefined,
|
|
226
|
+
newText: tsEdit.newText,
|
|
227
|
+
range,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
210
230
|
}
|
|
211
231
|
}
|
|
212
232
|
if (!sourceEdit.edits.length) {
|
|
@@ -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<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
@@ -1,34 +1,30 @@
|
|
|
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 vscode = require("vscode-languageserver-protocol");
|
|
13
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
5
|
function register(context) {
|
|
15
|
-
return (uri, position) =>
|
|
16
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.
|
|
6
|
+
return (uri, position) => {
|
|
7
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => { var _a, _b; return (_b = (_a = plugin.rename) === null || _a === void 0 ? void 0 : _a.prepare) === null || _b === void 0 ? void 0 : _b.call(_a, document, position); }, (item, map) => {
|
|
17
8
|
if (!map) {
|
|
18
9
|
return item;
|
|
19
10
|
}
|
|
20
11
|
if (vscode.Range.is(item)) {
|
|
21
12
|
return map.toSourceRange(item);
|
|
22
13
|
}
|
|
14
|
+
return item;
|
|
23
15
|
}, prepares => {
|
|
24
16
|
for (const prepare of prepares) {
|
|
25
17
|
if (vscode.Range.is(prepare)) {
|
|
26
18
|
return prepare; // if has any valid range, ignore other errors
|
|
27
19
|
}
|
|
28
20
|
}
|
|
29
|
-
|
|
21
|
+
const error = prepares[0];
|
|
22
|
+
const newError = new vscode.ResponseError(error.code, error.message);
|
|
23
|
+
newError.name = error.name;
|
|
24
|
+
newError.stack = error.stack;
|
|
25
|
+
return newError;
|
|
30
26
|
});
|
|
31
|
-
}
|
|
27
|
+
};
|
|
32
28
|
}
|
|
33
29
|
exports.register = register;
|
|
34
30
|
//# sourceMappingURL=renamePrepare.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type * 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, signatureHelpContext?: vscode.SignatureHelpContext) => Promise<vscode.SignatureHelp | undefined>;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
export declare function updateRange(range: vscode.Range, change: {
|
|
4
4
|
range: vscode.Range;
|
|
5
5
|
newEnd: vscode.Position;
|
|
6
6
|
}): vscode.Range | undefined;
|
|
7
7
|
export interface PluginDiagnosticData {
|
|
8
8
|
uri: string;
|
|
9
|
+
version: number;
|
|
9
10
|
original: Pick<vscode.Diagnostic, 'data'>;
|
|
10
11
|
type: 'plugin' | 'rule';
|
|
12
|
+
isFormat: boolean;
|
|
11
13
|
pluginOrRuleId: string;
|
|
12
14
|
ruleFixIndex: number;
|
|
13
15
|
documentUri: string;
|
|
14
16
|
}
|
|
15
|
-
export declare function register(context:
|
|
17
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|