@volar/language-service 1.4.0-alpha.0 → 1.4.0-alpha.2
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 +31 -31
- package/out/baseLanguageService.js +20 -16
- package/out/documentFeatures/colorPresentations.d.ts +1 -1
- package/out/documentFeatures/colorPresentations.js +3 -3
- package/out/documentFeatures/documentColors.d.ts +1 -1
- package/out/documentFeatures/documentColors.js +2 -3
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +6 -16
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.js +3 -3
- package/out/documentFeatures/format.d.ts +1 -1
- package/out/documentFeatures/format.js +29 -42
- package/out/documentFeatures/linkedEditingRanges.d.ts +1 -1
- package/out/documentFeatures/linkedEditingRanges.js +3 -3
- package/out/documentFeatures/selectionRanges.d.ts +1 -1
- package/out/documentFeatures/selectionRanges.js +3 -3
- package/out/documents.js +28 -16
- package/out/languageFeatures/autoInsert.d.ts +1 -1
- package/out/languageFeatures/autoInsert.js +9 -7
- package/out/languageFeatures/callHierarchy.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.js +65 -73
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +10 -19
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +22 -28
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +16 -24
- package/out/languageFeatures/codeLensResolve.d.ts +1 -1
- package/out/languageFeatures/codeLensResolve.js +8 -17
- package/out/languageFeatures/complete.d.ts +1 -1
- package/out/languageFeatures/complete.js +18 -33
- package/out/languageFeatures/completeResolve.d.ts +1 -1
- package/out/languageFeatures/completeResolve.js +6 -15
- package/out/languageFeatures/definition.d.ts +1 -1
- package/out/languageFeatures/definition.js +37 -45
- package/out/languageFeatures/documentHighlights.d.ts +1 -1
- package/out/languageFeatures/documentHighlights.js +32 -40
- package/out/languageFeatures/documentLinks.d.ts +1 -1
- package/out/languageFeatures/documentLinks.js +10 -17
- package/out/languageFeatures/documentSemanticTokens.d.ts +1 -1
- package/out/languageFeatures/documentSemanticTokens.js +6 -16
- package/out/languageFeatures/fileReferences.d.ts +1 -1
- package/out/languageFeatures/fileReferences.js +5 -14
- package/out/languageFeatures/fileRename.d.ts +1 -2
- package/out/languageFeatures/fileRename.js +6 -15
- package/out/languageFeatures/hover.d.ts +1 -1
- package/out/languageFeatures/hover.js +6 -10
- package/out/languageFeatures/inlayHints.d.ts +1 -1
- package/out/languageFeatures/inlayHints.js +13 -19
- package/out/languageFeatures/references.d.ts +1 -1
- package/out/languageFeatures/references.js +28 -39
- package/out/languageFeatures/rename.d.ts +1 -1
- package/out/languageFeatures/rename.js +55 -69
- package/out/languageFeatures/renamePrepare.d.ts +1 -1
- package/out/languageFeatures/renamePrepare.js +2 -3
- package/out/languageFeatures/signatureHelp.d.ts +1 -1
- package/out/languageFeatures/signatureHelp.js +8 -10
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +134 -152
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- package/out/languageFeatures/workspaceSymbols.js +3 -12
- package/out/transformer/completionItem.js +8 -3
- package/out/transformer/completionList.js +6 -3
- package/out/transformer/documentSymbol.js +8 -3
- package/out/transformer/foldingRanges.js +2 -3
- package/out/transformer/hover.js +5 -2
- package/out/transformer/locationLike.js +4 -1
- package/out/transformer/textEdit.js +20 -5
- package/out/transformer/workspaceSymbol.js +4 -1
- package/out/types.d.ts +3 -3
- package/out/utils/definePlugin.js +11 -23
- package/out/utils/featureWorkers.js +126 -146
- package/package.json +4 -4
|
@@ -1,12 +1,3 @@
|
|
|
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 = exports.updateRange = void 0;
|
|
12
3
|
const vscode = require("vscode-languageserver-protocol");
|
|
@@ -94,13 +85,12 @@ function register(context) {
|
|
|
94
85
|
syntax_rules: new Map(),
|
|
95
86
|
format_rules: new Map(),
|
|
96
87
|
};
|
|
97
|
-
return (uri,
|
|
98
|
-
var _a;
|
|
88
|
+
return async (uri, mode, token = vscode.CancellationToken.None, response) => {
|
|
99
89
|
const newDocument = context.getTextDocument(uri);
|
|
100
90
|
if (!newDocument) {
|
|
101
91
|
return [];
|
|
102
92
|
}
|
|
103
|
-
const lastResponse =
|
|
93
|
+
const lastResponse = lastResponses.get(uri) ?? lastResponses.set(uri, {
|
|
104
94
|
semantic: { errors: [] },
|
|
105
95
|
syntactic: { errors: [] },
|
|
106
96
|
semantic_rules: { errors: [] },
|
|
@@ -114,7 +104,7 @@ function register(context) {
|
|
|
114
104
|
for (const cache of Object.values(lastResponse)) {
|
|
115
105
|
const oldSnapshot = cache.snapshot;
|
|
116
106
|
const oldDocument = cache.document;
|
|
117
|
-
const change = oldSnapshot ? newSnapshot
|
|
107
|
+
const change = oldSnapshot ? newSnapshot?.getChangeRange(oldSnapshot) : undefined;
|
|
118
108
|
cache.snapshot = newSnapshot;
|
|
119
109
|
cache.document = newDocument;
|
|
120
110
|
if (!updateCacheRangeFailed && newDocument && oldSnapshot && oldDocument && newSnapshot && change) {
|
|
@@ -134,177 +124,169 @@ function register(context) {
|
|
|
134
124
|
}
|
|
135
125
|
}
|
|
136
126
|
if (mode === 'all' || mode === 'syntactic') {
|
|
137
|
-
|
|
127
|
+
await lintWorker('onFormat', cacheMaps.format_rules, lastResponse.format_rules);
|
|
138
128
|
doResponse();
|
|
139
|
-
|
|
129
|
+
await lintWorker('onSyntax', cacheMaps.syntax_rules, lastResponse.syntax_rules);
|
|
140
130
|
doResponse();
|
|
141
|
-
|
|
131
|
+
await worker('provideSyntacticDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
|
|
142
132
|
doResponse();
|
|
143
133
|
}
|
|
144
134
|
if (mode === 'all' || mode === 'semantic') {
|
|
145
|
-
|
|
135
|
+
await lintWorker('onSemantic', cacheMaps.semantic_rules, lastResponse.semantic_rules);
|
|
146
136
|
doResponse();
|
|
147
|
-
|
|
137
|
+
await worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
|
|
148
138
|
}
|
|
149
139
|
return collectErrors();
|
|
150
140
|
function doResponse() {
|
|
151
141
|
if (errorsUpdated && !updateCacheRangeFailed) {
|
|
152
|
-
response
|
|
142
|
+
response?.(collectErrors());
|
|
153
143
|
errorsUpdated = false;
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
146
|
function collectErrors() {
|
|
157
147
|
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
158
148
|
}
|
|
159
|
-
function lintWorker(api, cacheMap, cache) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
166
|
-
yield (0, common_1.sleep)(5); // wait for LSP event polling
|
|
167
|
-
lastCheckCancelAt = Date.now();
|
|
168
|
-
}
|
|
169
|
-
if (token.isCancellationRequested) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
149
|
+
async function lintWorker(api, cacheMap, cache) {
|
|
150
|
+
const result = await (0, featureWorkers_1.ruleWorker)(context, api, uri, file => api === 'onFormat' ? !!file.capabilities.documentFormatting : !!file.capabilities.diagnostic, async (ruleName, rule, ruleCtx) => {
|
|
151
|
+
if (token) {
|
|
152
|
+
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
153
|
+
await (0, common_1.sleep)(5); // wait for LSP event polling
|
|
154
|
+
lastCheckCancelAt = Date.now();
|
|
172
155
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const tsProjectVersion = (api === 'onSemantic') ? (_c = (_b = context.core.typescript.languageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
176
|
-
if (api === 'onSemantic') {
|
|
177
|
-
if (cache && cache.documentVersion === ruleCtx.document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
178
|
-
return cache.errors;
|
|
179
|
-
}
|
|
156
|
+
if (token.isCancellationRequested) {
|
|
157
|
+
return;
|
|
180
158
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
159
|
+
}
|
|
160
|
+
const pluginCache = cacheMap.get(ruleName) ?? cacheMap.set(ruleName, new Map()).get(ruleName);
|
|
161
|
+
const cache = pluginCache.get(ruleCtx.document.uri);
|
|
162
|
+
const tsProjectVersion = (api === 'onSemantic') ? context.core.typescript.languageServiceHost.getProjectVersion?.() : undefined;
|
|
163
|
+
if (api === 'onSemantic') {
|
|
164
|
+
if (cache && cache.documentVersion === ruleCtx.document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
165
|
+
return cache.errors;
|
|
185
166
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
console.warn('[volar/rules-api] report() error must be a Diagnostic.');
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
error.message || (error.message = 'No message.');
|
|
194
|
-
error.source || (error.source = 'rules');
|
|
195
|
-
error.code || (error.code = ruleCtx.ruleId);
|
|
196
|
-
const severity = (_b = (_a = context.config.lint) === null || _a === void 0 ? void 0 : _a.severities) === null || _b === void 0 ? void 0 : _b[ruleCtx.ruleId];
|
|
197
|
-
if (severity !== undefined) {
|
|
198
|
-
error.severity = severity;
|
|
199
|
-
}
|
|
200
|
-
reportResults.push([error, ...fixes]);
|
|
201
|
-
};
|
|
202
|
-
try {
|
|
203
|
-
yield ((_d = rule[api]) === null || _d === void 0 ? void 0 : _d.call(rule, ruleCtx));
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
if (cache && cache.documentVersion === ruleCtx.document.version) {
|
|
170
|
+
return cache.errors;
|
|
204
171
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
172
|
+
}
|
|
173
|
+
const reportResults = [];
|
|
174
|
+
ruleCtx.report = (error, ...fixes) => {
|
|
175
|
+
if (!vscode.Diagnostic.is(error)) {
|
|
176
|
+
console.warn('[volar/rules-api] report() error must be a Diagnostic.');
|
|
177
|
+
return;
|
|
208
178
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
error.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
documentUri: ruleCtx.document.uri,
|
|
225
|
-
};
|
|
226
|
-
});
|
|
227
|
-
errorsUpdated = true;
|
|
228
|
-
const errors = reportResults.map(reportResult => reportResult[0]);
|
|
229
|
-
pluginCache.set(ruleCtx.document.uri, {
|
|
230
|
-
documentVersion: ruleCtx.document.version,
|
|
231
|
-
errors,
|
|
232
|
-
tsProjectVersion,
|
|
233
|
-
});
|
|
234
|
-
return errors;
|
|
235
|
-
}), api === 'onFormat' ? transformFormatErrorRange : transformErrorRange, arr => arr.flat());
|
|
236
|
-
if (result) {
|
|
237
|
-
cache.errors = result;
|
|
238
|
-
cache.snapshot = newSnapshot;
|
|
179
|
+
error.message ||= 'No message.';
|
|
180
|
+
error.source ||= 'rules';
|
|
181
|
+
error.code ||= ruleCtx.ruleId;
|
|
182
|
+
const severity = context.config.lint?.severities?.[ruleCtx.ruleId];
|
|
183
|
+
if (severity !== undefined) {
|
|
184
|
+
error.severity = severity;
|
|
185
|
+
}
|
|
186
|
+
reportResults.push([error, ...fixes]);
|
|
187
|
+
};
|
|
188
|
+
try {
|
|
189
|
+
await rule[api]?.(ruleCtx);
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
console.warn(`[volar/rules-api] ${ruleName} ${api} error.`);
|
|
193
|
+
console.warn(err);
|
|
239
194
|
}
|
|
240
|
-
|
|
195
|
+
context.ruleFixes ??= {};
|
|
196
|
+
context.ruleFixes[ruleCtx.document.uri] ??= {};
|
|
197
|
+
context.ruleFixes[ruleCtx.document.uri][ruleCtx.ruleId] ??= {};
|
|
198
|
+
reportResults?.forEach(([error, ...fixes], index) => {
|
|
199
|
+
context.ruleFixes[ruleCtx.document.uri][ruleCtx.ruleId][index] = [error, fixes];
|
|
200
|
+
error.data = {
|
|
201
|
+
uri,
|
|
202
|
+
version: newDocument.version,
|
|
203
|
+
type: 'rule',
|
|
204
|
+
isFormat: api === 'onFormat',
|
|
205
|
+
pluginOrRuleId: ruleCtx.ruleId,
|
|
206
|
+
original: {
|
|
207
|
+
data: error.data,
|
|
208
|
+
},
|
|
209
|
+
ruleFixIndex: index,
|
|
210
|
+
documentUri: ruleCtx.document.uri,
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
errorsUpdated = true;
|
|
214
|
+
const errors = reportResults.map(reportResult => reportResult[0]);
|
|
215
|
+
pluginCache.set(ruleCtx.document.uri, {
|
|
216
|
+
documentVersion: ruleCtx.document.version,
|
|
217
|
+
errors,
|
|
218
|
+
tsProjectVersion,
|
|
219
|
+
});
|
|
220
|
+
return errors;
|
|
221
|
+
}, api === 'onFormat' ? transformFormatErrorRange : transformErrorRange, arr => arr.flat());
|
|
222
|
+
if (result) {
|
|
223
|
+
cache.errors = result;
|
|
224
|
+
cache.snapshot = newSnapshot;
|
|
225
|
+
}
|
|
241
226
|
}
|
|
242
|
-
function worker(api, cacheMap, cache) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
227
|
+
async function worker(api, cacheMap, cache) {
|
|
228
|
+
const result = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, true, function* (arg, _, file) {
|
|
229
|
+
if (file.capabilities.diagnostic) {
|
|
230
|
+
yield arg;
|
|
231
|
+
}
|
|
232
|
+
}, async (plugin, document) => {
|
|
233
|
+
if (token) {
|
|
234
|
+
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
235
|
+
await (0, common_1.sleep)(5); // waiting LSP event polling
|
|
236
|
+
lastCheckCancelAt = Date.now();
|
|
247
237
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (token) {
|
|
251
|
-
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
252
|
-
yield (0, common_1.sleep)(5); // waiting LSP event polling
|
|
253
|
-
lastCheckCancelAt = Date.now();
|
|
254
|
-
}
|
|
255
|
-
if (token.isCancellationRequested) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
238
|
+
if (token.isCancellationRequested) {
|
|
239
|
+
return;
|
|
258
240
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
241
|
+
}
|
|
242
|
+
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
243
|
+
const pluginCache = cacheMap.get(pluginId) ?? cacheMap.set(pluginId, new Map()).get(pluginId);
|
|
244
|
+
const cache = pluginCache.get(document.uri);
|
|
245
|
+
const tsProjectVersion = api === 'provideSemanticDiagnostics' ? context.core.typescript.languageServiceHost.getProjectVersion?.() : undefined;
|
|
246
|
+
if (api === 'provideSemanticDiagnostics') {
|
|
247
|
+
if (cache && cache.documentVersion === document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
248
|
+
return cache.errors;
|
|
267
249
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
if (cache && cache.documentVersion === document.version) {
|
|
253
|
+
return cache.errors;
|
|
272
254
|
}
|
|
273
|
-
const errors = yield ((_d = plugin[api]) === null || _d === void 0 ? void 0 : _d.call(plugin, document, token));
|
|
274
|
-
errors === null || errors === void 0 ? void 0 : errors.forEach(error => {
|
|
275
|
-
error.data = {
|
|
276
|
-
uri,
|
|
277
|
-
version: newDocument.version,
|
|
278
|
-
type: 'plugin',
|
|
279
|
-
pluginOrRuleId: pluginId,
|
|
280
|
-
isFormat: false,
|
|
281
|
-
original: {
|
|
282
|
-
data: error.data,
|
|
283
|
-
},
|
|
284
|
-
ruleFixIndex: 0,
|
|
285
|
-
documentUri: document.uri,
|
|
286
|
-
};
|
|
287
|
-
});
|
|
288
|
-
errorsUpdated = true;
|
|
289
|
-
pluginCache.set(document.uri, {
|
|
290
|
-
documentVersion: document.version,
|
|
291
|
-
errors,
|
|
292
|
-
tsProjectVersion,
|
|
293
|
-
});
|
|
294
|
-
return errors;
|
|
295
|
-
}), transformErrorRange, arr => dedupe.withDiagnostics(arr.flat()));
|
|
296
|
-
if (result) {
|
|
297
|
-
cache.errors = result;
|
|
298
|
-
cache.snapshot = newSnapshot;
|
|
299
255
|
}
|
|
300
|
-
|
|
256
|
+
const errors = await plugin[api]?.(document, token);
|
|
257
|
+
errors?.forEach(error => {
|
|
258
|
+
error.data = {
|
|
259
|
+
uri,
|
|
260
|
+
version: newDocument.version,
|
|
261
|
+
type: 'plugin',
|
|
262
|
+
pluginOrRuleId: pluginId,
|
|
263
|
+
isFormat: false,
|
|
264
|
+
original: {
|
|
265
|
+
data: error.data,
|
|
266
|
+
},
|
|
267
|
+
ruleFixIndex: 0,
|
|
268
|
+
documentUri: document.uri,
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
errorsUpdated = true;
|
|
272
|
+
pluginCache.set(document.uri, {
|
|
273
|
+
documentVersion: document.version,
|
|
274
|
+
errors,
|
|
275
|
+
tsProjectVersion,
|
|
276
|
+
});
|
|
277
|
+
return errors;
|
|
278
|
+
}, transformErrorRange, arr => dedupe.withDiagnostics(arr.flat()));
|
|
279
|
+
if (result) {
|
|
280
|
+
cache.errors = result;
|
|
281
|
+
cache.snapshot = newSnapshot;
|
|
282
|
+
}
|
|
301
283
|
}
|
|
302
|
-
}
|
|
284
|
+
};
|
|
303
285
|
function transformFormatErrorRange(errors, map) {
|
|
304
286
|
const result = [];
|
|
305
287
|
for (const error of errors) {
|
|
306
288
|
// clone it to avoid modify cache
|
|
307
|
-
let _error =
|
|
289
|
+
let _error = { ...error };
|
|
308
290
|
if (map) {
|
|
309
291
|
const range = map.toSourceRange(error.range);
|
|
310
292
|
if (!range) {
|
|
@@ -320,7 +302,7 @@ function register(context) {
|
|
|
320
302
|
const result = [];
|
|
321
303
|
for (const error of errors) {
|
|
322
304
|
// clone it to avoid modify cache
|
|
323
|
-
let _error =
|
|
305
|
+
let _error = { ...error };
|
|
324
306
|
if (map) {
|
|
325
307
|
const range = map.toSourceRange(error.range, data => !!data.diagnostic);
|
|
326
308
|
if (!range) {
|
|
@@ -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, token
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
3
|
const transformer = require("../transformer");
|
|
13
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
14
5
|
const common_1 = require("../utils/common");
|
|
15
6
|
function register(context) {
|
|
16
|
-
return (query, token) =>
|
|
7
|
+
return async (query, token = vscode.CancellationToken.None) => {
|
|
17
8
|
const symbolsList = [];
|
|
18
9
|
for (const plugin of Object.values(context.plugins)) {
|
|
19
10
|
if (token.isCancellationRequested)
|
|
20
11
|
break;
|
|
21
12
|
if (!plugin.provideWorkspaceSymbols)
|
|
22
13
|
continue;
|
|
23
|
-
const embeddedSymbols =
|
|
14
|
+
const embeddedSymbols = await plugin.provideWorkspaceSymbols(query, token);
|
|
24
15
|
if (!embeddedSymbols)
|
|
25
16
|
continue;
|
|
26
17
|
const symbols = embeddedSymbols.map(symbol => transformer.asWorkspaceSymbol(symbol, loc => {
|
|
@@ -39,7 +30,7 @@ function register(context) {
|
|
|
39
30
|
symbolsList.push(symbols);
|
|
40
31
|
}
|
|
41
32
|
return symbolsList.flat();
|
|
42
|
-
}
|
|
33
|
+
};
|
|
43
34
|
}
|
|
44
35
|
exports.register = register;
|
|
45
36
|
//# sourceMappingURL=workspaceSymbols.js.map
|
|
@@ -3,10 +3,15 @@ exports.transform = void 0;
|
|
|
3
3
|
const common_1 = require("../utils/common");
|
|
4
4
|
const textEdit_1 = require("./textEdit");
|
|
5
5
|
function transform(item, getOtherRange, document) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
return {
|
|
7
|
+
...item,
|
|
8
|
+
additionalTextEdits: item.additionalTextEdits
|
|
9
|
+
?.map(edit => (0, textEdit_1.transform)(edit, getOtherRange, document))
|
|
10
|
+
.filter(common_1.notEmpty),
|
|
11
|
+
textEdit: item.textEdit
|
|
8
12
|
? (0, textEdit_1.transform)(item.textEdit, getOtherRange, document)
|
|
9
|
-
: undefined
|
|
13
|
+
: undefined,
|
|
14
|
+
};
|
|
10
15
|
}
|
|
11
16
|
exports.transform = transform;
|
|
12
17
|
//# sourceMappingURL=completionItem.js.map
|
|
@@ -4,17 +4,20 @@ const completionItem_1 = require("./completionItem");
|
|
|
4
4
|
function transform(completionList, getOtherRange, document, onItem) {
|
|
5
5
|
return {
|
|
6
6
|
isIncomplete: completionList.isIncomplete,
|
|
7
|
-
itemDefaults: completionList.itemDefaults ?
|
|
7
|
+
itemDefaults: completionList.itemDefaults ? {
|
|
8
|
+
...completionList.itemDefaults,
|
|
9
|
+
editRange: completionList.itemDefaults.editRange
|
|
8
10
|
? 'replace' in completionList.itemDefaults.editRange
|
|
9
11
|
? {
|
|
10
12
|
insert: getOtherRange(completionList.itemDefaults.editRange.insert),
|
|
11
13
|
replace: getOtherRange(completionList.itemDefaults.editRange.replace),
|
|
12
14
|
}
|
|
13
15
|
: getOtherRange(completionList.itemDefaults.editRange)
|
|
14
|
-
: undefined
|
|
16
|
+
: undefined,
|
|
17
|
+
} : undefined,
|
|
15
18
|
items: completionList.items.map(item => {
|
|
16
19
|
const newItem = (0, completionItem_1.transform)(item, getOtherRange, document);
|
|
17
|
-
onItem
|
|
20
|
+
onItem?.(newItem, item);
|
|
18
21
|
return newItem;
|
|
19
22
|
}),
|
|
20
23
|
};
|
|
@@ -2,7 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.transform = void 0;
|
|
3
3
|
const common_1 = require("../utils/common");
|
|
4
4
|
function transform(symbol, getOtherRange) {
|
|
5
|
-
var _a;
|
|
6
5
|
const range = getOtherRange(symbol.range);
|
|
7
6
|
if (!range) {
|
|
8
7
|
return;
|
|
@@ -11,8 +10,14 @@ function transform(symbol, getOtherRange) {
|
|
|
11
10
|
if (!selectionRange) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
|
-
return
|
|
15
|
-
|
|
13
|
+
return {
|
|
14
|
+
...symbol,
|
|
15
|
+
range,
|
|
16
|
+
selectionRange,
|
|
17
|
+
children: symbol.children
|
|
18
|
+
?.map(child => transform(child, getOtherRange))
|
|
19
|
+
.filter(common_1.notEmpty),
|
|
20
|
+
};
|
|
16
21
|
}
|
|
17
22
|
exports.transform = transform;
|
|
18
23
|
//# sourceMappingURL=documentSymbol.js.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.transform = void 0;
|
|
3
3
|
function transform(ranges, getOtherRange) {
|
|
4
|
-
var _a, _b;
|
|
5
4
|
const result = [];
|
|
6
5
|
for (const range of ranges) {
|
|
7
6
|
const otherRange = getOtherRange({
|
|
8
|
-
start: { line: range.startLine, character:
|
|
9
|
-
end: { line: range.endLine, character:
|
|
7
|
+
start: { line: range.startLine, character: range.startCharacter ?? 0 },
|
|
8
|
+
end: { line: range.endLine, character: range.endCharacter ?? 0 },
|
|
10
9
|
});
|
|
11
10
|
if (otherRange) {
|
|
12
11
|
range.startLine = otherRange.start.line;
|
package/out/transformer/hover.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.transform = void 0;
|
|
3
3
|
function transform(hover, getOtherRange) {
|
|
4
|
-
if (!
|
|
4
|
+
if (!hover?.range) {
|
|
5
5
|
return hover;
|
|
6
6
|
}
|
|
7
7
|
const range = getOtherRange(hover.range);
|
|
8
8
|
if (!range)
|
|
9
9
|
return;
|
|
10
|
-
return
|
|
10
|
+
return {
|
|
11
|
+
...hover,
|
|
12
|
+
range,
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
15
|
exports.transform = transform;
|
|
13
16
|
//# sourceMappingURL=hover.js.map
|
|
@@ -4,7 +4,10 @@ function transform(location, getOtherRange) {
|
|
|
4
4
|
const range = getOtherRange(location.range);
|
|
5
5
|
if (!range)
|
|
6
6
|
return;
|
|
7
|
-
return
|
|
7
|
+
return {
|
|
8
|
+
...location,
|
|
9
|
+
range,
|
|
10
|
+
};
|
|
8
11
|
}
|
|
9
12
|
exports.transform = transform;
|
|
10
13
|
//# sourceMappingURL=locationLike.js.map
|
|
@@ -5,25 +5,40 @@ function transform(textEdit, getOtherRange, document) {
|
|
|
5
5
|
if (vscode.TextEdit.is(textEdit)) {
|
|
6
6
|
let range = getOtherRange(textEdit.range);
|
|
7
7
|
if (range) {
|
|
8
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...textEdit,
|
|
10
|
+
range,
|
|
11
|
+
};
|
|
9
12
|
}
|
|
10
13
|
;
|
|
11
14
|
const cover = tryRecover(getOtherRange, textEdit.range, textEdit.newText, document);
|
|
12
15
|
if (cover) {
|
|
13
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
...textEdit,
|
|
18
|
+
range: cover.range,
|
|
19
|
+
newText: cover.newText,
|
|
20
|
+
};
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
else if (vscode.InsertReplaceEdit.is(textEdit)) {
|
|
17
24
|
const insert = getOtherRange(textEdit.insert);
|
|
18
25
|
const replace = insert ? getOtherRange(textEdit.replace) : undefined;
|
|
19
26
|
if (insert && replace) {
|
|
20
|
-
return
|
|
21
|
-
|
|
27
|
+
return {
|
|
28
|
+
...textEdit,
|
|
29
|
+
insert,
|
|
30
|
+
replace,
|
|
31
|
+
};
|
|
22
32
|
}
|
|
23
33
|
const recoverInsert = tryRecover(getOtherRange, textEdit.insert, textEdit.newText, document);
|
|
24
34
|
const recoverReplace = recoverInsert ? tryRecover(getOtherRange, textEdit.replace, textEdit.newText, document) : undefined;
|
|
25
35
|
if (recoverInsert && recoverReplace && recoverInsert.newText === recoverReplace.newText) {
|
|
26
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
...textEdit,
|
|
38
|
+
insert: recoverInsert.range,
|
|
39
|
+
replace: recoverReplace.range,
|
|
40
|
+
newText: recoverInsert.newText,
|
|
41
|
+
};
|
|
27
42
|
}
|
|
28
43
|
}
|
|
29
44
|
}
|
|
@@ -9,7 +9,10 @@ function transform(symbol, getOtherLocation) {
|
|
|
9
9
|
if (!loc) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
...symbol,
|
|
14
|
+
location: loc,
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
exports.transform = transform;
|
|
15
18
|
//# sourceMappingURL=workspaceSymbol.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -93,9 +93,9 @@ export interface LanguageServicePluginInstance {
|
|
|
93
93
|
provideReferences?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
94
94
|
provideSelectionRanges?(document: TextDocument, positions: vscode.Position[], token: vscode.CancellationToken): NullableResult<vscode.SelectionRange[]>;
|
|
95
95
|
provideInlayHints?(document: TextDocument, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.InlayHint[]>;
|
|
96
|
-
provideCallHierarchyItems(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.CallHierarchyItem[]>;
|
|
97
|
-
provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyIncomingCall[]>;
|
|
98
|
-
provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyOutgoingCall[]>;
|
|
96
|
+
provideCallHierarchyItems?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.CallHierarchyItem[]>;
|
|
97
|
+
provideCallHierarchyIncomingCalls?(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyIncomingCall[]>;
|
|
98
|
+
provideCallHierarchyOutgoingCalls?(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Result<vscode.CallHierarchyOutgoingCall[]>;
|
|
99
99
|
provideDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken): NullableResult<SemanticToken[]>;
|
|
100
100
|
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
101
101
|
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
@@ -1,31 +1,19 @@
|
|
|
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.visitEmbedded = void 0;
|
|
12
|
-
function visitEmbedded(documents, current, cb, rootFile = current) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!(yield visitEmbedded(documents, embedded, cb, rootFile))) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
3
|
+
async function visitEmbedded(documents, current, cb, rootFile = current) {
|
|
4
|
+
for (const embedded of current.embeddedFiles) {
|
|
5
|
+
if (!await visitEmbedded(documents, embedded, cb, rootFile)) {
|
|
6
|
+
return false;
|
|
19
7
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
}
|
|
9
|
+
for (const [_, map] of documents.getMapsByVirtualFileName(current.fileName)) {
|
|
10
|
+
if (documents.getSourceByUri(map.sourceFileDocument.uri)?.root === rootFile) {
|
|
11
|
+
if (!await cb(current, map)) {
|
|
12
|
+
return false;
|
|
25
13
|
}
|
|
26
14
|
}
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
29
17
|
}
|
|
30
18
|
exports.visitEmbedded = visitEmbedded;
|
|
31
19
|
//# sourceMappingURL=definePlugin.js.map
|