volar-service-typescript-twoslash-queries 0.0.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/index.d.ts +3 -0
- package/out/index.js +35 -0
- package/package.json +24 -0
package/out/index.d.ts
ADDED
package/out/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = () => (context, modules) => ({
|
|
4
|
+
provideInlayHints(document, range) {
|
|
5
|
+
if (modules?.typescript && context?.typescript && isTsDocument(document.languageId)) {
|
|
6
|
+
const ts = modules.typescript;
|
|
7
|
+
const inlayHints = [];
|
|
8
|
+
for (const pointer of document.getText(range).matchAll(/^\s*\/\/\s*\^\?/gm)) {
|
|
9
|
+
const pointerOffset = pointer.index + pointer[0].indexOf('^?') + document.offsetAt(range.start);
|
|
10
|
+
const pointerPosition = document.positionAt(pointerOffset);
|
|
11
|
+
const hoverOffset = document.offsetAt({
|
|
12
|
+
line: pointerPosition.line - 1,
|
|
13
|
+
character: pointerPosition.character,
|
|
14
|
+
});
|
|
15
|
+
const quickInfo = context.typescript.languageService.getQuickInfoAtPosition(context.env.uriToFileName(document.uri), hoverOffset);
|
|
16
|
+
if (quickInfo) {
|
|
17
|
+
inlayHints.push({
|
|
18
|
+
position: { line: pointerPosition.line, character: pointerPosition.character + 2 },
|
|
19
|
+
label: ts.displayPartsToString(quickInfo.displayParts),
|
|
20
|
+
paddingLeft: true,
|
|
21
|
+
paddingRight: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return inlayHints;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
function isTsDocument(languageId) {
|
|
30
|
+
return languageId === 'javascript' ||
|
|
31
|
+
languageId === 'typescript' ||
|
|
32
|
+
languageId === 'javascriptreact' ||
|
|
33
|
+
languageId === 'typescriptreact';
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "volar-service-typescript-twoslash-queries",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"main": "out/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"out/**/*.js",
|
|
8
|
+
"out/**/*.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/volarjs/services.git",
|
|
13
|
+
"directory": "packages/typescript-twoslash-queries"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@volar/language-service": "*"
|
|
17
|
+
},
|
|
18
|
+
"peerDependenciesMeta": {
|
|
19
|
+
"@volar/language-service": {
|
|
20
|
+
"optional": true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"gitHead": "1011561ac4bbf79c53c3b80c27692569bf861519"
|
|
24
|
+
}
|