@volar/typescript 2.2.1 → 2.2.3
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,19 +193,60 @@ 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
|
+
});
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
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
|
+
const displayPartsStrs = new Set([displayPartsToString(infos[0].displayParts)]);
|
|
221
|
+
const documentationStrs = new Set([displayPartsToString(infos[0].documentation)]);
|
|
222
|
+
const tagsStrs = new Set();
|
|
223
|
+
for (const tag of infos[0].tags ?? []) {
|
|
224
|
+
tagsStrs.add(tag.name + '__volar__' + displayPartsToString(tag.text));
|
|
225
|
+
}
|
|
226
|
+
for (let i = 1; i < infos.length; i++) {
|
|
227
|
+
const { displayParts, documentation, tags } = infos[i];
|
|
228
|
+
if (displayParts?.length && !displayPartsStrs.has(displayPartsToString(displayParts))) {
|
|
229
|
+
displayPartsStrs.add(displayPartsToString(displayParts));
|
|
230
|
+
combine.displayParts ??= [];
|
|
231
|
+
combine.displayParts.push({ ...displayParts[0], text: '\n\n' + displayParts[0].text });
|
|
232
|
+
combine.displayParts.push(...displayParts.slice(1));
|
|
233
|
+
}
|
|
234
|
+
if (documentation?.length && !documentationStrs.has(displayPartsToString(documentation))) {
|
|
235
|
+
documentationStrs.add(displayPartsToString(documentation));
|
|
236
|
+
combine.documentation ??= [];
|
|
237
|
+
combine.documentation.push({ ...documentation[0], text: '\n\n' + documentation[0].text });
|
|
238
|
+
combine.documentation.push(...documentation.slice(1));
|
|
239
|
+
}
|
|
240
|
+
for (const tag of tags ?? []) {
|
|
241
|
+
if (!tagsStrs.has(tag.name + '__volar__' + displayPartsToString(tag.text))) {
|
|
242
|
+
tagsStrs.add(tag.name + '__volar__' + displayPartsToString(tag.text));
|
|
243
|
+
combine.tags ??= [];
|
|
244
|
+
combine.tags.push(tag);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return combine;
|
|
249
|
+
}
|
|
209
250
|
}
|
|
210
251
|
else {
|
|
211
252
|
return getQuickInfoAtPosition(fileName, position);
|
|
@@ -538,7 +579,7 @@ function decorateLanguageService(language, languageService) {
|
|
|
538
579
|
continue;
|
|
539
580
|
}
|
|
540
581
|
const result = getCompletionsAtPosition(fileName, generatedOffset, options, formattingSettings);
|
|
541
|
-
if (!result
|
|
582
|
+
if (!result) {
|
|
542
583
|
continue;
|
|
543
584
|
}
|
|
544
585
|
if (typeof mapping.data.completion === 'object' && mapping.data.completion.onlyImport) {
|
|
@@ -554,7 +595,7 @@ function decorateLanguageService(language, languageService) {
|
|
|
554
595
|
results.push(result);
|
|
555
596
|
}
|
|
556
597
|
else {
|
|
557
|
-
results.
|
|
598
|
+
results.unshift(result);
|
|
558
599
|
}
|
|
559
600
|
}
|
|
560
601
|
if (results.length) {
|
|
@@ -678,4 +719,10 @@ function decorateLanguageService(language, languageService) {
|
|
|
678
719
|
}
|
|
679
720
|
}
|
|
680
721
|
exports.decorateLanguageService = decorateLanguageService;
|
|
722
|
+
function displayPartsToString(displayParts) {
|
|
723
|
+
if (displayParts) {
|
|
724
|
+
return displayParts.map(displayPart => displayPart.text).join('');
|
|
725
|
+
}
|
|
726
|
+
return '';
|
|
727
|
+
}
|
|
681
728
|
//# sourceMappingURL=decorateLanguageService.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.3",
|
|
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.3",
|
|
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.3"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "189ea5c663630358a9ad965c50d2bee69a9d84eb"
|
|
24
24
|
}
|