@volar/language-service 1.2.0-alpha.9 → 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 +3 -2
- package/out/baseLanguageService.js +1 -0
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +34 -6
- package/out/documentFeatures/format.js +111 -52
- package/out/languageFeatures/codeActions.js +2 -2
- package/out/languageFeatures/documentLinks.js +1 -1
- package/out/languageFeatures/inlayHints.js +2 -3
- package/out/languageFeatures/rename.js +2 -2
- package/out/languageFeatures/renamePrepare.js +9 -13
- package/out/languageFeatures/validation.js +1 -1
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- 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 +9 -7
- package/out/utils/dedupe.d.ts +0 -1
- package/out/utils/dedupe.js +1 -13
- package/out/utils/featureWorkers.d.ts +1 -1
- package/out/utils/featureWorkers.js +16 -8
- package/package.json +9 -9
- package/out/languageFeatures/executeCommand.d.ts +0 -10
- package/out/languageFeatures/executeCommand.js +0 -24
|
@@ -4,6 +4,7 @@ import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
|
4
4
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
5
5
|
export type LanguageService = ReturnType<typeof createLanguageService>;
|
|
6
6
|
export declare function createLanguageService(host: LanguageServiceHost, config: Config, env: LanguageServicePluginContext['env'], documentRegistry?: ts.DocumentRegistry): {
|
|
7
|
+
triggerCharacters: string[];
|
|
7
8
|
format: (uri: string, options: _.FormattingOptions, range?: _.Range | undefined, onTypeParams?: {
|
|
8
9
|
ch: string;
|
|
9
10
|
position: _.Position;
|
|
@@ -11,7 +12,7 @@ export declare function createLanguageService(host: LanguageServiceHost, config:
|
|
|
11
12
|
getFoldingRanges: (uri: string) => Promise<_.FoldingRange[] | undefined>;
|
|
12
13
|
getSelectionRanges: (uri: string, positions: _.Position[]) => Promise<_.SelectionRange[] | undefined>;
|
|
13
14
|
findLinkedEditingRanges: (uri: string, position: _.Position) => Promise<_.LinkedEditingRanges | undefined>;
|
|
14
|
-
findDocumentSymbols: (uri: string) => Promise<_.
|
|
15
|
+
findDocumentSymbols: (uri: string) => Promise<_.DocumentSymbol[] | undefined>;
|
|
15
16
|
findDocumentColors: (uri: string) => Promise<_.ColorInformation[] | undefined>;
|
|
16
17
|
getColorPresentations: (uri: string, color: _.Color, range: _.Range) => Promise<_.ColorPresentation[] | undefined>;
|
|
17
18
|
doValidation: (uri: string, token?: _.CancellationToken | undefined, response?: ((result: _.Diagnostic[]) => void) | undefined) => Promise<_.Diagnostic[]>;
|
|
@@ -34,7 +35,7 @@ export declare function createLanguageService(host: LanguageServiceHost, config:
|
|
|
34
35
|
doCodeLensResolve: (item: _.CodeLens) => Promise<_.CodeLens>;
|
|
35
36
|
findDocumentHighlights: (uri: string, position: _.Position) => Promise<_.DocumentHighlight[] | undefined>;
|
|
36
37
|
findDocumentLinks: (uri: string) => Promise<_.DocumentLink[]>;
|
|
37
|
-
findWorkspaceSymbols: (query: string) => Promise<_.
|
|
38
|
+
findWorkspaceSymbols: (query: string) => Promise<_.WorkspaceSymbol[]>;
|
|
38
39
|
doAutoInsert: (uri: string, position: _.Position, autoInsertContext: {
|
|
39
40
|
lastChange: {
|
|
40
41
|
range: _.Range;
|
|
@@ -103,6 +103,7 @@ function createLanguageServiceContext(host, languageContext, config, env, docume
|
|
|
103
103
|
}
|
|
104
104
|
function createLanguageServiceBase(context) {
|
|
105
105
|
return {
|
|
106
|
+
triggerCharacters: Object.values(context.plugins).map(plugin => { var _a, _b; return (_b = (_a = plugin.complete) === null || _a === void 0 ? void 0 : _a.triggerCharacters) !== null && _b !== void 0 ? _b : []; }).flat(),
|
|
106
107
|
format: format.register(context),
|
|
107
108
|
getFoldingRanges: foldingRanges.register(context),
|
|
108
109
|
getSelectionRanges: selectionRanges.register(context),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LanguageServicePluginContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
@@ -1,16 +1,44 @@
|
|
|
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
|
+
};
|
|
1
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
11
|
exports.register = void 0;
|
|
3
12
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
13
|
const transformer = require("../transformer");
|
|
5
|
-
const
|
|
14
|
+
const shared = require("@volar/shared");
|
|
15
|
+
const common_1 = require("../utils/common");
|
|
6
16
|
function register(context) {
|
|
7
17
|
return (uri) => {
|
|
8
|
-
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => { var _a; return (_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => map
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }), (data, map) => map
|
|
19
|
+
? data
|
|
20
|
+
.map(symbol => transformer.asDocumentSymbol(symbol, range => map.toSourceRange(range)))
|
|
21
|
+
.filter(shared.notEmpty)
|
|
22
|
+
: data, results => {
|
|
23
|
+
for (let i = 0; i < results.length; i++) {
|
|
24
|
+
for (let j = 0; j < results.length; j++) {
|
|
25
|
+
if (i === j)
|
|
26
|
+
continue;
|
|
27
|
+
results[i] = results[i].filter(child => {
|
|
28
|
+
var _a;
|
|
29
|
+
for (const parent of results[j]) {
|
|
30
|
+
if ((0, common_1.isInsideRange)(parent.range, child.range)) {
|
|
31
|
+
(_a = parent.children) !== null && _a !== void 0 ? _a : (parent.children = []);
|
|
32
|
+
parent.children.push(child);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
12
39
|
}
|
|
13
|
-
|
|
40
|
+
return results.flat();
|
|
41
|
+
});
|
|
14
42
|
};
|
|
15
43
|
}
|
|
16
44
|
exports.register = register;
|
|
@@ -20,13 +20,13 @@ function register(context) {
|
|
|
20
20
|
if (!document)
|
|
21
21
|
return;
|
|
22
22
|
range !== null && range !== void 0 ? range : (range = vscode.Range.create(document.positionAt(0), document.positionAt(document.getText().length)));
|
|
23
|
-
const initialIndentLanguageId = (_b = yield ((_a = context.env.configurationHost) === null || _a === void 0 ? void 0 : _a.getConfiguration('volar.format.initialIndent'))) !== null && _b !== void 0 ? _b : { html: true };
|
|
24
23
|
const source = context.documents.getSourceByUri(document.uri);
|
|
25
24
|
if (!source) {
|
|
26
25
|
return onTypeParams
|
|
27
|
-
? yield tryFormat(
|
|
28
|
-
: yield tryFormat(
|
|
26
|
+
? yield tryFormat(document, onTypeParams.position, onTypeParams.ch)
|
|
27
|
+
: yield tryFormat(document, range, undefined);
|
|
29
28
|
}
|
|
29
|
+
const initialIndentLanguageId = (_b = yield ((_a = context.env.configurationHost) === null || _a === void 0 ? void 0 : _a.getConfiguration('volar.format.initialIndent'))) !== null && _b !== void 0 ? _b : { html: true };
|
|
30
30
|
const originalSnapshot = source.snapshot;
|
|
31
31
|
const rootVirtualFile = source.root;
|
|
32
32
|
const originalDocument = document;
|
|
@@ -37,42 +37,37 @@ function register(context) {
|
|
|
37
37
|
if (embeddedFiles.length === 0)
|
|
38
38
|
break;
|
|
39
39
|
let edits = [];
|
|
40
|
-
|
|
40
|
+
const toPatchIndentUris = [];
|
|
41
41
|
for (const embedded of embeddedFiles) {
|
|
42
42
|
if (!embedded.capabilities.documentFormatting)
|
|
43
43
|
continue;
|
|
44
|
+
const isCodeBlock = embedded.mappings.length === 1 && embedded.mappings[0].generatedRange[0] === 0 && embedded.mappings[0].generatedRange[1] === embedded.snapshot.getLength();
|
|
45
|
+
if (onTypeParams && !isCodeBlock)
|
|
46
|
+
continue;
|
|
44
47
|
const maps = [...context.documents.getMapsByVirtualFileName(embedded.fileName)];
|
|
45
48
|
const map = (_c = maps.find(map => map[1].sourceFileDocument.uri === document.uri)) === null || _c === void 0 ? void 0 : _c[1];
|
|
46
49
|
if (!map)
|
|
47
50
|
continue;
|
|
48
|
-
let
|
|
51
|
+
let virtualCodeEdits;
|
|
49
52
|
if (onTypeParams) {
|
|
50
53
|
const embeddedPosition = map.toGeneratedPosition(onTypeParams.position);
|
|
51
54
|
if (embeddedPosition) {
|
|
52
|
-
|
|
55
|
+
virtualCodeEdits = yield tryFormat(map.virtualFileDocument, embeddedPosition, onTypeParams.ch);
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
else {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (firstMapping && document.offsetAt(range.start) < firstMapping.sourceRange[0]
|
|
61
|
-
&& lastMapping && document.offsetAt(range.end) > lastMapping.sourceRange[1]) {
|
|
62
|
-
genRange = {
|
|
63
|
-
start: map.virtualFileDocument.positionAt(firstMapping.generatedRange[0]),
|
|
64
|
-
end: map.virtualFileDocument.positionAt(lastMapping.generatedRange[1]),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (genRange) {
|
|
69
|
-
toPatchIndentUri = map.virtualFileDocument.uri;
|
|
70
|
-
_edits = yield tryFormat(true, map.virtualFileDocument, genRange);
|
|
71
|
-
}
|
|
59
|
+
virtualCodeEdits = yield tryFormat(map.virtualFileDocument, {
|
|
60
|
+
start: map.virtualFileDocument.positionAt(0),
|
|
61
|
+
end: map.virtualFileDocument.positionAt(map.virtualFileDocument.getText().length),
|
|
62
|
+
});
|
|
72
63
|
}
|
|
73
|
-
if (!
|
|
64
|
+
if (!virtualCodeEdits)
|
|
74
65
|
continue;
|
|
75
|
-
|
|
66
|
+
toPatchIndentUris.push({
|
|
67
|
+
uri: map.virtualFileDocument.uri,
|
|
68
|
+
isCodeBlock,
|
|
69
|
+
});
|
|
70
|
+
for (const textEdit of virtualCodeEdits) {
|
|
76
71
|
const range = map.toSourceRange(textEdit.range);
|
|
77
72
|
if (range) {
|
|
78
73
|
edits.push({
|
|
@@ -82,20 +77,57 @@ function register(context) {
|
|
|
82
77
|
}
|
|
83
78
|
}
|
|
84
79
|
}
|
|
80
|
+
edits = edits.filter(edit => (0, common_1.isInsideRange)(range, edit.range));
|
|
85
81
|
if (edits.length > 0) {
|
|
86
82
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
87
83
|
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
88
84
|
context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
|
|
89
85
|
edited = true;
|
|
90
86
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
if (level > 1) {
|
|
88
|
+
const baseIndent = options.insertSpaces ? ' '.repeat(options.tabSize) : '\t';
|
|
89
|
+
const editLines = new Set();
|
|
90
|
+
if (onTypeParams) {
|
|
91
|
+
for (const edit of edits) {
|
|
92
|
+
for (let line = edit.range.start.line; line <= edit.range.end.line; line++) {
|
|
93
|
+
editLines.add(line);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const toPatchIndentUri of toPatchIndentUris) {
|
|
98
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(toPatchIndentUri.uri)) {
|
|
99
|
+
const indentSensitiveLines = new Set();
|
|
100
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
101
|
+
if (plugin.getIndentSensitiveLines) {
|
|
102
|
+
const lines = yield plugin.getIndentSensitiveLines(map.virtualFileDocument);
|
|
103
|
+
if (lines) {
|
|
104
|
+
for (const line of lines) {
|
|
105
|
+
indentSensitiveLines.add(line);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
let indentEdits = patchIndents(document, toPatchIndentUri.isCodeBlock, map.map, initialIndentLanguageId[map.virtualFileDocument.languageId] ? baseIndent : '');
|
|
111
|
+
indentEdits = indentEdits.filter(edit => {
|
|
112
|
+
for (let line = edit.range.start.line; line <= edit.range.end.line; line++) {
|
|
113
|
+
if (indentSensitiveLines.has(line) && !edit.newText.includes('\n')) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (onTypeParams && !editLines.has(line)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (!(0, common_1.isInsideRange)(range, edit.range)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
});
|
|
125
|
+
if (indentEdits.length > 0) {
|
|
126
|
+
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, indentEdits);
|
|
127
|
+
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
128
|
+
context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
|
|
129
|
+
edited = true;
|
|
130
|
+
}
|
|
99
131
|
}
|
|
100
132
|
}
|
|
101
133
|
}
|
|
@@ -121,7 +153,7 @@ function register(context) {
|
|
|
121
153
|
embeddedFilesByLevel.push(nextLevel);
|
|
122
154
|
}
|
|
123
155
|
}
|
|
124
|
-
function tryFormat(
|
|
156
|
+
function tryFormat(document, range, ch) {
|
|
125
157
|
var _a, _b;
|
|
126
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
159
|
let formatRange = range;
|
|
@@ -132,11 +164,11 @@ function register(context) {
|
|
|
132
164
|
edits = yield ((_a = plugin.formatOnType) === null || _a === void 0 ? void 0 : _a.call(plugin, document, formatRange, ch, options));
|
|
133
165
|
}
|
|
134
166
|
else if (ch === undefined && vscode.Range.is(formatRange)) {
|
|
135
|
-
edits = yield ((_b = plugin.format) === null || _b === void 0 ? void 0 : _b.call(plugin, document, formatRange,
|
|
167
|
+
edits = yield ((_b = plugin.format) === null || _b === void 0 ? void 0 : _b.call(plugin, document, formatRange, options));
|
|
136
168
|
}
|
|
137
169
|
}
|
|
138
170
|
catch (err) {
|
|
139
|
-
console.
|
|
171
|
+
console.warn(err);
|
|
140
172
|
}
|
|
141
173
|
if (!edits)
|
|
142
174
|
continue;
|
|
@@ -147,28 +179,55 @@ function register(context) {
|
|
|
147
179
|
});
|
|
148
180
|
}
|
|
149
181
|
exports.register = register;
|
|
150
|
-
function
|
|
182
|
+
function patchIndents(document, isCodeBlock, map, initialIndent) {
|
|
151
183
|
const indentTextEdits = [];
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
if (!isCodeBlock) {
|
|
185
|
+
initialIndent = '';
|
|
186
|
+
}
|
|
187
|
+
for (let i = 0; i < map.mappings.length; i++) {
|
|
188
|
+
const mapping = map.mappings[i];
|
|
189
|
+
const firstLineIndent = getBaseIndent(mapping.sourceRange[0]);
|
|
190
|
+
const text = document.getText().substring(mapping.sourceRange[0], mapping.sourceRange[1]);
|
|
191
|
+
const lines = text.split('\n');
|
|
192
|
+
const baseIndent = firstLineIndent + initialIndent;
|
|
193
|
+
let lineOffset = lines[0].length + 1;
|
|
194
|
+
let insertedFinalNewLine = false;
|
|
195
|
+
if (!text.trim())
|
|
155
196
|
continue;
|
|
197
|
+
if (isCodeBlock && text.trimStart().length === text.length) {
|
|
198
|
+
indentTextEdits.push({
|
|
199
|
+
newText: '\n' + baseIndent,
|
|
200
|
+
range: {
|
|
201
|
+
start: document.positionAt(mapping.sourceRange[0]),
|
|
202
|
+
end: document.positionAt(mapping.sourceRange[0]),
|
|
203
|
+
},
|
|
204
|
+
});
|
|
156
205
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
206
|
+
if (isCodeBlock && text.trimEnd().length === text.length) {
|
|
207
|
+
indentTextEdits.push({
|
|
208
|
+
newText: '\n',
|
|
209
|
+
range: {
|
|
210
|
+
start: document.positionAt(mapping.sourceRange[1]),
|
|
211
|
+
end: document.positionAt(mapping.sourceRange[1]),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
insertedFinalNewLine = true;
|
|
160
215
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
216
|
+
if (baseIndent && lines.length > 1) {
|
|
217
|
+
for (let i = 1; i < lines.length; i++) {
|
|
218
|
+
if (lines[i].trim() || i === lines.length - 1) {
|
|
219
|
+
const isLastLine = i === lines.length - 1 && !insertedFinalNewLine;
|
|
220
|
+
indentTextEdits.push({
|
|
221
|
+
newText: isLastLine ? firstLineIndent : baseIndent,
|
|
222
|
+
range: {
|
|
223
|
+
start: document.positionAt(mapping.sourceRange[0] + lineOffset),
|
|
224
|
+
end: document.positionAt(mapping.sourceRange[0] + lineOffset),
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
lineOffset += lines[i].length + 1;
|
|
229
|
+
}
|
|
164
230
|
}
|
|
165
|
-
indentTextEdits.push({
|
|
166
|
-
newText: lines.join('\n'),
|
|
167
|
-
range: {
|
|
168
|
-
start: document.positionAt(mapped.sourceRange[0]),
|
|
169
|
-
end: document.positionAt(mapped.sourceRange[1]),
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
231
|
}
|
|
173
232
|
return indentTextEdits;
|
|
174
233
|
function getBaseIndent(pos) {
|
|
@@ -60,7 +60,7 @@ function register(context) {
|
|
|
60
60
|
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {
|
|
61
61
|
const data = diagnostic.data;
|
|
62
62
|
if (data && data.version !== sourceDocument.version) {
|
|
63
|
-
console.warn('[volar/plugin-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
63
|
+
// console.warn('[volar/plugin-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
return (data === null || data === void 0 ? void 0 : data.type) === 'plugin' && (data === null || data === void 0 ? void 0 : data.pluginOrRuleId) === pluginId;
|
|
@@ -100,7 +100,7 @@ function register(context) {
|
|
|
100
100
|
for (const diagnostic of codeActionContext.diagnostics) {
|
|
101
101
|
const data = diagnostic.data;
|
|
102
102
|
if (data && data.version !== sourceDocument.version) {
|
|
103
|
-
console.warn('[volar/rules-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
103
|
+
// console.warn('[volar/rules-api] diagnostic version mismatch', data.version, sourceDocument.version);
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
106
|
if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
|
|
@@ -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);
|
|
@@ -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
|
});
|
|
@@ -160,7 +160,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
160
160
|
for (const [_, map] of documents.getMapsByVirtualFileUri(tsUri)) {
|
|
161
161
|
const tsEdits = tsResult.changes[tsUri];
|
|
162
162
|
for (const tsEdit of tsEdits) {
|
|
163
|
-
if (mode === 'rename') {
|
|
163
|
+
if (mode === 'rename' || mode === 'fileName') {
|
|
164
164
|
let _data;
|
|
165
165
|
const range = map.toSourceRange(tsEdit.range, data => {
|
|
166
166
|
_data = data;
|
|
@@ -199,7 +199,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
199
199
|
version: (_f = versions[map.sourceFileDocument.uri]) !== null && _f !== void 0 ? _f : null,
|
|
200
200
|
}, []);
|
|
201
201
|
for (const tsEdit of tsDocEdit.edits) {
|
|
202
|
-
if (mode === 'rename') {
|
|
202
|
+
if (mode === 'rename' || mode === 'fileName') {
|
|
203
203
|
let _data;
|
|
204
204
|
const range = map.toSourceRange(tsEdit.range, data => {
|
|
205
205
|
_data = data;
|
|
@@ -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
|
|
@@ -162,7 +162,7 @@ function register(context) {
|
|
|
162
162
|
}
|
|
163
163
|
function lintWorker(api, cacheMap, cache) {
|
|
164
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
const result = yield (0, featureWorkers_1.ruleWorker)(context, uri, file => api === 'onFormat' ? !!file.capabilities.documentFormatting : !!file.capabilities.diagnostic, (ruleName, rule, ruleCtx) => __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
const result = yield (0, featureWorkers_1.ruleWorker)(context, api, uri, file => api === 'onFormat' ? !!file.capabilities.documentFormatting : !!file.capabilities.diagnostic, (ruleName, rule, ruleCtx) => __awaiter(this, void 0, void 0, function* () {
|
|
166
166
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
167
167
|
var _h, _j, _k, _l;
|
|
168
168
|
if (token) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (query: string) => Promise<vscode.
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (query: string) => Promise<vscode.WorkspaceSymbol[]>;
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const transformer = require("../transformer");
|
|
13
13
|
const vscode = require("vscode-languageserver-protocol");
|
|
14
|
+
const shared = require("@volar/shared");
|
|
14
15
|
function register(context) {
|
|
15
16
|
return (query) => __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
const symbolsList = [];
|
|
@@ -20,7 +21,7 @@ function register(context) {
|
|
|
20
21
|
const embeddedSymbols = yield plugin.findWorkspaceSymbols(query);
|
|
21
22
|
if (!embeddedSymbols)
|
|
22
23
|
continue;
|
|
23
|
-
const symbols = transformer.
|
|
24
|
+
const symbols = embeddedSymbols.map(symbol => transformer.asWorkspaceSymbol(symbol, loc => {
|
|
24
25
|
if (context.documents.hasVirtualFileByUri(loc.uri)) {
|
|
25
26
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(loc.uri)) {
|
|
26
27
|
const range = map.toSourceRange(loc.range);
|
|
@@ -32,7 +33,7 @@ function register(context) {
|
|
|
32
33
|
else {
|
|
33
34
|
return loc;
|
|
34
35
|
}
|
|
35
|
-
});
|
|
36
|
+
})).filter(shared.notEmpty);
|
|
36
37
|
symbolsList.push(symbols);
|
|
37
38
|
}
|
|
38
39
|
return symbolsList.flat();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const shared = require("@volar/shared");
|
|
4
|
+
function transform(symbol, getOtherRange) {
|
|
5
|
+
var _a;
|
|
6
|
+
const range = getOtherRange(symbol.range);
|
|
7
|
+
if (!range) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const selectionRange = getOtherRange(symbol.selectionRange);
|
|
11
|
+
if (!selectionRange) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
return Object.assign(Object.assign({}, symbol), { range,
|
|
15
|
+
selectionRange, children: (_a = symbol.children) === null || _a === void 0 ? void 0 : _a.map(child => transform(child, getOtherRange)).filter(shared.notEmpty) });
|
|
16
|
+
}
|
|
17
|
+
exports.transform = transform;
|
|
18
|
+
//# sourceMappingURL=documentSymbol.js.map
|
|
@@ -6,6 +6,6 @@ export { transform as asLocation } from './locationLike';
|
|
|
6
6
|
export { transform as asLocations } from './locationsLike';
|
|
7
7
|
export { transform as asSelectionRange } from './selectionRange';
|
|
8
8
|
export { transform as asSelectionRanges } from './selectionRanges';
|
|
9
|
-
export { transform as asSymbolInformation } from './symbolInformation';
|
|
10
|
-
export { transform as asSymbolInformations } from './symbolInformations';
|
|
11
9
|
export { transform as asTextEdit } from './textEdit';
|
|
10
|
+
export { transform as asDocumentSymbol } from './documentSymbol';
|
|
11
|
+
export { transform as asWorkspaceSymbol } from './workspaceSymbol';
|
package/out/transformer/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.asWorkspaceSymbol = exports.asDocumentSymbol = exports.asTextEdit = exports.asSelectionRanges = exports.asSelectionRange = exports.asLocations = exports.asLocation = exports.asHover = exports.asFoldingRanges = exports.asCompletionList = exports.asCompletionItem = void 0;
|
|
3
3
|
var completionItem_1 = require("./completionItem");
|
|
4
4
|
Object.defineProperty(exports, "asCompletionItem", { enumerable: true, get: function () { return completionItem_1.transform; } });
|
|
5
5
|
var completionList_1 = require("./completionList");
|
|
@@ -16,10 +16,10 @@ var selectionRange_1 = require("./selectionRange");
|
|
|
16
16
|
Object.defineProperty(exports, "asSelectionRange", { enumerable: true, get: function () { return selectionRange_1.transform; } });
|
|
17
17
|
var selectionRanges_1 = require("./selectionRanges");
|
|
18
18
|
Object.defineProperty(exports, "asSelectionRanges", { enumerable: true, get: function () { return selectionRanges_1.transform; } });
|
|
19
|
-
var symbolInformation_1 = require("./symbolInformation");
|
|
20
|
-
Object.defineProperty(exports, "asSymbolInformation", { enumerable: true, get: function () { return symbolInformation_1.transform; } });
|
|
21
|
-
var symbolInformations_1 = require("./symbolInformations");
|
|
22
|
-
Object.defineProperty(exports, "asSymbolInformations", { enumerable: true, get: function () { return symbolInformations_1.transform; } });
|
|
23
19
|
var textEdit_1 = require("./textEdit");
|
|
24
20
|
Object.defineProperty(exports, "asTextEdit", { enumerable: true, get: function () { return textEdit_1.transform; } });
|
|
21
|
+
var documentSymbol_1 = require("./documentSymbol");
|
|
22
|
+
Object.defineProperty(exports, "asDocumentSymbol", { enumerable: true, get: function () { return documentSymbol_1.transform; } });
|
|
23
|
+
var workspaceSymbol_1 = require("./workspaceSymbol");
|
|
24
|
+
Object.defineProperty(exports, "asWorkspaceSymbol", { enumerable: true, get: function () { return workspaceSymbol_1.transform; } });
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
4
|
+
function transform(symbol, getOtherLocation) {
|
|
5
|
+
if (!vscode.Location.is(symbol.location)) {
|
|
6
|
+
return symbol;
|
|
7
|
+
}
|
|
8
|
+
const loc = getOtherLocation(symbol.location);
|
|
9
|
+
if (!loc) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return Object.assign(Object.assign({}, symbol), { location: loc });
|
|
13
|
+
}
|
|
14
|
+
exports.transform = transform;
|
|
15
|
+
//# sourceMappingURL=workspaceSymbol.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface LanguageServicePluginContext {
|
|
|
18
18
|
rootUri: URI;
|
|
19
19
|
locale?: string;
|
|
20
20
|
configurationHost?: ConfigurationHost;
|
|
21
|
-
documentContext
|
|
21
|
+
documentContext?: DocumentContext;
|
|
22
22
|
fileSystemProvider?: FileSystemProvider;
|
|
23
23
|
schemaRequestService?: SchemaRequestService;
|
|
24
24
|
};
|
|
@@ -60,7 +60,10 @@ export interface LanguageServicePlugin<T = {}> {
|
|
|
60
60
|
}
|
|
61
61
|
export interface LanguageServicePluginInstance {
|
|
62
62
|
rules?: {
|
|
63
|
-
|
|
63
|
+
onAny?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
64
|
+
onFormat?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
65
|
+
onSyntax?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
66
|
+
onSemantic?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
64
67
|
};
|
|
65
68
|
validation?: {
|
|
66
69
|
onSemantic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
@@ -74,19 +77,18 @@ export interface LanguageServicePluginInstance {
|
|
|
74
77
|
findFileReferences?(document: TextDocument): NullableResult<vscode.Location[]>;
|
|
75
78
|
findDocumentHighlights?(document: TextDocument, position: vscode.Position): NullableResult<vscode.DocumentHighlight[]>;
|
|
76
79
|
findDocumentLinks?(document: TextDocument): NullableResult<vscode.DocumentLink[]>;
|
|
77
|
-
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.
|
|
80
|
+
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.DocumentSymbol[]>;
|
|
78
81
|
findDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend): NullableResult<SemanticToken[]>;
|
|
79
|
-
findWorkspaceSymbols?(query: string): NullableResult<vscode.
|
|
82
|
+
findWorkspaceSymbols?(query: string): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
80
83
|
findDocumentColors?(document: TextDocument): NullableResult<vscode.ColorInformation[]>;
|
|
81
84
|
getColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range): NullableResult<vscode.ColorPresentation[]>;
|
|
82
85
|
doFileRename?(oldUri: string, newUri: string): NullableResult<vscode.WorkspaceEdit>;
|
|
83
86
|
getFoldingRanges?(document: TextDocument): NullableResult<vscode.FoldingRange[]>;
|
|
84
87
|
getSelectionRanges?(document: TextDocument, positions: vscode.Position[]): NullableResult<vscode.SelectionRange[]>;
|
|
85
88
|
getSignatureHelp?(document: TextDocument, position: vscode.Position, context?: vscode.SignatureHelpContext): NullableResult<vscode.SignatureHelp>;
|
|
86
|
-
format?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions
|
|
87
|
-
initialIndent: boolean;
|
|
88
|
-
}): NullableResult<vscode.TextEdit[]>;
|
|
89
|
+
format?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
89
90
|
formatOnType?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
91
|
+
getIndentSensitiveLines?(document: TextDocument): NullableResult<number[]>;
|
|
90
92
|
definition?: {
|
|
91
93
|
on?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
92
94
|
onType?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
package/out/utils/dedupe.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export declare function withCodeAction<T extends vscode.CodeAction>(items: T[]):
|
|
|
7
7
|
export declare function withTextEdits<T extends vscode.TextEdit>(items: T[]): T[];
|
|
8
8
|
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.TextDocumentEdit | vscode.CreateFile | vscode.RenameFile | vscode.DeleteFile)[];
|
|
9
9
|
export declare function withDiagnostics<T extends vscode.Diagnostic>(items: T[]): T[];
|
|
10
|
-
export declare function withSymbolInformations<T extends vscode.SymbolInformation>(items: T[]): T[];
|
|
11
10
|
export declare function withLocations<T extends vscode.Location>(items: T[]): T[];
|
|
12
11
|
export declare function withLocationLinks<T extends vscode.LocationLink>(items: T[]): T[];
|
|
13
12
|
export declare function withCallHierarchyIncomingCalls<T extends vscode.CallHierarchyIncomingCall>(items: T[]): T[];
|
package/out/utils/dedupe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.withRanges = exports.withCallHierarchyOutgoingCalls = exports.withCallHierarchyIncomingCalls = exports.withLocationLinks = exports.withLocations = exports.
|
|
2
|
+
exports.withRanges = exports.withCallHierarchyOutgoingCalls = exports.withCallHierarchyIncomingCalls = exports.withLocationLinks = exports.withLocations = exports.withDiagnostics = exports.withDocumentChanges = exports.withTextEdits = exports.withCodeAction = exports.createLocationSet = void 0;
|
|
3
3
|
function createLocationSet() {
|
|
4
4
|
const set = new Set();
|
|
5
5
|
return {
|
|
@@ -60,18 +60,6 @@ function withDiagnostics(items) {
|
|
|
60
60
|
].join(':'));
|
|
61
61
|
}
|
|
62
62
|
exports.withDiagnostics = withDiagnostics;
|
|
63
|
-
function withSymbolInformations(items) {
|
|
64
|
-
return dedupe(items, item => [
|
|
65
|
-
item.name,
|
|
66
|
-
item.kind,
|
|
67
|
-
item.location.uri,
|
|
68
|
-
item.location.range.start.line,
|
|
69
|
-
item.location.range.start.character,
|
|
70
|
-
item.location.range.end.line,
|
|
71
|
-
item.location.range.end.character,
|
|
72
|
-
].join(':'));
|
|
73
|
-
}
|
|
74
|
-
exports.withSymbolInformations = withSymbolInformations;
|
|
75
63
|
function withLocations(items) {
|
|
76
64
|
return dedupe(items, item => [
|
|
77
65
|
item.uri,
|
|
@@ -4,4 +4,4 @@ import { FileRangeCapabilities, VirtualFile } from '@volar/language-service';
|
|
|
4
4
|
import { SourceMapWithDocuments } from '../documents';
|
|
5
5
|
export declare function documentFeatureWorker<T>(context: LanguageServicePluginContext, uri: string, isValidSourceMap: (file: VirtualFile, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>) => boolean, worker: (plugin: LanguageServicePluginInstance, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
6
6
|
export declare function languageFeatureWorker<T, K>(context: LanguageServicePluginContext, uri: string, arg: K, transformArg: (arg: K, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>, file: VirtualFile) => Generator<K> | K[], worker: (plugin: LanguageServicePluginInstance, document: TextDocument, arg: K, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined, file: VirtualFile | undefined) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
7
|
-
export declare function ruleWorker<T>(context: LanguageServicePluginContext, uri: string, isValidSourceMap: (file: VirtualFile) => boolean, worker: (ruleName: string, rule: Rule, ruleCtx: RuleContext) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
7
|
+
export declare function ruleWorker<T>(context: LanguageServicePluginContext, api: 'onSyntax' | 'onSemantic' | 'onFormat', uri: string, isValidSourceMap: (file: VirtualFile) => boolean, worker: (ruleName: string, rule: Rule, ruleCtx: RuleContext) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
@@ -76,7 +76,7 @@ function languageFeatureWorker(context, uri, arg, transformArg, worker, transfor
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
exports.languageFeatureWorker = languageFeatureWorker;
|
|
79
|
-
function ruleWorker(context, uri, isValidSourceMap, worker, transform, combineResult, reportProgress) {
|
|
79
|
+
function ruleWorker(context, api, uri, isValidSourceMap, worker, transform, combineResult, reportProgress) {
|
|
80
80
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
82
|
const document = context.getTextDocument(uri);
|
|
@@ -84,7 +84,7 @@ function ruleWorker(context, uri, isValidSourceMap, worker, transform, combineRe
|
|
|
84
84
|
let results = [];
|
|
85
85
|
if (virtualFile) {
|
|
86
86
|
yield (0, definePlugin_1.visitEmbedded)(context.documents, virtualFile, (file, map) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
var _l, _m, _o, _p, _q, _r, _s, _t;
|
|
87
|
+
var _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
88
88
|
if (!isValidSourceMap(file)) {
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
@@ -104,12 +104,16 @@ function ruleWorker(context, uri, isValidSourceMap, worker, transform, combineRe
|
|
|
104
104
|
report: () => { },
|
|
105
105
|
};
|
|
106
106
|
for (const plugin of Object.values(context.plugins)) {
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const fn = (_r = plugin.rules) === null || _r === void 0 ? void 0 : _r[api];
|
|
108
|
+
if (fn) {
|
|
109
|
+
ruleCtx = yield fn(ruleCtx);
|
|
110
|
+
}
|
|
111
|
+
else if ((_s = plugin.rules) === null || _s === void 0 ? void 0 : _s.onAny) {
|
|
112
|
+
ruleCtx = yield plugin.rules.onAny(ruleCtx);
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
for (const ruleName in (
|
|
112
|
-
const rule = (
|
|
115
|
+
for (const ruleName in (_t = context.config.lint) === null || _t === void 0 ? void 0 : _t.rules) {
|
|
116
|
+
const rule = (_u = context.config.lint) === null || _u === void 0 ? void 0 : _u.rules[ruleName];
|
|
113
117
|
if (!rule) {
|
|
114
118
|
continue;
|
|
115
119
|
}
|
|
@@ -148,8 +152,12 @@ function ruleWorker(context, uri, isValidSourceMap, worker, transform, combineRe
|
|
|
148
152
|
report: () => { },
|
|
149
153
|
};
|
|
150
154
|
for (const plugin of Object.values(context.plugins)) {
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
const fn = (_g = plugin.rules) === null || _g === void 0 ? void 0 : _g[api];
|
|
156
|
+
if (fn) {
|
|
157
|
+
ruleCtx = yield fn(ruleCtx);
|
|
158
|
+
}
|
|
159
|
+
else if ((_h = plugin.rules) === null || _h === void 0 ? void 0 : _h.onAny) {
|
|
160
|
+
ruleCtx = yield plugin.rules.onAny(ruleCtx);
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
163
|
for (const ruleName in (_j = context.config.lint) === null || _j === void 0 ? void 0 : _j.rules) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.
|
|
17
|
-
"@volar/shared": "1.
|
|
18
|
-
"@volar/source-map": "1.
|
|
19
|
-
"@volar/typescript-faster": "1.
|
|
20
|
-
"vscode-html-languageservice": "^5.0.
|
|
21
|
-
"vscode-json-languageservice": "^5.
|
|
22
|
-
"vscode-languageserver-protocol": "^3.17.
|
|
16
|
+
"@volar/language-core": "1.3.0-alpha.0",
|
|
17
|
+
"@volar/shared": "1.3.0-alpha.0",
|
|
18
|
+
"@volar/source-map": "1.3.0-alpha.0",
|
|
19
|
+
"@volar/typescript-faster": "1.3.0-alpha.0",
|
|
20
|
+
"vscode-html-languageservice": "^5.0.4",
|
|
21
|
+
"vscode-json-languageservice": "^5.2.0",
|
|
22
|
+
"vscode-languageserver-protocol": "^3.17.3",
|
|
23
23
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
24
24
|
"vscode-uri": "^3.0.7"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "7582403cc521d33f642183a32da44fb1f64e65ef"
|
|
27
27
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { LanguageServiceRuntimeContext } from '../types';
|
|
2
|
-
import { ExecuteCommandContext } from '@volar/language-service';
|
|
3
|
-
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
|
-
export declare const executePluginCommand: string;
|
|
5
|
-
export type ExecutePluginCommandArgs = [
|
|
6
|
-
string,
|
|
7
|
-
string,
|
|
8
|
-
vscode.Command
|
|
9
|
-
];
|
|
10
|
-
export declare function register(context: LanguageServiceRuntimeContext): (command: string, args: ExecutePluginCommandArgs, executeCommandContext: ExecuteCommandContext) => Promise<void>;
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.register = exports.executePluginCommand = void 0;
|
|
12
|
-
const randomCommandId = Math.random().toString(36).slice(2); // TODO
|
|
13
|
-
exports.executePluginCommand = `volar.${randomCommandId}.executePluginCommand`;
|
|
14
|
-
function register(context) {
|
|
15
|
-
return (command, args, executeCommandContext) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
if (command === exports.executePluginCommand) {
|
|
18
|
-
const [_uri, pluginId, originalCommand] = args;
|
|
19
|
-
yield ((_b = (_a = context.plugins[pluginId]) === null || _a === void 0 ? void 0 : _a.doExecuteCommand) === null || _b === void 0 ? void 0 : _b.call(_a, originalCommand.command, originalCommand.arguments, executeCommandContext));
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.register = register;
|
|
24
|
-
//# sourceMappingURL=executeCommand.js.map
|