@volar/typescript 2.2.0 → 2.2.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.
|
@@ -193,18 +193,54 @@ function decorateLanguageService(language, languageService) {
|
|
|
193
193
|
const fileName = filePath.replace(windowsPathReg, '/');
|
|
194
194
|
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
|
|
195
195
|
if (serviceScript) {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
const infos = [];
|
|
197
|
+
for (const [generatePosition, mapping] of (0, transform_1.toGeneratedOffsets)(sourceScript, map, position)) {
|
|
198
|
+
if (!(0, language_core_1.isHoverEnabled)(mapping.data)) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const info = getQuickInfoAtPosition(fileName, generatePosition);
|
|
202
|
+
if (info) {
|
|
203
|
+
const textSpan = (0, transform_1.transformTextSpan)(sourceScript, map, info.textSpan, language_core_1.isHoverEnabled);
|
|
201
204
|
if (textSpan) {
|
|
202
|
-
|
|
203
|
-
...
|
|
205
|
+
infos.push({
|
|
206
|
+
...info,
|
|
204
207
|
textSpan,
|
|
205
|
-
};
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (infos.length === 1) {
|
|
213
|
+
return infos[0];
|
|
214
|
+
}
|
|
215
|
+
else if (infos.length >= 2) {
|
|
216
|
+
const combine = { ...infos[0] };
|
|
217
|
+
combine.displayParts = combine.displayParts?.slice();
|
|
218
|
+
combine.documentation = combine.documentation?.slice();
|
|
219
|
+
combine.tags = combine.tags?.slice();
|
|
220
|
+
for (let i = 1; i < infos.length; i++) {
|
|
221
|
+
const { displayParts, documentation, tags } = infos[i];
|
|
222
|
+
if (!combine.displayParts) {
|
|
223
|
+
combine.displayParts = displayParts;
|
|
224
|
+
}
|
|
225
|
+
else if (displayParts?.length) {
|
|
226
|
+
combine.displayParts.push({ ...displayParts[0], text: '\n\n' + displayParts[0].text });
|
|
227
|
+
combine.displayParts.push(...displayParts.slice(1));
|
|
228
|
+
}
|
|
229
|
+
if (!combine.documentation) {
|
|
230
|
+
combine.documentation = documentation;
|
|
231
|
+
}
|
|
232
|
+
else if (documentation?.length) {
|
|
233
|
+
combine.documentation.push({ ...documentation[0], text: '\n\n' + documentation[0].text });
|
|
234
|
+
combine.documentation.push(...documentation.slice(1));
|
|
235
|
+
}
|
|
236
|
+
if (!combine.tags) {
|
|
237
|
+
combine.tags = tags;
|
|
238
|
+
}
|
|
239
|
+
else if (tags?.length) {
|
|
240
|
+
combine.tags.push(...tags);
|
|
206
241
|
}
|
|
207
242
|
}
|
|
243
|
+
return combine;
|
|
208
244
|
}
|
|
209
245
|
}
|
|
210
246
|
else {
|
|
@@ -316,7 +352,10 @@ function decorateLanguageService(language, languageService) {
|
|
|
316
352
|
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
|
|
317
353
|
if (serviceScript) {
|
|
318
354
|
let failed;
|
|
319
|
-
for (const generateOffset of (0, transform_1.
|
|
355
|
+
for (const [generateOffset, mapping] of (0, transform_1.toGeneratedOffsets)(sourceScript, map, position)) {
|
|
356
|
+
if (!(0, language_core_1.isRenameEnabled)(mapping.data)) {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
320
359
|
const info = getRenameInfo(fileName, generateOffset, options);
|
|
321
360
|
if (info.canRename) {
|
|
322
361
|
const span = (0, transform_1.transformTextSpan)(sourceScript, map, info.triggerSpan, language_core_1.isRenameEnabled);
|
|
@@ -529,44 +568,37 @@ function decorateLanguageService(language, languageService) {
|
|
|
529
568
|
const fileName = filePath.replace(windowsPathReg, '/');
|
|
530
569
|
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
|
|
531
570
|
if (serviceScript) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (!(0, language_core_1.isCompletionEnabled)(data)) {
|
|
537
|
-
return false;
|
|
538
|
-
}
|
|
539
|
-
isAdditional = typeof data.completion === 'object' && data.completion.isAdditional;
|
|
540
|
-
if (!isAdditional && mainResult) {
|
|
541
|
-
return false;
|
|
571
|
+
const results = [];
|
|
572
|
+
for (const [generatedOffset, mapping] of (0, transform_1.toGeneratedOffsets)(sourceScript, map, position)) {
|
|
573
|
+
if (!(0, language_core_1.isCompletionEnabled)(mapping.data)) {
|
|
574
|
+
continue;
|
|
542
575
|
}
|
|
543
|
-
return true;
|
|
544
|
-
});
|
|
545
|
-
if (generatedOffset !== undefined) {
|
|
546
576
|
const result = getCompletionsAtPosition(fileName, generatedOffset, options, formattingSettings);
|
|
547
|
-
if (result) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
result.
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
577
|
+
if (!result || !result.entries.length) {
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
if (typeof mapping.data.completion === 'object' && mapping.data.completion.onlyImport) {
|
|
581
|
+
result.entries = result.entries.filter(entry => !!entry.sourceDisplay);
|
|
582
|
+
}
|
|
583
|
+
for (const entry of result.entries) {
|
|
584
|
+
entry.replacementSpan = entry.replacementSpan && (0, transform_1.transformTextSpan)(sourceScript, map, entry.replacementSpan, language_core_1.isCompletionEnabled);
|
|
585
|
+
}
|
|
586
|
+
result.optionalReplacementSpan = result.optionalReplacementSpan
|
|
587
|
+
&& (0, transform_1.transformTextSpan)(sourceScript, map, result.optionalReplacementSpan, language_core_1.isCompletionEnabled);
|
|
588
|
+
const isAdditional = typeof mapping.data.completion === 'object' && mapping.data.completion.isAdditional;
|
|
589
|
+
if (isAdditional) {
|
|
590
|
+
results.push(result);
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
results.splice(0, 0, result);
|
|
558
594
|
}
|
|
559
595
|
}
|
|
560
|
-
if (
|
|
561
|
-
mainResult = additionalResults.shift();
|
|
562
|
-
}
|
|
563
|
-
if (mainResult) {
|
|
596
|
+
if (results.length) {
|
|
564
597
|
return {
|
|
565
|
-
...
|
|
566
|
-
entries:
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
],
|
|
598
|
+
...results[0],
|
|
599
|
+
entries: results
|
|
600
|
+
.map(additionalResult => additionalResult.entries)
|
|
601
|
+
.flat(),
|
|
570
602
|
};
|
|
571
603
|
}
|
|
572
604
|
}
|
package/lib/node/transform.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export declare function transformTextChange(sourceScript: SourceScript, map: Sou
|
|
|
13
13
|
export declare function transformTextSpan(sourceScript: SourceScript, map: SourceMap<CodeInformation>, textSpan: ts.TextSpan, filter: (data: CodeInformation) => boolean): ts.TextSpan | undefined;
|
|
14
14
|
export declare function toSourceOffset(sourceScript: SourceScript, map: SourceMap, position: number, filter: (data: CodeInformation) => boolean): number | undefined;
|
|
15
15
|
export declare function toGeneratedOffset(sourceScript: SourceScript, map: SourceMap, position: number, filter: (data: CodeInformation) => boolean): number | undefined;
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function toGeneratedOffsets(sourceScript: SourceScript, map: SourceMap<CodeInformation>, position: number): Generator<readonly [number, import("@volar/language-core").Mapping<CodeInformation>], void, unknown>;
|
package/lib/node/transform.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toGeneratedOffsets = exports.toGeneratedOffset = exports.toSourceOffset = exports.transformTextSpan = exports.transformTextChange = exports.transformSpan = exports.transformDocumentSpan = exports.transformFileTextChanges = exports.fillSourceFileText = exports.transformDiagnostic = exports.transformCallHierarchyItem = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
const transformedDiagnostics = new WeakMap();
|
|
@@ -172,12 +172,10 @@ function toGeneratedOffset(sourceScript, map, position, filter) {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
exports.toGeneratedOffset = toGeneratedOffset;
|
|
175
|
-
function*
|
|
175
|
+
function* toGeneratedOffsets(sourceScript, map, position) {
|
|
176
176
|
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
|
|
177
|
-
|
|
178
|
-
yield generateOffset + sourceScript.snapshot.getLength();
|
|
179
|
-
}
|
|
177
|
+
yield [generateOffset + sourceScript.snapshot.getLength(), mapping];
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
|
-
exports.
|
|
180
|
+
exports.toGeneratedOffsets = toGeneratedOffsets;
|
|
183
181
|
//# sourceMappingURL=transform.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/typescript",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"directory": "packages/typescript"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.2.
|
|
15
|
+
"@volar/language-core": "2.2.2",
|
|
16
16
|
"path-browserify": "^1.0.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "latest",
|
|
20
20
|
"@types/path-browserify": "latest",
|
|
21
|
-
"@volar/language-service": "2.2.
|
|
21
|
+
"@volar/language-service": "2.2.2"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "8aa41e4c2ab1e954b8c777f789b7a948972e77aa"
|
|
24
24
|
}
|