@volar/language-service 1.0.22 → 1.1.0-1.2.0-alpha.1.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 -11
- package/out/baseLanguageService.js +34 -24
- package/out/documentFeatures/documentSymbols.js +3 -5
- package/out/documentFeatures/foldingRanges.js +2 -2
- package/out/documentFeatures/format.js +7 -7
- package/out/documentFeatures/selectionRanges.js +2 -2
- package/out/documents.d.ts +3 -3
- package/out/documents.js +17 -24
- package/out/index.d.ts +1 -0
- package/out/index.js +2 -1
- package/out/languageFeatures/callHierarchy.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.js +18 -21
- package/out/languageFeatures/codeActionResolve.js +4 -6
- package/out/languageFeatures/codeActions.d.ts +2 -2
- package/out/languageFeatures/codeActions.js +14 -7
- package/out/languageFeatures/codeLens.d.ts +4 -4
- package/out/languageFeatures/codeLens.js +16 -10
- package/out/languageFeatures/codeLensResolve.js +10 -4
- package/out/languageFeatures/complete.d.ts +2 -2
- package/out/languageFeatures/complete.js +34 -35
- package/out/languageFeatures/completeResolve.js +5 -7
- package/out/languageFeatures/definition.js +1 -1
- package/out/languageFeatures/executeCommand.d.ts +1 -1
- package/out/languageFeatures/executeCommand.js +1 -1
- package/out/languageFeatures/fileReferences.js +1 -1
- package/out/languageFeatures/fileRename.js +4 -3
- package/out/languageFeatures/inlayHints.js +2 -2
- package/out/languageFeatures/references.js +1 -1
- package/out/languageFeatures/rename.js +5 -5
- package/out/languageFeatures/renamePrepare.js +1 -6
- package/out/languageFeatures/validation copy.d.ts +7 -0
- package/out/languageFeatures/validation copy.js +234 -0
- package/out/languageFeatures/validation.d.ts +6 -0
- package/out/languageFeatures/validation.js +118 -41
- package/out/languageFeatures/workspaceSymbols.js +4 -4
- package/out/transformer/completionItem.d.ts +2 -0
- package/out/transformer/completionItem.js +12 -0
- package/out/transformer/completionList.d.ts +2 -0
- package/out/transformer/completionList.js +23 -0
- package/out/transformer/foldingRanges.d.ts +2 -0
- package/out/transformer/foldingRanges.js +24 -0
- package/out/transformer/hover.d.ts +2 -0
- package/out/transformer/hover.js +13 -0
- package/out/transformer/index.d.ts +11 -0
- package/out/transformer/index.js +25 -0
- package/out/transformer/locationLike.d.ts +4 -0
- package/out/transformer/locationLike.js +10 -0
- package/out/transformer/locationsLike.d.ts +4 -0
- package/out/transformer/locationsLike.js +11 -0
- package/out/transformer/selectionRange.d.ts +2 -0
- package/out/transformer/selectionRange.js +14 -0
- package/out/transformer/selectionRanges.d.ts +2 -0
- package/out/transformer/selectionRanges.js +11 -0
- package/out/transformer/symbolInformation.d.ts +2 -0
- package/out/transformer/symbolInformation.js +10 -0
- package/out/transformer/symbolInformations.d.ts +2 -0
- package/out/transformer/symbolInformations.js +11 -0
- package/out/transformer/textEdit.d.ts +2 -0
- package/out/transformer/textEdit.js +57 -0
- package/out/types.d.ts +45 -9
- package/out/types.js +0 -1
- package/out/utils/common.d.ts +0 -2
- package/out/utils/common.js +1 -28
- package/out/utils/definePlugin.js +2 -1
- package/out/utils/featureWorkers.d.ts +2 -1
- package/out/utils/featureWorkers.js +89 -6
- package/package.json +7 -8
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = exports.updateRange = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
|
-
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
14
13
|
const dedupe = require("../utils/dedupe");
|
|
15
14
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
16
15
|
function updateRange(range, change) {
|
|
@@ -86,32 +85,39 @@ function updatePosition(position, change, isEnd) {
|
|
|
86
85
|
return false;
|
|
87
86
|
}
|
|
88
87
|
function register(context) {
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const lastResponses = new Map();
|
|
89
|
+
const cacheMaps = {
|
|
90
|
+
semantic: new Map(),
|
|
91
|
+
declaration: new Map(),
|
|
92
|
+
syntactic: new Map(),
|
|
93
|
+
suggestion: new Map(),
|
|
94
|
+
semantic_rules: new Map(),
|
|
95
|
+
syntactic_rules: new Map(),
|
|
96
|
+
formatic_rules: new Map(),
|
|
97
|
+
};
|
|
95
98
|
return (uri, token, response) => __awaiter(this, void 0, void 0, function* () {
|
|
96
99
|
var _a;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
const lastResponse = (_a = lastResponses.get(uri)) !== null && _a !== void 0 ? _a : lastResponses.set(uri, {
|
|
101
|
+
semantic: { errors: [] },
|
|
102
|
+
declaration: { errors: [] },
|
|
103
|
+
suggestion: { errors: [] },
|
|
104
|
+
syntactic: { errors: [] },
|
|
105
|
+
semantic_rules: { errors: [] },
|
|
106
|
+
syntactic_rules: { errors: [] },
|
|
107
|
+
formatic_rules: { errors: [] },
|
|
103
108
|
}).get(uri);
|
|
104
|
-
const newSnapshot = context.host.getScriptSnapshot(shared.
|
|
105
|
-
const newDocument =
|
|
106
|
-
let
|
|
109
|
+
const newSnapshot = context.host.getScriptSnapshot(shared.uriToFileName(uri));
|
|
110
|
+
const newDocument = context.getTextDocument(uri);
|
|
111
|
+
let updateCacheRangeFailed = false;
|
|
107
112
|
let errorsUpdated = false;
|
|
108
113
|
let lastCheckCancelAt = 0;
|
|
109
|
-
for (const
|
|
110
|
-
const oldSnapshot =
|
|
114
|
+
for (const cache of Object.values(lastResponse)) {
|
|
115
|
+
const oldSnapshot = cache.snapshot;
|
|
116
|
+
const oldDocument = cache.document;
|
|
111
117
|
const change = oldSnapshot ? newSnapshot === null || newSnapshot === void 0 ? void 0 : newSnapshot.getChangeRange(oldSnapshot) : undefined;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
cache.snapshot = newSnapshot;
|
|
119
|
+
cache.document = newDocument;
|
|
120
|
+
if (!updateCacheRangeFailed && newDocument && oldSnapshot && oldDocument && newSnapshot && change) {
|
|
115
121
|
const changeRange = {
|
|
116
122
|
range: {
|
|
117
123
|
start: oldDocument.positionAt(change.span.start),
|
|
@@ -119,32 +125,94 @@ function register(context) {
|
|
|
119
125
|
},
|
|
120
126
|
newEnd: newDocument.positionAt(change.span.start + change.newLength),
|
|
121
127
|
};
|
|
122
|
-
for (const error of
|
|
128
|
+
for (const error of cache.errors) {
|
|
123
129
|
if (!updateRange(error.range, changeRange)) {
|
|
124
|
-
|
|
130
|
+
updateCacheRangeFailed = true;
|
|
125
131
|
break;
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
|
-
yield
|
|
136
|
+
yield lintWorker('onFormat', cacheMaps.formatic_rules, lastResponse.formatic_rules);
|
|
131
137
|
doResponse();
|
|
132
|
-
yield
|
|
138
|
+
yield lintWorker('onSyntax', cacheMaps.syntactic_rules, lastResponse.syntactic_rules);
|
|
133
139
|
doResponse();
|
|
134
|
-
yield worker('
|
|
140
|
+
yield worker('onSyntactic', cacheMaps.syntactic, lastResponse.syntactic);
|
|
135
141
|
doResponse();
|
|
136
|
-
yield worker('
|
|
137
|
-
|
|
142
|
+
yield worker('onSuggestion', cacheMaps.suggestion, lastResponse.suggestion);
|
|
143
|
+
doResponse();
|
|
144
|
+
yield lintWorker('onSemantic', cacheMaps.semantic_rules, lastResponse.semantic_rules);
|
|
145
|
+
doResponse();
|
|
146
|
+
yield worker('onSemantic', cacheMaps.semantic, lastResponse.semantic);
|
|
147
|
+
doResponse();
|
|
148
|
+
yield worker('onDeclaration', cacheMaps.declaration, lastResponse.declaration);
|
|
149
|
+
return collectErrors();
|
|
138
150
|
function doResponse() {
|
|
139
|
-
if (errorsUpdated && !
|
|
140
|
-
response === null || response === void 0 ? void 0 : response(
|
|
151
|
+
if (errorsUpdated && !updateCacheRangeFailed) {
|
|
152
|
+
response === null || response === void 0 ? void 0 : response(collectErrors());
|
|
141
153
|
errorsUpdated = false;
|
|
142
154
|
}
|
|
143
155
|
}
|
|
144
|
-
function
|
|
145
|
-
return Object.values(
|
|
156
|
+
function collectErrors() {
|
|
157
|
+
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
146
158
|
}
|
|
147
|
-
function
|
|
159
|
+
function lintWorker(api, cacheMap, cache) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
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* () {
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
if (token) {
|
|
164
|
+
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
165
|
+
yield shared.sleep(5); // wait for LSP event polling
|
|
166
|
+
lastCheckCancelAt = Date.now();
|
|
167
|
+
}
|
|
168
|
+
if (token.isCancellationRequested) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const pluginCache = (_a = cacheMap.get(ruleName)) !== null && _a !== void 0 ? _a : cacheMap.set(ruleName, new Map()).get(ruleName);
|
|
173
|
+
const cache = pluginCache.get(ruleCtx.document.uri);
|
|
174
|
+
const tsProjectVersion = (api === 'onSemantic') ? (_c = (_b = context.core.typescript.languageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
175
|
+
if (api === 'onSemantic') {
|
|
176
|
+
if (cache && cache.documentVersion === ruleCtx.document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
177
|
+
return cache.errors;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (cache && cache.documentVersion === ruleCtx.document.version) {
|
|
182
|
+
return cache.errors;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const reportResults = [];
|
|
186
|
+
ruleCtx.report = (error, ...fixes) => {
|
|
187
|
+
error.source || (error.source = 'rules');
|
|
188
|
+
error.code || (error.code = ruleCtx.ruleId);
|
|
189
|
+
reportResults.push([error, ...fixes]);
|
|
190
|
+
};
|
|
191
|
+
yield ((_d = rule[api]) === null || _d === void 0 ? void 0 : _d.call(rule, ruleCtx));
|
|
192
|
+
const errors = reportResults.map(reportResult => reportResult[0]);
|
|
193
|
+
errors === null || errors === void 0 ? void 0 : errors.forEach(error => {
|
|
194
|
+
error.data = {
|
|
195
|
+
uri,
|
|
196
|
+
type: 'rule',
|
|
197
|
+
pluginOrRuleId: ruleCtx.ruleId,
|
|
198
|
+
originalData: error.data,
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
errorsUpdated = true;
|
|
202
|
+
pluginCache.set(ruleCtx.document.uri, {
|
|
203
|
+
documentVersion: ruleCtx.document.version,
|
|
204
|
+
errors,
|
|
205
|
+
tsProjectVersion,
|
|
206
|
+
});
|
|
207
|
+
return errors;
|
|
208
|
+
}), transformErrorRange, arr => arr.flat());
|
|
209
|
+
if (result) {
|
|
210
|
+
cache.errors = result;
|
|
211
|
+
cache.snapshot = newSnapshot;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function worker(api, cacheMap, cache) {
|
|
148
216
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
217
|
const result = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, true, function* (arg, _, file) {
|
|
150
218
|
if (file.capabilities.diagnostic) {
|
|
@@ -157,14 +225,15 @@ function register(context) {
|
|
|
157
225
|
yield shared.sleep(5); // wait for LSP event polling
|
|
158
226
|
lastCheckCancelAt = Date.now();
|
|
159
227
|
}
|
|
160
|
-
if (token.isCancellationRequested)
|
|
228
|
+
if (token.isCancellationRequested) {
|
|
161
229
|
return;
|
|
230
|
+
}
|
|
162
231
|
}
|
|
163
|
-
const pluginId = context.plugins.
|
|
232
|
+
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
164
233
|
const pluginCache = (_a = cacheMap.get(pluginId)) !== null && _a !== void 0 ? _a : cacheMap.set(pluginId, new Map()).get(pluginId);
|
|
165
234
|
const cache = pluginCache.get(document.uri);
|
|
166
|
-
const tsProjectVersion = (
|
|
167
|
-
if (
|
|
235
|
+
const tsProjectVersion = (api === 'onDeclaration' || api === 'onSemantic') ? (_c = (_b = context.core.typescript.languageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
236
|
+
if (api === 'onDeclaration' || api === 'onSemantic') {
|
|
168
237
|
if (cache && cache.documentVersion === document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
169
238
|
return cache.errors;
|
|
170
239
|
}
|
|
@@ -174,7 +243,15 @@ function register(context) {
|
|
|
174
243
|
return cache.errors;
|
|
175
244
|
}
|
|
176
245
|
}
|
|
177
|
-
const errors = yield ((_e = (_d = plugin.validation) === null || _d === void 0 ? void 0 : _d[
|
|
246
|
+
const errors = yield ((_e = (_d = plugin.validation) === null || _d === void 0 ? void 0 : _d[api]) === null || _e === void 0 ? void 0 : _e.call(_d, document));
|
|
247
|
+
errors === null || errors === void 0 ? void 0 : errors.forEach(error => {
|
|
248
|
+
error.data = {
|
|
249
|
+
uri,
|
|
250
|
+
type: 'plugin',
|
|
251
|
+
pluginOrRuleId: pluginId,
|
|
252
|
+
originalData: error.data,
|
|
253
|
+
};
|
|
254
|
+
});
|
|
178
255
|
errorsUpdated = true;
|
|
179
256
|
pluginCache.set(document.uri, {
|
|
180
257
|
documentVersion: document.version,
|
|
@@ -182,7 +259,7 @@ function register(context) {
|
|
|
182
259
|
tsProjectVersion,
|
|
183
260
|
});
|
|
184
261
|
return errors;
|
|
185
|
-
}),
|
|
262
|
+
}), transformErrorRange, arr => dedupe.withDiagnostics(arr.flat()));
|
|
186
263
|
if (result) {
|
|
187
264
|
cache.errors = result;
|
|
188
265
|
cache.snapshot = newSnapshot;
|
|
@@ -190,7 +267,7 @@ function register(context) {
|
|
|
190
267
|
});
|
|
191
268
|
}
|
|
192
269
|
});
|
|
193
|
-
function transformErrorRange(
|
|
270
|
+
function transformErrorRange(errors, map) {
|
|
194
271
|
const result = [];
|
|
195
272
|
for (const error of errors) {
|
|
196
273
|
// clone it to avoid modify cache
|
|
@@ -205,7 +282,7 @@ function register(context) {
|
|
|
205
282
|
if (_error.relatedInformation) {
|
|
206
283
|
const relatedInfos = [];
|
|
207
284
|
for (const info of _error.relatedInformation) {
|
|
208
|
-
if (context.documents.
|
|
285
|
+
if (context.documents.hasVirtualFileByUri(info.location.uri)) {
|
|
209
286
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(info.location.uri)) {
|
|
210
287
|
const range = map.toSourceRange(info.location.range, data => !!data.diagnostic);
|
|
211
288
|
if (range) {
|
|
@@ -9,19 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
|
-
const
|
|
12
|
+
const transformer = require("../transformer");
|
|
13
13
|
const vscode = require("vscode-languageserver-protocol");
|
|
14
14
|
function register(context) {
|
|
15
15
|
return (query) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
const symbolsList = [];
|
|
17
|
-
for (const plugin of context.plugins) {
|
|
17
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
18
18
|
if (!plugin.findWorkspaceSymbols)
|
|
19
19
|
continue;
|
|
20
20
|
const embeddedSymbols = yield plugin.findWorkspaceSymbols(query);
|
|
21
21
|
if (!embeddedSymbols)
|
|
22
22
|
continue;
|
|
23
|
-
const symbols =
|
|
24
|
-
if (context.documents.
|
|
23
|
+
const symbols = transformer.asSymbolInformations(embeddedSymbols, loc => {
|
|
24
|
+
if (context.documents.hasVirtualFileByUri(loc.uri)) {
|
|
25
25
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(loc.uri)) {
|
|
26
26
|
const range = map.toSourceRange(loc.range);
|
|
27
27
|
if (range) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const textEdit_1 = require("./textEdit");
|
|
4
|
+
const shared = require("@volar/shared");
|
|
5
|
+
function transform(item, getOtherRange, document) {
|
|
6
|
+
var _a;
|
|
7
|
+
return Object.assign(Object.assign({}, item), { additionalTextEdits: (_a = item.additionalTextEdits) === null || _a === void 0 ? void 0 : _a.map(edit => (0, textEdit_1.transform)(edit, getOtherRange, document)).filter(shared.notEmpty), textEdit: item.textEdit
|
|
8
|
+
? (0, textEdit_1.transform)(item.textEdit, getOtherRange, document)
|
|
9
|
+
: undefined });
|
|
10
|
+
}
|
|
11
|
+
exports.transform = transform;
|
|
12
|
+
//# sourceMappingURL=completionItem.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
export declare function transform<T extends vscode.CompletionList>(completionList: T, getOtherRange: (range: vscode.Range) => vscode.Range | undefined, document: vscode.TextDocument, onItem?: (newItem: vscode.CompletionItem, oldItem: vscode.CompletionItem) => void): T;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const completionItem_1 = require("./completionItem");
|
|
4
|
+
function transform(completionList, getOtherRange, document, onItem) {
|
|
5
|
+
return {
|
|
6
|
+
isIncomplete: completionList.isIncomplete,
|
|
7
|
+
itemDefaults: completionList.itemDefaults ? Object.assign(Object.assign({}, completionList.itemDefaults), { editRange: completionList.itemDefaults.editRange
|
|
8
|
+
? 'replace' in completionList.itemDefaults.editRange
|
|
9
|
+
? {
|
|
10
|
+
insert: getOtherRange(completionList.itemDefaults.editRange.insert),
|
|
11
|
+
replace: getOtherRange(completionList.itemDefaults.editRange.replace),
|
|
12
|
+
}
|
|
13
|
+
: getOtherRange(completionList.itemDefaults.editRange)
|
|
14
|
+
: undefined }) : undefined,
|
|
15
|
+
items: completionList.items.map(item => {
|
|
16
|
+
const newItem = (0, completionItem_1.transform)(item, getOtherRange, document);
|
|
17
|
+
onItem === null || onItem === void 0 ? void 0 : onItem(newItem, item);
|
|
18
|
+
return newItem;
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.transform = transform;
|
|
23
|
+
//# sourceMappingURL=completionList.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
function transform(ranges, getOtherRange) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const range of ranges) {
|
|
7
|
+
const vueRange = getOtherRange({
|
|
8
|
+
start: { line: range.startLine, character: (_a = range.startCharacter) !== null && _a !== void 0 ? _a : 0 },
|
|
9
|
+
end: { line: range.endLine, character: (_b = range.endCharacter) !== null && _b !== void 0 ? _b : 0 },
|
|
10
|
+
});
|
|
11
|
+
if (vueRange) {
|
|
12
|
+
range.startLine = vueRange.start.line;
|
|
13
|
+
range.endLine = vueRange.end.line;
|
|
14
|
+
if (range.startCharacter !== undefined)
|
|
15
|
+
range.startCharacter = vueRange.start.character;
|
|
16
|
+
if (range.endCharacter !== undefined)
|
|
17
|
+
range.endCharacter = vueRange.end.character;
|
|
18
|
+
result.push(range);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
exports.transform = transform;
|
|
24
|
+
//# sourceMappingURL=foldingRanges.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
function transform(hover, getOtherRange) {
|
|
4
|
+
if (!(hover === null || hover === void 0 ? void 0 : hover.range)) {
|
|
5
|
+
return hover;
|
|
6
|
+
}
|
|
7
|
+
const range = getOtherRange(hover.range);
|
|
8
|
+
if (!range)
|
|
9
|
+
return;
|
|
10
|
+
return Object.assign(Object.assign({}, hover), { range });
|
|
11
|
+
}
|
|
12
|
+
exports.transform = transform;
|
|
13
|
+
//# sourceMappingURL=hover.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { transform as asCompletionItem } from './completionItem';
|
|
2
|
+
export { transform as asCompletionList } from './completionList';
|
|
3
|
+
export { transform as asFoldingRanges } from './foldingRanges';
|
|
4
|
+
export { transform as asHover } from './hover';
|
|
5
|
+
export { transform as asLocation } from './locationLike';
|
|
6
|
+
export { transform as asLocations } from './locationsLike';
|
|
7
|
+
export { transform as asSelectionRange } from './selectionRange';
|
|
8
|
+
export { transform as asSelectionRanges } from './selectionRanges';
|
|
9
|
+
export { transform as asSymbolInformation } from './symbolInformation';
|
|
10
|
+
export { transform as asSymbolInformations } from './symbolInformations';
|
|
11
|
+
export { transform as asTextEdit } from './textEdit';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.asTextEdit = exports.asSymbolInformations = exports.asSymbolInformation = exports.asSelectionRanges = exports.asSelectionRange = exports.asLocations = exports.asLocation = exports.asHover = exports.asFoldingRanges = exports.asCompletionList = exports.asCompletionItem = void 0;
|
|
3
|
+
var completionItem_1 = require("./completionItem");
|
|
4
|
+
Object.defineProperty(exports, "asCompletionItem", { enumerable: true, get: function () { return completionItem_1.transform; } });
|
|
5
|
+
var completionList_1 = require("./completionList");
|
|
6
|
+
Object.defineProperty(exports, "asCompletionList", { enumerable: true, get: function () { return completionList_1.transform; } });
|
|
7
|
+
var foldingRanges_1 = require("./foldingRanges");
|
|
8
|
+
Object.defineProperty(exports, "asFoldingRanges", { enumerable: true, get: function () { return foldingRanges_1.transform; } });
|
|
9
|
+
var hover_1 = require("./hover");
|
|
10
|
+
Object.defineProperty(exports, "asHover", { enumerable: true, get: function () { return hover_1.transform; } });
|
|
11
|
+
var locationLike_1 = require("./locationLike");
|
|
12
|
+
Object.defineProperty(exports, "asLocation", { enumerable: true, get: function () { return locationLike_1.transform; } });
|
|
13
|
+
var locationsLike_1 = require("./locationsLike");
|
|
14
|
+
Object.defineProperty(exports, "asLocations", { enumerable: true, get: function () { return locationsLike_1.transform; } });
|
|
15
|
+
var selectionRange_1 = require("./selectionRange");
|
|
16
|
+
Object.defineProperty(exports, "asSelectionRange", { enumerable: true, get: function () { return selectionRange_1.transform; } });
|
|
17
|
+
var selectionRanges_1 = require("./selectionRanges");
|
|
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
|
+
var textEdit_1 = require("./textEdit");
|
|
24
|
+
Object.defineProperty(exports, "asTextEdit", { enumerable: true, get: function () { return textEdit_1.transform; } });
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
function transform(location, getOtherRange) {
|
|
4
|
+
const range = getOtherRange(location.range);
|
|
5
|
+
if (!range)
|
|
6
|
+
return;
|
|
7
|
+
return Object.assign(Object.assign({}, location), { range });
|
|
8
|
+
}
|
|
9
|
+
exports.transform = transform;
|
|
10
|
+
//# sourceMappingURL=locationLike.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const shared = require("@volar/shared");
|
|
4
|
+
const locationLike_1 = require("./locationLike");
|
|
5
|
+
function transform(locations, getOtherRange) {
|
|
6
|
+
return locations
|
|
7
|
+
.map(location => (0, locationLike_1.transform)(location, getOtherRange))
|
|
8
|
+
.filter(shared.notEmpty);
|
|
9
|
+
}
|
|
10
|
+
exports.transform = transform;
|
|
11
|
+
//# sourceMappingURL=locationsLike.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
function transform(location, getOtherRange) {
|
|
4
|
+
const range = getOtherRange(location.range);
|
|
5
|
+
if (!range)
|
|
6
|
+
return;
|
|
7
|
+
const parent = location.parent ? transform(location.parent, getOtherRange) : undefined;
|
|
8
|
+
return {
|
|
9
|
+
range,
|
|
10
|
+
parent,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.transform = transform;
|
|
14
|
+
//# sourceMappingURL=selectionRange.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const shared = require("@volar/shared");
|
|
4
|
+
const selectionRange_1 = require("./selectionRange");
|
|
5
|
+
function transform(locations, getOtherRange) {
|
|
6
|
+
return locations
|
|
7
|
+
.map(location => (0, selectionRange_1.transform)(location, getOtherRange))
|
|
8
|
+
.filter(shared.notEmpty);
|
|
9
|
+
}
|
|
10
|
+
exports.transform = transform;
|
|
11
|
+
//# sourceMappingURL=selectionRanges.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
function transform(symbol, getOtherLocation) {
|
|
4
|
+
const location = getOtherLocation(symbol.location);
|
|
5
|
+
if (!location)
|
|
6
|
+
return;
|
|
7
|
+
return Object.assign(Object.assign({}, symbol), { location });
|
|
8
|
+
}
|
|
9
|
+
exports.transform = transform;
|
|
10
|
+
//# sourceMappingURL=symbolInformation.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const shared = require("@volar/shared");
|
|
4
|
+
const symbolInformation_1 = require("./symbolInformation");
|
|
5
|
+
function transform(locations, getOtherLocation) {
|
|
6
|
+
return locations
|
|
7
|
+
.map(location => (0, symbolInformation_1.transform)(location, getOtherLocation))
|
|
8
|
+
.filter(shared.notEmpty);
|
|
9
|
+
}
|
|
10
|
+
exports.transform = transform;
|
|
11
|
+
//# sourceMappingURL=symbolInformations.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.transform = void 0;
|
|
3
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
4
|
+
function transform(textEdit, getOtherRange, document) {
|
|
5
|
+
if (vscode.TextEdit.is(textEdit)) {
|
|
6
|
+
let range = getOtherRange(textEdit.range);
|
|
7
|
+
if (range) {
|
|
8
|
+
return Object.assign(Object.assign({}, textEdit), { range });
|
|
9
|
+
}
|
|
10
|
+
;
|
|
11
|
+
const cover = tryRecover(getOtherRange, textEdit.range, textEdit.newText, document);
|
|
12
|
+
if (cover) {
|
|
13
|
+
return Object.assign(Object.assign({}, textEdit), { range: cover.range, newText: cover.newText });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if (vscode.InsertReplaceEdit.is(textEdit)) {
|
|
17
|
+
const insert = getOtherRange(textEdit.insert);
|
|
18
|
+
const replace = insert ? getOtherRange(textEdit.replace) : undefined;
|
|
19
|
+
if (insert && replace) {
|
|
20
|
+
return Object.assign(Object.assign({}, textEdit), { insert,
|
|
21
|
+
replace });
|
|
22
|
+
}
|
|
23
|
+
const recoverInsert = tryRecover(getOtherRange, textEdit.insert, textEdit.newText, document);
|
|
24
|
+
const recoverReplace = recoverInsert ? tryRecover(getOtherRange, textEdit.replace, textEdit.newText, document) : undefined;
|
|
25
|
+
if (recoverInsert && recoverReplace && recoverInsert.newText === recoverReplace.newText) {
|
|
26
|
+
return Object.assign(Object.assign({}, textEdit), { insert: recoverInsert.range, replace: recoverReplace.range, newText: recoverInsert.newText });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.transform = transform;
|
|
31
|
+
/**
|
|
32
|
+
* update edit text from ". foo" to " foo"
|
|
33
|
+
* fix https://github.com/johnsoncodehk/volar/issues/2155
|
|
34
|
+
*/
|
|
35
|
+
function tryRecover(getOtherRange, replaceRange, newText, document) {
|
|
36
|
+
if (replaceRange.start.line === replaceRange.end.line && replaceRange.end.character > replaceRange.start.character) {
|
|
37
|
+
let character = replaceRange.start.character;
|
|
38
|
+
while (newText.length && replaceRange.end.character > character) {
|
|
39
|
+
const newStart = { line: replaceRange.start.line, character: replaceRange.start.character + 1 };
|
|
40
|
+
if (document.getText({ start: replaceRange.start, end: newStart }) === newText[0]) {
|
|
41
|
+
newText = newText.slice(1);
|
|
42
|
+
character++;
|
|
43
|
+
const otherRange = getOtherRange({ start: newStart, end: replaceRange.end });
|
|
44
|
+
if (otherRange) {
|
|
45
|
+
return {
|
|
46
|
+
newText,
|
|
47
|
+
range: otherRange,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=textEdit.js.map
|