@volar/language-service 1.4.0-alpha.0 → 1.4.0-alpha.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.
Files changed (73) hide show
  1. package/out/baseLanguageService.d.ts +31 -31
  2. package/out/baseLanguageService.js +20 -16
  3. package/out/documentFeatures/colorPresentations.d.ts +1 -1
  4. package/out/documentFeatures/colorPresentations.js +3 -3
  5. package/out/documentFeatures/documentColors.d.ts +1 -1
  6. package/out/documentFeatures/documentColors.js +2 -3
  7. package/out/documentFeatures/documentSymbols.d.ts +1 -1
  8. package/out/documentFeatures/documentSymbols.js +6 -16
  9. package/out/documentFeatures/foldingRanges.d.ts +2 -2
  10. package/out/documentFeatures/foldingRanges.js +3 -3
  11. package/out/documentFeatures/format.d.ts +1 -1
  12. package/out/documentFeatures/format.js +29 -42
  13. package/out/documentFeatures/linkedEditingRanges.d.ts +1 -1
  14. package/out/documentFeatures/linkedEditingRanges.js +3 -3
  15. package/out/documentFeatures/selectionRanges.d.ts +1 -1
  16. package/out/documentFeatures/selectionRanges.js +3 -3
  17. package/out/documents.js +28 -16
  18. package/out/languageFeatures/autoInsert.d.ts +1 -1
  19. package/out/languageFeatures/autoInsert.js +9 -7
  20. package/out/languageFeatures/callHierarchy.d.ts +2 -2
  21. package/out/languageFeatures/callHierarchy.js +65 -73
  22. package/out/languageFeatures/codeActionResolve.d.ts +2 -2
  23. package/out/languageFeatures/codeActionResolve.js +10 -19
  24. package/out/languageFeatures/codeActions.d.ts +1 -1
  25. package/out/languageFeatures/codeActions.js +22 -28
  26. package/out/languageFeatures/codeLens.d.ts +1 -1
  27. package/out/languageFeatures/codeLens.js +16 -24
  28. package/out/languageFeatures/codeLensResolve.d.ts +1 -1
  29. package/out/languageFeatures/codeLensResolve.js +8 -17
  30. package/out/languageFeatures/complete.d.ts +1 -1
  31. package/out/languageFeatures/complete.js +18 -33
  32. package/out/languageFeatures/completeResolve.d.ts +1 -1
  33. package/out/languageFeatures/completeResolve.js +6 -15
  34. package/out/languageFeatures/definition.d.ts +1 -1
  35. package/out/languageFeatures/definition.js +37 -45
  36. package/out/languageFeatures/documentHighlights.d.ts +1 -1
  37. package/out/languageFeatures/documentHighlights.js +32 -40
  38. package/out/languageFeatures/documentLinks.d.ts +1 -1
  39. package/out/languageFeatures/documentLinks.js +10 -17
  40. package/out/languageFeatures/documentSemanticTokens.d.ts +1 -1
  41. package/out/languageFeatures/documentSemanticTokens.js +6 -16
  42. package/out/languageFeatures/fileReferences.d.ts +1 -1
  43. package/out/languageFeatures/fileReferences.js +5 -14
  44. package/out/languageFeatures/fileRename.d.ts +1 -2
  45. package/out/languageFeatures/fileRename.js +6 -15
  46. package/out/languageFeatures/hover.d.ts +1 -1
  47. package/out/languageFeatures/hover.js +6 -10
  48. package/out/languageFeatures/inlayHints.d.ts +1 -1
  49. package/out/languageFeatures/inlayHints.js +13 -19
  50. package/out/languageFeatures/references.d.ts +1 -1
  51. package/out/languageFeatures/references.js +28 -39
  52. package/out/languageFeatures/rename.d.ts +1 -1
  53. package/out/languageFeatures/rename.js +55 -69
  54. package/out/languageFeatures/renamePrepare.d.ts +1 -1
  55. package/out/languageFeatures/renamePrepare.js +2 -3
  56. package/out/languageFeatures/signatureHelp.d.ts +1 -1
  57. package/out/languageFeatures/signatureHelp.js +8 -10
  58. package/out/languageFeatures/validation.d.ts +1 -1
  59. package/out/languageFeatures/validation.js +134 -152
  60. package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
  61. package/out/languageFeatures/workspaceSymbols.js +3 -12
  62. package/out/transformer/completionItem.js +8 -3
  63. package/out/transformer/completionList.js +6 -3
  64. package/out/transformer/documentSymbol.js +8 -3
  65. package/out/transformer/foldingRanges.js +2 -3
  66. package/out/transformer/hover.js +5 -2
  67. package/out/transformer/locationLike.js +4 -1
  68. package/out/transformer/textEdit.js +20 -5
  69. package/out/transformer/workspaceSymbol.js +4 -1
  70. package/out/types.d.ts +3 -3
  71. package/out/utils/definePlugin.js +11 -23
  72. package/out/utils/featureWorkers.js +126 -146
  73. package/package.json +4 -4
@@ -1,12 +1,3 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
12
3
  const transformer = require("../transformer");
@@ -14,14 +5,10 @@ const vscode = require("vscode-languageserver-protocol");
14
5
  const definePlugin_1 = require("../utils/definePlugin");
15
6
  function register(context) {
16
7
  let cache;
17
- return (uri, position, completionContext, token) => __awaiter(this, void 0, void 0, function* () {
18
- var _a, _b;
19
- completionContext !== null && completionContext !== void 0 ? completionContext : (completionContext = {
20
- triggerKind: vscode.CompletionTriggerKind.Invoked,
21
- });
8
+ return async (uri, position, completionContext = { triggerKind: vscode.CompletionTriggerKind.Invoked, }, token = vscode.CancellationToken.None) => {
22
9
  let document;
23
- if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerKind) === vscode.CompletionTriggerKind.TriggerForIncompleteCompletions
24
- && (cache === null || cache === void 0 ? void 0 : cache.uri) === uri) {
10
+ if (completionContext?.triggerKind === vscode.CompletionTriggerKind.TriggerForIncompleteCompletions
11
+ && cache?.uri === uri) {
25
12
  for (const cacheData of cache.data) {
26
13
  if (!cacheData.list.isIncomplete)
27
14
  continue;
@@ -30,7 +17,7 @@ function register(context) {
30
17
  for (const mapped of map.toGeneratedPositions(position, data => !!data.completion)) {
31
18
  if (!cacheData.plugin.provideCompletionItems)
32
19
  continue;
33
- const embeddedCompletionList = yield cacheData.plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
20
+ const embeddedCompletionList = await cacheData.plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
34
21
  if (!embeddedCompletionList) {
35
22
  cacheData.list.isIncomplete = false;
36
23
  continue;
@@ -53,7 +40,7 @@ function register(context) {
53
40
  else if (document = context.getTextDocument(uri)) {
54
41
  if (!cacheData.plugin.provideCompletionItems)
55
42
  continue;
56
- const completionList = yield cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
43
+ const completionList = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
57
44
  if (!completionList) {
58
45
  cacheData.list.isIncomplete = false;
59
46
  continue;
@@ -74,7 +61,7 @@ function register(context) {
74
61
  }
75
62
  }
76
63
  else {
77
- const rootFile = (_a = context.documents.getSourceByUri(uri)) === null || _a === void 0 ? void 0 : _a.root;
64
+ const rootFile = context.documents.getSourceByUri(uri)?.root;
78
65
  cache = {
79
66
  uri,
80
67
  data: [],
@@ -83,8 +70,7 @@ function register(context) {
83
70
  // monky fix https://github.com/johnsoncodehk/volar/issues/1358
84
71
  let isFirstMapping = true;
85
72
  if (rootFile) {
86
- yield (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, (_, map) => __awaiter(this, void 0, void 0, function* () {
87
- var _c;
73
+ await (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, async (_, map) => {
88
74
  const plugins = Object.values(context.plugins).sort(sortPlugins);
89
75
  let _data;
90
76
  for (const mapped of map.toGeneratedPositions(position, data => {
@@ -98,18 +84,18 @@ function register(context) {
98
84
  continue;
99
85
  if (plugin.isAdditionalCompletion && !isFirstMapping)
100
86
  continue;
101
- if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) && !((_c = plugin.triggerCharacters) === null || _c === void 0 ? void 0 : _c.includes(completionContext.triggerCharacter)))
87
+ if (completionContext?.triggerCharacter && !plugin.triggerCharacters?.includes(completionContext.triggerCharacter))
102
88
  continue;
103
89
  const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.additional || plugin.isAdditionalCompletion;
104
- if (cache.mainCompletion && (!isAdditional || (cache === null || cache === void 0 ? void 0 : cache.mainCompletion.documentUri) !== map.virtualFileDocument.uri))
90
+ if (cache.mainCompletion && (!isAdditional || cache?.mainCompletion.documentUri !== map.virtualFileDocument.uri))
105
91
  continue;
106
92
  // avoid duplicate items with .vue and .vue.html
107
- if (plugin.isAdditionalCompletion && (cache === null || cache === void 0 ? void 0 : cache.data.some(data => data.plugin === plugin)))
93
+ if (plugin.isAdditionalCompletion && cache?.data.some(data => data.plugin === plugin))
108
94
  continue;
109
- const embeddedCompletionList = yield plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
95
+ const embeddedCompletionList = await plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
110
96
  if (!embeddedCompletionList || !embeddedCompletionList.items.length)
111
97
  continue;
112
- if (typeof (_data === null || _data === void 0 ? void 0 : _data.completion) === 'object' && _data.completion.autoImportOnly) {
98
+ if (typeof _data?.completion === 'object' && _data.completion.autoImportOnly) {
113
99
  embeddedCompletionList.items = embeddedCompletionList.items.filter(item => !!item.labelDetails);
114
100
  }
115
101
  if (!isAdditional) {
@@ -138,7 +124,7 @@ function register(context) {
138
124
  isFirstMapping = false;
139
125
  }
140
126
  return true;
141
- }));
127
+ });
142
128
  }
143
129
  if (document = context.getTextDocument(uri)) {
144
130
  const plugins = Object.values(context.plugins).sort(sortPlugins);
@@ -149,14 +135,14 @@ function register(context) {
149
135
  continue;
150
136
  if (plugin.isAdditionalCompletion && !isFirstMapping)
151
137
  continue;
152
- if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) && !((_b = plugin.triggerCharacters) === null || _b === void 0 ? void 0 : _b.includes(completionContext.triggerCharacter)))
138
+ if (completionContext?.triggerCharacter && !plugin.triggerCharacters?.includes(completionContext.triggerCharacter))
153
139
  continue;
154
140
  if (cache.mainCompletion && (!plugin.isAdditionalCompletion || cache.mainCompletion.documentUri !== document.uri))
155
141
  continue;
156
142
  // avoid duplicate items with .vue and .vue.html
157
- if (plugin.isAdditionalCompletion && (cache === null || cache === void 0 ? void 0 : cache.data.some(data => data.plugin === plugin)))
143
+ if (plugin.isAdditionalCompletion && cache?.data.some(data => data.plugin === plugin))
158
144
  continue;
159
- const completionList = yield plugin.provideCompletionItems(document, position, completionContext, token);
145
+ const completionList = await plugin.provideCompletionItems(document, position, completionContext, token);
160
146
  if (!completionList || !completionList.items.length)
161
147
  continue;
162
148
  if (!plugin.isAdditionalCompletion) {
@@ -187,14 +173,13 @@ function register(context) {
187
173
  return (b.isAdditionalCompletion ? -1 : 1) - (a.isAdditionalCompletion ? -1 : 1);
188
174
  }
189
175
  function combineCompletionList(lists) {
190
- var _a;
191
176
  return {
192
177
  isIncomplete: lists.some(list => list.isIncomplete),
193
- itemDefaults: (_a = lists.find(list => list.itemDefaults)) === null || _a === void 0 ? void 0 : _a.itemDefaults,
178
+ itemDefaults: lists.find(list => list.itemDefaults)?.itemDefaults,
194
179
  items: lists.map(list => list.items).flat(),
195
180
  };
196
181
  }
197
- });
182
+ };
198
183
  }
199
184
  exports.register = register;
200
185
  //# sourceMappingURL=complete.js.map
@@ -1,3 +1,3 @@
1
1
  import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
- export declare function register(context: LanguageServicePluginContext): (item: vscode.CompletionItem, token: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
3
+ export declare function register(context: LanguageServicePluginContext): (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
@@ -1,17 +1,9 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
12
3
  const transformer = require("../transformer");
4
+ const vscode = require("vscode-languageserver-protocol");
13
5
  function register(context) {
14
- return (item, token) => __awaiter(this, void 0, void 0, function* () {
6
+ return async (item, token = vscode.CancellationToken.None) => {
15
7
  const data = item.data;
16
8
  if (data) {
17
9
  const plugin = context.plugins[data.pluginId];
@@ -20,10 +12,9 @@ function register(context) {
20
12
  item = Object.assign(item, data.original);
21
13
  if (data.map) {
22
14
  for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
23
- item = yield plugin.resolveCompletionItem(item, token);
15
+ item = await plugin.resolveCompletionItem(item, token);
24
16
  item = transformer.asCompletionItem(item, embeddedRange => {
25
- var _a;
26
- let range = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange);
17
+ let range = plugin.resolveEmbeddedRange?.(embeddedRange);
27
18
  if (range)
28
19
  return range;
29
20
  return map.toSourceRange(embeddedRange);
@@ -31,7 +22,7 @@ function register(context) {
31
22
  }
32
23
  }
33
24
  else {
34
- item = yield plugin.resolveCompletionItem(item, token);
25
+ item = await plugin.resolveCompletionItem(item, token);
35
26
  }
36
27
  }
37
28
  // TODO: monkey fix import ts file icon
@@ -39,7 +30,7 @@ function register(context) {
39
30
  item.detail = item.detail;
40
31
  }
41
32
  return item;
42
- });
33
+ };
43
34
  }
44
35
  exports.register = register;
45
36
  //# sourceMappingURL=completeResolve.js.map
@@ -1,4 +1,4 @@
1
1
  import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
3
  import { FileRangeCapabilities, MirrorBehaviorCapabilities } from '@volar/language-core';
4
- export declare function register(context: LanguageServicePluginContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidMapping: (data: FileRangeCapabilities) => boolean, isValidMirrorPosition: (mirrorData: MirrorBehaviorCapabilities) => boolean): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
4
+ export declare function register(context: LanguageServicePluginContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidMapping: (data: FileRangeCapabilities) => boolean, isValidMirrorPosition: (mirrorData: MirrorBehaviorCapabilities) => boolean): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
@@ -1,62 +1,54 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
3
+ const vscode = require("vscode-languageserver-protocol");
12
4
  const featureWorkers_1 = require("../utils/featureWorkers");
13
5
  const dedupe = require("../utils/dedupe");
14
6
  const common_1 = require("../utils/common");
15
7
  function register(context, apiName, isValidMapping, isValidMirrorPosition) {
16
- return (uri, position, token) => {
17
- return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
8
+ return (uri, position, token = vscode.CancellationToken.None) => {
9
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), async (plugin, document, position) => {
18
10
  if (token.isCancellationRequested)
19
11
  return;
20
12
  const recursiveChecker = dedupe.createLocationSet();
21
13
  const result = [];
22
- yield withMirrors(document, position, undefined);
14
+ await withMirrors(document, position, undefined);
23
15
  return result;
24
- function withMirrors(document, position, originDefinition) {
25
- var _a, _b;
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const api = plugin[apiName];
28
- if (!api)
29
- return;
30
- if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
31
- return;
32
- recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
33
- const definitions = (_a = yield (api === null || api === void 0 ? void 0 : api(document, position, token))) !== null && _a !== void 0 ? _a : [];
34
- for (const definition of definitions) {
35
- let foundMirrorPosition = false;
36
- recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
37
- const mirrorMap = (_b = context.documents.getMirrorMapByUri(definition.targetUri)) === null || _b === void 0 ? void 0 : _b[1];
38
- if (mirrorMap) {
39
- for (const mapped of mirrorMap.findMirrorPositions(definition.targetSelectionRange.start)) {
40
- if (!isValidMirrorPosition(mapped[1]))
41
- continue;
42
- if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
43
- continue;
44
- foundMirrorPosition = true;
45
- yield withMirrors(mirrorMap.document, mapped[0], originDefinition !== null && originDefinition !== void 0 ? originDefinition : definition);
46
- }
16
+ async function withMirrors(document, position, originDefinition) {
17
+ const api = plugin[apiName];
18
+ if (!api)
19
+ return;
20
+ if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
21
+ return;
22
+ recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
23
+ const definitions = await api?.(document, position, token) ?? [];
24
+ for (const definition of definitions) {
25
+ let foundMirrorPosition = false;
26
+ recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
27
+ const mirrorMap = context.documents.getMirrorMapByUri(definition.targetUri)?.[1];
28
+ if (mirrorMap) {
29
+ for (const mapped of mirrorMap.findMirrorPositions(definition.targetSelectionRange.start)) {
30
+ if (!isValidMirrorPosition(mapped[1]))
31
+ continue;
32
+ if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
33
+ continue;
34
+ foundMirrorPosition = true;
35
+ await withMirrors(mirrorMap.document, mapped[0], originDefinition ?? definition);
36
+ }
37
+ }
38
+ if (!foundMirrorPosition) {
39
+ if (originDefinition) {
40
+ result.push({
41
+ ...definition,
42
+ originSelectionRange: originDefinition.originSelectionRange,
43
+ });
47
44
  }
48
- if (!foundMirrorPosition) {
49
- if (originDefinition) {
50
- result.push(Object.assign(Object.assign({}, definition), { originSelectionRange: originDefinition.originSelectionRange }));
51
- }
52
- else {
53
- result.push(definition);
54
- }
45
+ else {
46
+ result.push(definition);
55
47
  }
56
48
  }
57
- });
49
+ }
58
50
  }
59
- }), (data, sourceMap) => data.map(link => {
51
+ }, (data, sourceMap) => data.map(link => {
60
52
  if (link.originSelectionRange && sourceMap) {
61
53
  const originSelectionRange = toSourcePositionPreferSurroundedPosition(sourceMap, link.originSelectionRange, position);
62
54
  if (!originSelectionRange)
@@ -72,7 +64,7 @@ function register(context, apiName, isValidMapping, isValidMirrorPosition) {
72
64
  let targetRange = targetSourceMap.toSourceRange(link.targetRange);
73
65
  link.targetUri = targetSourceMap.sourceFileDocument.uri;
74
66
  // loose range mapping to for template slots, slot properties
75
- link.targetRange = targetRange !== null && targetRange !== void 0 ? targetRange : targetSelectionRange;
67
+ link.targetRange = targetRange ?? targetSelectionRange;
76
68
  link.targetSelectionRange = targetSelectionRange;
77
69
  }
78
70
  if (context.documents.hasVirtualFileByUri(link.targetUri) && !foundTargetSelectionRange) {
@@ -1,3 +1,3 @@
1
1
  import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
- export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
3
+ export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
@@ -1,63 +1,55 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
3
+ const vscode = require("vscode-languageserver-protocol");
12
4
  const featureWorkers_1 = require("../utils/featureWorkers");
13
5
  const dedupe = require("../utils/dedupe");
14
6
  const common_1 = require("../utils/common");
15
7
  function register(context) {
16
- return (uri, position, token) => {
8
+ return (uri, position, token = vscode.CancellationToken.None) => {
17
9
  return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position,
18
10
  // note https://github.com/johnsoncodehk/volar/issues/2009
19
- data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
11
+ data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), async (plugin, document, position) => {
20
12
  if (token.isCancellationRequested)
21
13
  return;
22
14
  const recursiveChecker = dedupe.createLocationSet();
23
15
  const result = [];
24
- yield withMirrors(document, position);
16
+ await withMirrors(document, position);
25
17
  return result;
26
- function withMirrors(document, position) {
27
- var _a, _b;
28
- return __awaiter(this, void 0, void 0, function* () {
29
- if (!plugin.provideDocumentHighlights)
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.provideDocumentHighlights(document, position, token)) !== null && _a !== void 0 ? _a : [];
35
- for (const reference of references) {
36
- let foundMirrorPosition = false;
37
- recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
38
- const mirrorMap = (_b = context.documents.getMirrorMapByUri(document.uri)) === null || _b === void 0 ? void 0 : _b[1];
39
- if (mirrorMap) {
40
- for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
41
- if (!mapped[1].references)
42
- continue;
43
- if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
44
- continue;
45
- foundMirrorPosition = true;
46
- yield withMirrors(mirrorMap.document, mapped[0]);
47
- }
48
- }
49
- if (!foundMirrorPosition) {
50
- result.push(reference);
18
+ async function withMirrors(document, position) {
19
+ if (!plugin.provideDocumentHighlights)
20
+ return;
21
+ if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
22
+ return;
23
+ recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
24
+ const references = await plugin.provideDocumentHighlights(document, position, token) ?? [];
25
+ for (const reference of references) {
26
+ let foundMirrorPosition = false;
27
+ recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
28
+ const mirrorMap = context.documents.getMirrorMapByUri(document.uri)?.[1];
29
+ if (mirrorMap) {
30
+ for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
31
+ if (!mapped[1].references)
32
+ continue;
33
+ if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
34
+ continue;
35
+ foundMirrorPosition = true;
36
+ await withMirrors(mirrorMap.document, mapped[0]);
51
37
  }
52
38
  }
53
- });
39
+ if (!foundMirrorPosition) {
40
+ result.push(reference);
41
+ }
42
+ }
54
43
  }
55
- }), (data, map) => data.map(highlight => {
44
+ }, (data, map) => data.map(highlight => {
56
45
  if (!map)
57
46
  return highlight;
58
47
  const range = map.toSourceRange(highlight.range);
59
48
  if (range) {
60
- return Object.assign(Object.assign({}, highlight), { range });
49
+ return {
50
+ ...highlight,
51
+ range,
52
+ };
61
53
  }
62
54
  }).filter(common_1.notEmpty), arr => arr.flat());
63
55
  };
@@ -1,3 +1,3 @@
1
1
  import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
- export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
3
+ export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
@@ -1,32 +1,25 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
3
+ const vscode = require("vscode-languageserver-protocol");
12
4
  const featureWorkers_1 = require("../utils/featureWorkers");
13
5
  const common_1 = require("../utils/common");
14
6
  function register(context) {
15
- return (uri, token) => __awaiter(this, void 0, void 0, function* () {
16
- var _a;
17
- const pluginLinks = (_a = yield (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => {
18
- var _a;
7
+ return async (uri, token = vscode.CancellationToken.None) => {
8
+ const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => {
19
9
  if (token.isCancellationRequested)
20
10
  return;
21
- return (_a = plugin.provideLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document, token);
11
+ return plugin.provideLinks?.(document, token);
22
12
  }, (data, map) => data.map(link => {
23
13
  if (!map)
24
14
  return link;
25
15
  const range = map.toSourceRange(link.range);
26
16
  if (range) {
27
- return Object.assign(Object.assign({}, link), { range });
17
+ return {
18
+ ...link,
19
+ range,
20
+ };
28
21
  }
29
- }).filter(common_1.notEmpty), arr => arr.flat())) !== null && _a !== void 0 ? _a : [];
22
+ }).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
30
23
  const maps = context.documents.getMapsBySourceFileUri(uri);
31
24
  const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
32
25
  return [
@@ -52,7 +45,7 @@ function register(context) {
52
45
  }
53
46
  return result;
54
47
  }
55
- });
48
+ };
56
49
  }
57
50
  exports.register = register;
58
51
  //# sourceMappingURL=documentLinks.js.map
@@ -1,3 +1,3 @@
1
1
  import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
- export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
3
+ export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
@@ -1,12 +1,3 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
12
3
  const vscode = require("vscode-languageserver-protocol");
@@ -14,7 +5,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
14
5
  const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");
15
6
  const common_1 = require("../utils/common");
16
7
  function register(context) {
17
- return (uri, range, legend, token, reportProgress) => __awaiter(this, void 0, void 0, function* () {
8
+ return async (uri, range, legend, token = vscode.CancellationToken.None, reportProgress) => {
18
9
  const document = context.getTextDocument(uri);
19
10
  if (!document)
20
11
  return;
@@ -25,7 +16,7 @@ function register(context) {
25
16
  0,
26
17
  document.getText().length,
27
18
  ];
28
- const tokens = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange, map) {
19
+ const tokens = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange, map) {
29
20
  let range;
30
21
  for (const mapping of map.map.mappings) {
31
22
  if (mapping.data.semanticTokens
@@ -44,10 +35,9 @@ function register(context) {
44
35
  yield range;
45
36
  }
46
37
  }, (plugin, document, offsetRange) => {
47
- var _a;
48
- if (token === null || token === void 0 ? void 0 : token.isCancellationRequested)
38
+ if (token?.isCancellationRequested)
49
39
  return;
50
- return (_a = plugin.provideDocumentSemanticTokens) === null || _a === void 0 ? void 0 : _a.call(plugin, document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])), legend, token);
40
+ return plugin.provideDocumentSemanticTokens?.(document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])), legend, token);
51
41
  }, (tokens, map) => tokens.map(_token => {
52
42
  if (!map)
53
43
  return _token;
@@ -58,11 +48,11 @@ function register(context) {
58
48
  if (range) {
59
49
  return [range.start.line, range.start.character, _token[2], _token[3], _token[4]];
60
50
  }
61
- }).filter(common_1.notEmpty), tokens => tokens.flat(), tokens => reportProgress === null || reportProgress === void 0 ? void 0 : reportProgress(buildTokens(tokens)));
51
+ }).filter(common_1.notEmpty), tokens => tokens.flat(), tokens => reportProgress?.(buildTokens(tokens)));
62
52
  if (tokens) {
63
53
  return buildTokens(tokens);
64
54
  }
65
- });
55
+ };
66
56
  }
67
57
  exports.register = register;
68
58
  function buildTokens(tokens) {
@@ -1,4 +1,4 @@
1
1
  import type { LanguageServicePluginContext } from '../types';
2
2
  import * as vscode from 'vscode-languageserver-protocol';
3
3
  import { NullableResult } from '@volar/language-service';
4
- export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken) => NullableResult<vscode.Location[]>;
4
+ export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => NullableResult<vscode.Location[]>;
@@ -1,27 +1,18 @@
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
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
12
3
  const featureWorkers_1 = require("../utils/featureWorkers");
13
4
  const dedupe = require("../utils/dedupe");
5
+ const vscode = require("vscode-languageserver-protocol");
14
6
  const common_1 = require("../utils/common");
15
7
  function register(context) {
16
- return (uri, token) => {
8
+ return (uri, token = vscode.CancellationToken.None) => {
17
9
  return (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, function* (_) {
18
10
  yield _;
19
- }, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
20
- var _a, _b;
11
+ }, async (plugin, document) => {
21
12
  if (token.isCancellationRequested)
22
13
  return;
23
- return (_b = yield ((_a = plugin.provideFileReferences) === null || _a === void 0 ? void 0 : _a.call(plugin, document, token))) !== null && _b !== void 0 ? _b : [];
24
- }), (data) => data.map(reference => {
14
+ return await plugin.provideFileReferences?.(document, token) ?? [];
15
+ }, (data) => data.map(reference => {
25
16
  if (!context.documents.hasVirtualFileByUri(reference.uri)) {
26
17
  return reference;
27
18
  }
@@ -1,4 +1,3 @@
1
1
  import type { LanguageServicePluginContext } from '../types';
2
2
  import type * as _ from 'vscode-languageserver-protocol';
3
- import type * as vscode from 'vscode-languageserver-protocol';
4
- export declare function register(context: LanguageServicePluginContext): (oldUri: string, newUri: string, token: vscode.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
3
+ export declare function register(context: LanguageServicePluginContext): (oldUri: string, newUri: string, token?: _.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;