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