@volar/language-service 2.0.2 → 2.0.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.
|
@@ -6,6 +6,7 @@ const common_1 = require("../utils/common");
|
|
|
6
6
|
const provideDiagnostics_1 = require("./provideDiagnostics");
|
|
7
7
|
const cancellation_1 = require("../utils/cancellation");
|
|
8
8
|
const language_core_1 = require("@volar/language-core");
|
|
9
|
+
const resolveDocumentLink_1 = require("./resolveDocumentLink");
|
|
9
10
|
function register(context) {
|
|
10
11
|
return async (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
|
11
12
|
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHoverEnabled), (service, document, position) => {
|
|
@@ -52,23 +53,44 @@ function register(context) {
|
|
|
52
53
|
}
|
|
53
54
|
return hover;
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
function getHoverTexts(hover) {
|
|
57
|
+
if (typeof hover.contents === 'string') {
|
|
58
|
+
return [transformMarkdown(hover.contents)];
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(hover.contents)) {
|
|
61
|
+
return hover.contents.map(content => {
|
|
62
|
+
if (typeof content === 'string') {
|
|
63
|
+
return transformMarkdown(content);
|
|
64
|
+
}
|
|
65
|
+
if (content.language === 'md') {
|
|
66
|
+
return `\`\`\`${content.language}\n${transformMarkdown(content.value)}\n\`\`\``;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return `\`\`\`${content.language}\n${content.value}\n\`\`\``;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if ('kind' in hover.contents) {
|
|
74
|
+
if (hover.contents.kind === 'markdown') {
|
|
75
|
+
return [transformMarkdown(hover.contents.value)];
|
|
65
76
|
}
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
else {
|
|
78
|
+
return [hover.contents.value];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (hover.contents.language === 'md') {
|
|
82
|
+
return [`\`\`\`${hover.contents.language}\n${transformMarkdown(hover.contents.value)}\n\`\`\``];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return [`\`\`\`${hover.contents.language}\n${hover.contents.value}\n\`\`\``];
|
|
86
|
+
}
|
|
68
87
|
}
|
|
69
|
-
|
|
70
|
-
return [
|
|
88
|
+
function transformMarkdown(content) {
|
|
89
|
+
return content.replace(/(\[[^\]]+\])(\([^)]+\))/g, s => {
|
|
90
|
+
const match = s.match(/(\[[^\]]+\])(\([^)]+\))/);
|
|
91
|
+
return `${match[1]}(${(0, resolveDocumentLink_1.transformDocumentLinkTarget)(match[2].slice(1, -1), context)})`;
|
|
92
|
+
});
|
|
71
93
|
}
|
|
72
|
-
return [`\`\`\`${hover.contents.language}\n${hover.contents.value}\n\`\`\``];
|
|
73
94
|
}
|
|
95
|
+
exports.register = register;
|
|
74
96
|
//# sourceMappingURL=provideHover.js.map
|
|
@@ -24,7 +24,7 @@ function register(context) {
|
|
|
24
24
|
exports.register = register;
|
|
25
25
|
function transformDocumentLinkTarget(target, context) {
|
|
26
26
|
const targetUri = vscode_uri_1.URI.parse(target);
|
|
27
|
-
const clearUri = targetUri.with({ fragment: '' }).toString();
|
|
27
|
+
const clearUri = targetUri.with({ fragment: '' }).toString(true);
|
|
28
28
|
const [virtualCode] = context.documents.getVirtualCodeByUri(clearUri);
|
|
29
29
|
if (virtualCode) {
|
|
30
30
|
for (const map of context.documents.getMaps(virtualCode)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/language-service"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.0.
|
|
15
|
+
"@volar/language-core": "2.0.3",
|
|
16
16
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
17
17
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
18
18
|
"vscode-uri": "^3.0.8"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "d8a6dc056d37779ff6486f545f45bc57b22c02e4"
|
|
21
21
|
}
|