@volar/language-service 1.0.0-alpha.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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/out/baseDocumentService.d.ts +35 -0
  3. package/out/baseDocumentService.js +100 -0
  4. package/out/baseLanguageService.d.ts +55 -0
  5. package/out/baseLanguageService.js +114 -0
  6. package/out/documentFeatures/autoInsert.d.ts +5 -0
  7. package/out/documentFeatures/autoInsert.js +25 -0
  8. package/out/documentFeatures/colorPresentations.d.ts +4 -0
  9. package/out/documentFeatures/colorPresentations.js +35 -0
  10. package/out/documentFeatures/documentColors.d.ts +4 -0
  11. package/out/documentFeatures/documentColors.js +21 -0
  12. package/out/documentFeatures/documentSymbols.d.ts +4 -0
  13. package/out/documentFeatures/documentSymbols.js +21 -0
  14. package/out/documentFeatures/foldingRanges.d.ts +4 -0
  15. package/out/documentFeatures/foldingRanges.js +16 -0
  16. package/out/documentFeatures/format.d.ts +7 -0
  17. package/out/documentFeatures/format.js +242 -0
  18. package/out/documentFeatures/linkedEditingRanges.d.ts +4 -0
  19. package/out/documentFeatures/linkedEditingRanges.js +23 -0
  20. package/out/documentFeatures/selectionRanges.d.ts +4 -0
  21. package/out/documentFeatures/selectionRanges.js +19 -0
  22. package/out/documents.d.ts +106 -0
  23. package/out/documents.js +227 -0
  24. package/out/index.d.ts +8 -0
  25. package/out/index.js +27 -0
  26. package/out/languageFeatures/autoInsert.d.ts +4 -0
  27. package/out/languageFeatures/autoInsert.js +35 -0
  28. package/out/languageFeatures/callHierarchy.d.ts +15 -0
  29. package/out/languageFeatures/callHierarchy.js +148 -0
  30. package/out/languageFeatures/codeActionResolve.d.ts +3 -0
  31. package/out/languageFeatures/codeActionResolve.js +45 -0
  32. package/out/languageFeatures/codeActions.d.ts +11 -0
  33. package/out/languageFeatures/codeActions.js +89 -0
  34. package/out/languageFeatures/codeLens.d.ts +8 -0
  35. package/out/languageFeatures/codeLens.js +45 -0
  36. package/out/languageFeatures/codeLensResolve.d.ts +3 -0
  37. package/out/languageFeatures/codeLensResolve.js +30 -0
  38. package/out/languageFeatures/complete.d.ts +14 -0
  39. package/out/languageFeatures/complete.js +181 -0
  40. package/out/languageFeatures/completeResolve.d.ts +3 -0
  41. package/out/languageFeatures/completeResolve.js +60 -0
  42. package/out/languageFeatures/definition.d.ts +4 -0
  43. package/out/languageFeatures/definition.js +85 -0
  44. package/out/languageFeatures/documentHighlights.d.ts +3 -0
  45. package/out/languageFeatures/documentHighlights.js +65 -0
  46. package/out/languageFeatures/documentLinks.d.ts +3 -0
  47. package/out/languageFeatures/documentLinks.js +53 -0
  48. package/out/languageFeatures/documentSemanticTokens.d.ts +4 -0
  49. package/out/languageFeatures/documentSemanticTokens.js +59 -0
  50. package/out/languageFeatures/executeCommand.d.ts +11 -0
  51. package/out/languageFeatures/executeCommand.js +31 -0
  52. package/out/languageFeatures/fileReferences.d.ts +4 -0
  53. package/out/languageFeatures/fileReferences.js +37 -0
  54. package/out/languageFeatures/fileRename.d.ts +3 -0
  55. package/out/languageFeatures/fileRename.js +36 -0
  56. package/out/languageFeatures/hover.d.ts +3 -0
  57. package/out/languageFeatures/hover.js +48 -0
  58. package/out/languageFeatures/inlayHints.d.ts +3 -0
  59. package/out/languageFeatures/inlayHints.js +65 -0
  60. package/out/languageFeatures/references.d.ts +3 -0
  61. package/out/languageFeatures/references.js +68 -0
  62. package/out/languageFeatures/rename.d.ts +19 -0
  63. package/out/languageFeatures/rename.js +226 -0
  64. package/out/languageFeatures/renamePrepare.d.ts +3 -0
  65. package/out/languageFeatures/renamePrepare.js +41 -0
  66. package/out/languageFeatures/signatureHelp.d.ts +3 -0
  67. package/out/languageFeatures/signatureHelp.js +14 -0
  68. package/out/languageFeatures/validation.d.ts +7 -0
  69. package/out/languageFeatures/validation.js +237 -0
  70. package/out/languageFeatures/workspaceSymbols.d.ts +3 -0
  71. package/out/languageFeatures/workspaceSymbols.js +34 -0
  72. package/out/plugin.d.ts +93 -0
  73. package/out/plugin.js +3 -0
  74. package/out/types.d.ts +43 -0
  75. package/out/types.js +4 -0
  76. package/out/utils/dedupe.d.ts +15 -0
  77. package/out/utils/dedupe.js +132 -0
  78. package/out/utils/definePlugin.d.ts +2 -0
  79. package/out/utils/definePlugin.js +27 -0
  80. package/out/utils/featureWorkers.d.ts +7 -0
  81. package/out/utils/featureWorkers.js +120 -0
  82. package/out/utils/singleFileTypeScriptService.d.ts +4 -0
  83. package/out/utils/singleFileTypeScriptService.js +30 -0
  84. package/package.json +32 -0
@@ -0,0 +1,60 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const transforms_1 = require("@volar/transforms");
13
+ function register(context) {
14
+ return (item, newPosition) => __awaiter(this, void 0, void 0, function* () {
15
+ var _a, _b;
16
+ const data = item.data;
17
+ if (data) {
18
+ const plugin = context.plugins[data.pluginId];
19
+ if (!plugin)
20
+ return item;
21
+ if (!((_a = plugin.complete) === null || _a === void 0 ? void 0 : _a.resolve))
22
+ return item;
23
+ const originalItem = data.originalItem;
24
+ if (data.sourceMap) {
25
+ const sourceMap = context.documents.sourceMapFromEmbeddedDocumentUri(data.sourceMap.embeddedDocumentUri);
26
+ if (sourceMap) {
27
+ const newPosition_2 = newPosition
28
+ ? (_b = sourceMap.getMappedRange(newPosition, newPosition, data => !!data.completion)) === null || _b === void 0 ? void 0 : _b[0].start
29
+ : undefined;
30
+ const resolvedItem = yield plugin.complete.resolve(originalItem, newPosition_2);
31
+ // fix https://github.com/johnsoncodehk/volar/issues/916
32
+ if (resolvedItem.additionalTextEdits) {
33
+ for (const edit of resolvedItem.additionalTextEdits) {
34
+ if (edit.range.start.line === 0
35
+ && edit.range.start.character === 0
36
+ && edit.range.end.line === 0
37
+ && edit.range.end.character === 0) {
38
+ edit.newText = '\n' + edit.newText;
39
+ }
40
+ }
41
+ }
42
+ item = (0, transforms_1.transformCompletionItem)(resolvedItem, embeddedRange => {
43
+ var _a, _b, _c;
44
+ return (_b = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange)) !== null && _b !== void 0 ? _b : (_c = sourceMap.getSourceRange(embeddedRange.start, embeddedRange.end)) === null || _c === void 0 ? void 0 : _c[0];
45
+ });
46
+ }
47
+ }
48
+ else {
49
+ item = yield plugin.complete.resolve(originalItem);
50
+ }
51
+ }
52
+ // TODO: monkey fix import ts file icon
53
+ if (item.detail !== item.detail + '.ts') {
54
+ item.detail = item.detail;
55
+ }
56
+ return item;
57
+ });
58
+ }
59
+ exports.register = register;
60
+ //# sourceMappingURL=completeResolve.js.map
@@ -0,0 +1,4 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { LanguageServiceRuntimeContext } from '../types';
3
+ import { PositionCapabilities, TeleportCapabilities } from '@volar/language-core';
4
+ export declare function register(context: LanguageServiceRuntimeContext, api: 'findDefinition' | 'findTypeDefinition' | 'findImplementations', isValidMappingData: (data: PositionCapabilities) => boolean, isValidTeleportSideData: (sideData: TeleportCapabilities) => boolean): (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
@@ -0,0 +1,85 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const shared = require("@volar/shared");
13
+ const featureWorkers_1 = require("../utils/featureWorkers");
14
+ const dedupe = require("../utils/dedupe");
15
+ function register(context, api, isValidMappingData, isValidTeleportSideData) {
16
+ return (uri, position) => {
17
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, function* (position, sourceMap) {
18
+ for (const [mappedRange] of sourceMap.getMappedRanges(position, position, isValidMappingData)) {
19
+ yield mappedRange.start;
20
+ }
21
+ }, (plugin, document, position, sourceMap) => __awaiter(this, void 0, void 0, function* () {
22
+ const recursiveChecker = dedupe.createLocationSet();
23
+ const result = [];
24
+ yield withTeleports(document, position, undefined);
25
+ return result;
26
+ function withTeleports(document, position, originDefinition) {
27
+ var _a, _b, _c;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const _api = api === 'findDefinition' ? (_a = plugin.definition) === null || _a === void 0 ? void 0 : _a.on :
30
+ api === 'findTypeDefinition' ? (_b = plugin.definition) === null || _b === void 0 ? void 0 : _b.onType :
31
+ api === 'findImplementations' ? plugin.findImplementations :
32
+ undefined;
33
+ if (!_api)
34
+ return;
35
+ if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
36
+ return;
37
+ recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
38
+ const definitions = (_c = yield (_api === null || _api === void 0 ? void 0 : _api(document, position))) !== null && _c !== void 0 ? _c : [];
39
+ for (const definition of definitions) {
40
+ let foundTeleport = false;
41
+ recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
42
+ const teleport = context.documents.teleportfromEmbeddedDocumentUri(definition.targetUri);
43
+ if (teleport) {
44
+ for (const [teleRange] of teleport.findTeleports(definition.targetSelectionRange.start, definition.targetSelectionRange.end, isValidTeleportSideData)) {
45
+ if (recursiveChecker.has({ uri: teleport.document.uri, range: { start: teleRange.start, end: teleRange.start } }))
46
+ continue;
47
+ foundTeleport = true;
48
+ yield withTeleports(teleport.document, teleRange.start, originDefinition !== null && originDefinition !== void 0 ? originDefinition : definition);
49
+ }
50
+ }
51
+ if (!foundTeleport) {
52
+ if (originDefinition) {
53
+ result.push(Object.assign(Object.assign({}, definition), { originSelectionRange: originDefinition.originSelectionRange }));
54
+ }
55
+ else {
56
+ result.push(definition);
57
+ }
58
+ }
59
+ }
60
+ });
61
+ }
62
+ }), (data, sourceMap) => data.map(link => {
63
+ var _a, _b, _c;
64
+ if (link.originSelectionRange && sourceMap) {
65
+ const originSelectionRange = (_a = sourceMap.getSourceRange(link.originSelectionRange.start, link.originSelectionRange.end)) === null || _a === void 0 ? void 0 : _a[0];
66
+ if (!originSelectionRange)
67
+ return;
68
+ link.originSelectionRange = originSelectionRange;
69
+ }
70
+ const targetSourceMap = context.documents.sourceMapFromEmbeddedDocumentUri(link.targetUri);
71
+ if (targetSourceMap) {
72
+ const targetRange = (_b = targetSourceMap.getSourceRange(link.targetRange.start, link.targetRange.end)) === null || _b === void 0 ? void 0 : _b[0];
73
+ const targetSelectionRange = (_c = targetSourceMap.getSourceRange(link.targetSelectionRange.start, link.targetSelectionRange.end)) === null || _c === void 0 ? void 0 : _c[0];
74
+ if (!targetSelectionRange)
75
+ return;
76
+ link.targetUri = targetSourceMap.sourceDocument.uri;
77
+ link.targetRange = targetRange !== null && targetRange !== void 0 ? targetRange : targetSelectionRange; // loose range mapping to for template slots, slot properties
78
+ link.targetSelectionRange = targetSelectionRange;
79
+ }
80
+ return link;
81
+ }).filter(shared.notEmpty), arr => dedupe.withLocationLinks(arr.flat()));
82
+ };
83
+ }
84
+ exports.register = register;
85
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1,3 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { LanguageServiceRuntimeContext } from '../types';
3
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position) => Promise<vscode.DocumentHighlight[] | undefined>;
@@ -0,0 +1,65 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const shared = require("@volar/shared");
13
+ const featureWorkers_1 = require("../utils/featureWorkers");
14
+ const dedupe = require("../utils/dedupe");
15
+ function register(context) {
16
+ return (uri, position) => {
17
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, function* (position, sourceMap) {
18
+ for (const [mappedRange] of sourceMap.getMappedRanges(position, position, data => !!data.references)) {
19
+ yield mappedRange.start;
20
+ }
21
+ }, (plugin, document, position, sourceMap, vueDocument) => __awaiter(this, void 0, void 0, function* () {
22
+ const recursiveChecker = dedupe.createLocationSet();
23
+ const result = [];
24
+ yield withTeleports(document, position);
25
+ return result;
26
+ function withTeleports(document, position) {
27
+ var _a;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ if (!plugin.findDocumentHighlights)
30
+ return;
31
+ if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
32
+ return;
33
+ recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
34
+ const references = (_a = yield plugin.findDocumentHighlights(document, position)) !== null && _a !== void 0 ? _a : [];
35
+ for (const reference of references) {
36
+ let foundTeleport = false;
37
+ recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
38
+ const teleport = context.documents.teleportfromEmbeddedDocumentUri(document.uri);
39
+ if (teleport) {
40
+ for (const [teleRange] of teleport.findTeleports(reference.range.start, reference.range.end, sideData => !!sideData.references)) {
41
+ if (recursiveChecker.has({ uri: teleport.document.uri, range: { start: teleRange.start, end: teleRange.start } }))
42
+ continue;
43
+ foundTeleport = true;
44
+ yield withTeleports(teleport.document, teleRange.start);
45
+ }
46
+ }
47
+ if (!foundTeleport) {
48
+ result.push(reference);
49
+ }
50
+ }
51
+ });
52
+ }
53
+ }), (data, sourceMap) => data.map(highlisht => {
54
+ var _a;
55
+ if (!sourceMap)
56
+ return highlisht;
57
+ const range = (_a = sourceMap.getSourceRange(highlisht.range.start, highlisht.range.end)) === null || _a === void 0 ? void 0 : _a[0];
58
+ if (range) {
59
+ return Object.assign(Object.assign({}, highlisht), { range });
60
+ }
61
+ }).filter(shared.notEmpty), arr => arr.flat());
62
+ };
63
+ }
64
+ exports.register = register;
65
+ //# sourceMappingURL=documentHighlights.js.map
@@ -0,0 +1,3 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { LanguageServiceRuntimeContext } from '../types';
3
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string) => Promise<vscode.DocumentLink[]>;
@@ -0,0 +1,53 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const shared = require("@volar/shared");
13
+ const featureWorkers_1 = require("../utils/featureWorkers");
14
+ function register(context) {
15
+ return (uri) => __awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ const pluginLinks = (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg, sourceMap) => [arg], (plugin, document, arg) => { var _a; return (_a = plugin.findDocumentLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, sourceMap) => data.map(link => {
18
+ var _a;
19
+ if (!sourceMap)
20
+ return link;
21
+ const range = (_a = sourceMap.getSourceRange(link.range.start, link.range.end)) === null || _a === void 0 ? void 0 : _a[0];
22
+ if (range) {
23
+ return Object.assign(Object.assign({}, link), { range });
24
+ }
25
+ }).filter(shared.notEmpty), arr => arr.flat())) !== null && _a !== void 0 ? _a : [];
26
+ const vueDocument = context.documents.get(uri);
27
+ const fictitiousLinks = vueDocument ? getFictitiousLinks(vueDocument) : [];
28
+ return [
29
+ ...pluginLinks,
30
+ ...fictitiousLinks,
31
+ ];
32
+ function getFictitiousLinks(vueDocument) {
33
+ const result = [];
34
+ const document = vueDocument.getDocument();
35
+ for (const sourceMap of vueDocument.getSourceMaps()) {
36
+ for (const mapped of sourceMap.base.mappings) {
37
+ if (!mapped.data.displayWithLink)
38
+ continue;
39
+ result.push({
40
+ range: {
41
+ start: document.positionAt(mapped.sourceRange.start),
42
+ end: document.positionAt(mapped.sourceRange.end),
43
+ },
44
+ target: uri, // TODO
45
+ });
46
+ }
47
+ }
48
+ return result;
49
+ }
50
+ });
51
+ }
52
+ exports.register = register;
53
+ //# sourceMappingURL=documentLinks.js.map
@@ -0,0 +1,4 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import { SemanticToken } from '@volar/language-service';
3
+ import type { LanguageServiceRuntimeContext } from '../types';
4
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string, range?: vscode.Range, cancleToken?: vscode.CancellationToken, reportProgress?: ((tokens: SemanticToken[]) => void) | undefined) => Promise<SemanticToken[] | undefined> | undefined;
@@ -0,0 +1,59 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.register = void 0;
3
+ const shared = require("@volar/shared");
4
+ const vscode = require("vscode-languageserver-protocol");
5
+ const featureWorkers_1 = require("../utils/featureWorkers");
6
+ function register(context) {
7
+ return (uri, range, cancleToken, reportProgress) => {
8
+ const document = context.getTextDocument(uri);
9
+ if (!document)
10
+ return;
11
+ const offsetRange = range ? {
12
+ start: document.offsetAt(range.start),
13
+ end: document.offsetAt(range.end),
14
+ } : {
15
+ start: 0,
16
+ end: document.getText().length,
17
+ };
18
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange, sourceMap) {
19
+ if (cancleToken === null || cancleToken === void 0 ? void 0 : cancleToken.isCancellationRequested)
20
+ return;
21
+ let range;
22
+ for (const mapping of sourceMap.base.mappings) {
23
+ if (cancleToken === null || cancleToken === void 0 ? void 0 : cancleToken.isCancellationRequested)
24
+ return;
25
+ if (mapping.data.semanticTokens
26
+ && mapping.sourceRange.end > offsetRange.start
27
+ && mapping.sourceRange.start < offsetRange.end) {
28
+ if (!range) {
29
+ range = Object.assign({}, mapping.mappedRange);
30
+ }
31
+ else {
32
+ range.start = Math.min(range.start, mapping.mappedRange.start);
33
+ range.end = Math.max(range.end, mapping.mappedRange.end);
34
+ }
35
+ }
36
+ }
37
+ if (range) {
38
+ yield range;
39
+ }
40
+ }, (plugin, document, offsetRange) => {
41
+ var _a;
42
+ return (_a = plugin.findDocumentSemanticTokens) === null || _a === void 0 ? void 0 : _a.call(plugin, document, vscode.Range.create(document.positionAt(offsetRange.start), document.positionAt(offsetRange.end)), cancleToken);
43
+ }, (tokens, sourceMap) => tokens.map(_token => {
44
+ var _a;
45
+ if (!sourceMap)
46
+ return _token;
47
+ const _start = sourceMap.mappedDocument.offsetAt({ line: _token[0], character: _token[1] });
48
+ const _end = sourceMap.mappedDocument.offsetAt({ line: _token[0], character: _token[1] + _token[2] });
49
+ const range = (_a = sourceMap.getSourceRange(_start, _end, data => !!data.semanticTokens)) === null || _a === void 0 ? void 0 : _a[0];
50
+ if (!range)
51
+ return;
52
+ const start = document.positionAt(range.start);
53
+ const token = [start.line, start.character, range.end - range.start, _token[3], _token[4]];
54
+ return token;
55
+ }).filter(shared.notEmpty), tokens => tokens.flat(), reportProgress);
56
+ };
57
+ }
58
+ exports.register = register;
59
+ //# sourceMappingURL=documentSemanticTokens.js.map
@@ -0,0 +1,11 @@
1
+ import type { LanguageServiceRuntimeContext } from '../types';
2
+ import { ExecuteCommandContext } from '@volar/language-service';
3
+ import * as vscode from 'vscode-languageserver-protocol';
4
+ export declare const executePluginCommand = "volar.executtePluginCommand";
5
+ export declare type ExecutePluginCommandArgs = [
6
+ string,
7
+ // uri
8
+ number | undefined,
9
+ vscode.Command
10
+ ];
11
+ export declare function register(context: LanguageServiceRuntimeContext): (command: string, args: ExecutePluginCommandArgs, executeCommandContext: ExecuteCommandContext) => Promise<void>;
@@ -0,0 +1,31 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = exports.executePluginCommand = void 0;
12
+ exports.executePluginCommand = 'volar.executtePluginCommand';
13
+ function register(context) {
14
+ return (command, args, executeCommandContext) => __awaiter(this, void 0, void 0, function* () {
15
+ var _a, _b;
16
+ if (command === exports.executePluginCommand) {
17
+ const [_uri, pluginId, originalCommand] = args;
18
+ if (pluginId !== undefined) {
19
+ const plugin = context.plugins[pluginId];
20
+ yield ((_a = plugin === null || plugin === void 0 ? void 0 : plugin.doExecuteCommand) === null || _a === void 0 ? void 0 : _a.call(plugin, originalCommand.command, originalCommand.arguments, executeCommandContext));
21
+ }
22
+ else {
23
+ for (const plugin of context.plugins) {
24
+ yield ((_b = plugin.doExecuteCommand) === null || _b === void 0 ? void 0 : _b.call(plugin, originalCommand.command, originalCommand.arguments, executeCommandContext));
25
+ }
26
+ }
27
+ }
28
+ });
29
+ }
30
+ exports.register = register;
31
+ //# sourceMappingURL=executeCommand.js.map
@@ -0,0 +1,4 @@
1
+ import type { LanguageServiceRuntimeContext } from '../types';
2
+ import * as vscode from 'vscode-languageserver-protocol';
3
+ import { NullableResult } from '@volar/language-service';
4
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string) => NullableResult<vscode.Location[]>;
@@ -0,0 +1,37 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const shared = require("@volar/shared");
13
+ const featureWorkers_1 = require("../utils/featureWorkers");
14
+ const dedupe = require("../utils/dedupe");
15
+ function register(context) {
16
+ return (uri) => {
17
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, function* (_, sourceMap) {
18
+ yield _;
19
+ }, (plugin, document, _, sourceMap, vueDocument) => __awaiter(this, void 0, void 0, function* () {
20
+ var _a, _b;
21
+ return (_b = yield ((_a = plugin.findFileReferences) === null || _a === void 0 ? void 0 : _a.call(plugin, document))) !== null && _b !== void 0 ? _b : [];
22
+ }), (data, sourceMap) => data.map(reference => {
23
+ var _a;
24
+ const referenceSourceMap = context.documents.sourceMapFromEmbeddedDocumentUri(reference.uri);
25
+ if (referenceSourceMap) {
26
+ const range = (_a = referenceSourceMap.getSourceRange(reference.range.start, reference.range.end, data => !!data.references)) === null || _a === void 0 ? void 0 : _a[0];
27
+ if (!range)
28
+ return;
29
+ reference.uri = referenceSourceMap.sourceDocument.uri;
30
+ reference.range = range;
31
+ }
32
+ return reference;
33
+ }).filter(shared.notEmpty), arr => dedupe.withLocations(arr.flat()));
34
+ };
35
+ }
36
+ exports.register = register;
37
+ //# sourceMappingURL=fileReferences.js.map
@@ -0,0 +1,3 @@
1
+ import type { LanguageServiceRuntimeContext } from '../types';
2
+ import type * as _ from 'vscode-languageserver-protocol';
3
+ export declare function register(context: LanguageServiceRuntimeContext): (oldUri: string, newUri: string) => Promise<_.WorkspaceEdit | undefined>;
@@ -0,0 +1,36 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const rename_1 = require("./rename");
13
+ const dedupe = require("../utils/dedupe");
14
+ function register(context) {
15
+ return (oldUri, newUri) => __awaiter(this, void 0, void 0, function* () {
16
+ const vueDocument = context.documents.get(oldUri);
17
+ if (vueDocument) {
18
+ oldUri += '.ts';
19
+ newUri += '.ts';
20
+ }
21
+ for (const plugin of context.plugins) {
22
+ if (!plugin.doFileRename)
23
+ continue;
24
+ const workspaceEdit = yield plugin.doFileRename(oldUri, newUri);
25
+ if (workspaceEdit) {
26
+ const result = (0, rename_1.embeddedEditToSourceEdit)(workspaceEdit, context.documents);
27
+ if (result === null || result === void 0 ? void 0 : result.documentChanges) {
28
+ result.documentChanges = dedupe.withDocumentChanges(result.documentChanges);
29
+ }
30
+ return result;
31
+ }
32
+ }
33
+ });
34
+ }
35
+ exports.register = register;
36
+ //# sourceMappingURL=fileRename.js.map
@@ -0,0 +1,3 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { LanguageServiceRuntimeContext } from '../types';
3
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.register = void 0;
3
+ const vscode = require("vscode-languageserver-protocol");
4
+ const shared = require("@volar/shared");
5
+ const featureWorkers_1 = require("../utils/featureWorkers");
6
+ function register(context) {
7
+ return (uri, position) => {
8
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, function* (position, sourceMap) {
9
+ for (const [mappedRange] of sourceMap.getMappedRanges(position, position, data => !!data.hover)) {
10
+ yield mappedRange.start;
11
+ }
12
+ }, (plugin, document, position) => { var _a; return (_a = plugin.doHover) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position); }, (data, sourceMap) => {
13
+ var _a;
14
+ if (!sourceMap)
15
+ return data;
16
+ if (!data.range)
17
+ return data;
18
+ const range = (_a = sourceMap.getSourceRange(data.range.start, data.range.end)) === null || _a === void 0 ? void 0 : _a[0];
19
+ if (range) {
20
+ data.range = range;
21
+ return data;
22
+ }
23
+ }, hovers => {
24
+ var _a, _b;
25
+ return ({
26
+ contents: hovers.map(getHoverTexts).flat(),
27
+ range: (_b = (_a = hovers.find(hover => hover.range && shared.isInsideRange(hover.range, { start: position, end: position }))) === null || _a === void 0 ? void 0 : _a.range) !== null && _b !== void 0 ? _b : hovers[0].range,
28
+ });
29
+ });
30
+ };
31
+ }
32
+ exports.register = register;
33
+ function getHoverTexts(hover) {
34
+ if (!hover) {
35
+ return [];
36
+ }
37
+ if (typeof hover.contents === 'string') {
38
+ return [hover.contents];
39
+ }
40
+ if (vscode.MarkupContent.is(hover.contents)) {
41
+ return [hover.contents.value];
42
+ }
43
+ if (Array.isArray(hover.contents)) {
44
+ return hover.contents;
45
+ }
46
+ return [hover.contents.value];
47
+ }
48
+ //# sourceMappingURL=hover.js.map
@@ -0,0 +1,3 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { LanguageServiceRuntimeContext } from '../types';
3
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string, range: vscode.Range) => Promise<vscode.InlayHint[] | undefined>;
@@ -0,0 +1,65 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.register = void 0;
12
+ const shared = require("@volar/shared");
13
+ const transforms_1 = require("@volar/transforms");
14
+ const vscode = require("vscode-languageserver-protocol");
15
+ const featureWorkers_1 = require("../utils/featureWorkers");
16
+ function register(context) {
17
+ return (uri, range) => __awaiter(this, void 0, void 0, function* () {
18
+ const document = context.getTextDocument(uri);
19
+ if (!document)
20
+ return;
21
+ const offsetRange = {
22
+ start: document.offsetAt(range.start),
23
+ end: document.offsetAt(range.end),
24
+ };
25
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, range, (arg, sourceMap) => {
26
+ /**
27
+ * copy from ./codeActions.ts
28
+ */
29
+ var _a;
30
+ if (!sourceMap.embeddedFile.capabilities.inlayHints)
31
+ return [];
32
+ let minStart;
33
+ let maxEnd;
34
+ for (const mapping of sourceMap.base.mappings) {
35
+ const overlapRange = shared.getOverlapRange2(offsetRange, mapping.sourceRange);
36
+ if (overlapRange) {
37
+ const embeddedRange = (_a = sourceMap.getMappedRange(overlapRange.start, overlapRange.end)) === null || _a === void 0 ? void 0 : _a[0];
38
+ if (embeddedRange) {
39
+ minStart = minStart === undefined ? embeddedRange.start : Math.min(embeddedRange.start, minStart);
40
+ maxEnd = maxEnd === undefined ? embeddedRange.end : Math.max(embeddedRange.end, maxEnd);
41
+ }
42
+ }
43
+ }
44
+ if (minStart !== undefined && maxEnd !== undefined) {
45
+ return [vscode.Range.create(sourceMap.mappedDocument.positionAt(minStart), sourceMap.mappedDocument.positionAt(maxEnd))];
46
+ }
47
+ return [];
48
+ }, (plugin, document, arg, sourceMap) => {
49
+ var _a, _b;
50
+ return (_b = (_a = plugin.inlayHints) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, document, arg);
51
+ }, (inlayHints, sourceMap) => inlayHints.map(_inlayHint => {
52
+ var _a, _b;
53
+ if (!sourceMap)
54
+ return _inlayHint;
55
+ const position = (_a = sourceMap.getSourceRange(_inlayHint.position, _inlayHint.position, data => !!data.completion)) === null || _a === void 0 ? void 0 : _a[0].start;
56
+ const edits = (_b = _inlayHint.textEdits) === null || _b === void 0 ? void 0 : _b.map(textEdit => (0, transforms_1.transformTextEdit)(textEdit, range => { var _a; return (_a = sourceMap.getSourceRange(range.start, range.end)) === null || _a === void 0 ? void 0 : _a[0]; })).filter(shared.notEmpty);
57
+ if (position) {
58
+ return Object.assign(Object.assign({}, _inlayHint), { position,
59
+ edits });
60
+ }
61
+ }).filter(shared.notEmpty), arr => arr.flat());
62
+ });
63
+ }
64
+ exports.register = register;
65
+ //# sourceMappingURL=inlayHints.js.map
@@ -0,0 +1,3 @@
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { LanguageServiceRuntimeContext } from '../types';
3
+ export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;