@volar/language-service 1.4.0-alpha.0 → 1.4.0-alpha.1

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 (44) hide show
  1. package/out/baseLanguageService.d.ts +1 -1
  2. package/out/baseLanguageService.js +20 -16
  3. package/out/documentFeatures/colorPresentations.js +1 -2
  4. package/out/documentFeatures/documentColors.js +1 -2
  5. package/out/documentFeatures/documentSymbols.js +4 -15
  6. package/out/documentFeatures/foldingRanges.js +1 -2
  7. package/out/documentFeatures/format.js +29 -42
  8. package/out/documentFeatures/linkedEditingRanges.js +1 -2
  9. package/out/documentFeatures/selectionRanges.js +1 -2
  10. package/out/documents.js +1 -2
  11. package/out/languageFeatures/autoInsert.js +7 -6
  12. package/out/languageFeatures/callHierarchy.js +63 -72
  13. package/out/languageFeatures/codeActionResolve.js +9 -19
  14. package/out/languageFeatures/codeActions.js +22 -28
  15. package/out/languageFeatures/codeLens.js +16 -24
  16. package/out/languageFeatures/codeLensResolve.js +7 -17
  17. package/out/languageFeatures/complete.js +20 -32
  18. package/out/languageFeatures/completeResolve.js +5 -15
  19. package/out/languageFeatures/definition.js +35 -44
  20. package/out/languageFeatures/documentHighlights.js +30 -39
  21. package/out/languageFeatures/documentLinks.js +9 -17
  22. package/out/languageFeatures/documentSemanticTokens.js +6 -16
  23. package/out/languageFeatures/fileReferences.js +3 -13
  24. package/out/languageFeatures/fileRename.js +5 -15
  25. package/out/languageFeatures/hover.js +5 -9
  26. package/out/languageFeatures/inlayHints.js +13 -19
  27. package/out/languageFeatures/references.js +26 -38
  28. package/out/languageFeatures/rename.js +54 -68
  29. package/out/languageFeatures/renamePrepare.js +1 -2
  30. package/out/languageFeatures/signatureHelp.js +6 -7
  31. package/out/languageFeatures/validation.js +134 -152
  32. package/out/languageFeatures/workspaceSymbols.js +3 -12
  33. package/out/transformer/completionItem.js +8 -3
  34. package/out/transformer/completionList.js +6 -3
  35. package/out/transformer/documentSymbol.js +8 -3
  36. package/out/transformer/foldingRanges.js +2 -3
  37. package/out/transformer/hover.js +5 -2
  38. package/out/transformer/locationLike.js +4 -1
  39. package/out/transformer/textEdit.js +20 -5
  40. package/out/transformer/workspaceSymbol.js +4 -1
  41. package/out/types.d.ts +3 -3
  42. package/out/utils/definePlugin.js +11 -23
  43. package/out/utils/featureWorkers.js +126 -146
  44. 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 featureWorkers_1 = require("../utils/featureWorkers");
@@ -16,48 +7,48 @@ function register(context) {
16
7
  return (uri, position, token) => {
17
8
  return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position,
18
9
  // 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* () {
10
+ data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), async (plugin, document, position) => {
20
11
  if (token.isCancellationRequested)
21
12
  return;
22
13
  const recursiveChecker = dedupe.createLocationSet();
23
14
  const result = [];
24
- yield withMirrors(document, position);
15
+ await withMirrors(document, position);
25
16
  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);
17
+ async function withMirrors(document, position) {
18
+ if (!plugin.provideDocumentHighlights)
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 references = await plugin.provideDocumentHighlights(document, position, token) ?? [];
24
+ for (const reference of references) {
25
+ let foundMirrorPosition = false;
26
+ recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
27
+ const mirrorMap = context.documents.getMirrorMapByUri(document.uri)?.[1];
28
+ if (mirrorMap) {
29
+ for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
30
+ if (!mapped[1].references)
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]);
51
36
  }
52
37
  }
53
- });
38
+ if (!foundMirrorPosition) {
39
+ result.push(reference);
40
+ }
41
+ }
54
42
  }
55
- }), (data, map) => data.map(highlight => {
43
+ }, (data, map) => data.map(highlight => {
56
44
  if (!map)
57
45
  return highlight;
58
46
  const range = map.toSourceRange(highlight.range);
59
47
  if (range) {
60
- return Object.assign(Object.assign({}, highlight), { range });
48
+ return {
49
+ ...highlight,
50
+ range,
51
+ };
61
52
  }
62
53
  }).filter(common_1.notEmpty), arr => arr.flat());
63
54
  };
@@ -1,32 +1,24 @@
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 common_1 = require("../utils/common");
14
5
  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;
6
+ return async (uri, token) => {
7
+ const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => {
19
8
  if (token.isCancellationRequested)
20
9
  return;
21
- return (_a = plugin.provideLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document, token);
10
+ return plugin.provideLinks?.(document, token);
22
11
  }, (data, map) => data.map(link => {
23
12
  if (!map)
24
13
  return link;
25
14
  const range = map.toSourceRange(link.range);
26
15
  if (range) {
27
- return Object.assign(Object.assign({}, link), { range });
16
+ return {
17
+ ...link,
18
+ range,
19
+ };
28
20
  }
29
- }).filter(common_1.notEmpty), arr => arr.flat())) !== null && _a !== void 0 ? _a : [];
21
+ }).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
30
22
  const maps = context.documents.getMapsBySourceFileUri(uri);
31
23
  const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
32
24
  return [
@@ -52,7 +44,7 @@ function register(context) {
52
44
  }
53
45
  return result;
54
46
  }
55
- });
47
+ };
56
48
  }
57
49
  exports.register = register;
58
50
  //# sourceMappingURL=documentLinks.js.map
@@ -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, 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,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 featureWorkers_1 = require("../utils/featureWorkers");
@@ -16,12 +7,11 @@ function register(context) {
16
7
  return (uri, token) => {
17
8
  return (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, function* (_) {
18
9
  yield _;
19
- }, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
20
- var _a, _b;
10
+ }, async (plugin, document) => {
21
11
  if (token.isCancellationRequested)
22
12
  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 => {
13
+ return await plugin.provideFileReferences?.(document, token) ?? [];
14
+ }, (data) => data.map(reference => {
25
15
  if (!context.documents.hasVirtualFileByUri(reference.uri)) {
26
16
  return reference;
27
17
  }
@@ -1,21 +1,11 @@
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 rename_1 = require("./rename");
13
4
  const dedupe = require("../utils/dedupe");
14
5
  const language_core_1 = require("@volar/language-core");
15
6
  function register(context) {
16
- return (oldUri, newUri, token) => __awaiter(this, void 0, void 0, function* () {
17
- var _a;
18
- const rootFile = (_a = context.documents.getSourceByUri(oldUri)) === null || _a === void 0 ? void 0 : _a.root;
7
+ return async (oldUri, newUri, token) => {
8
+ const rootFile = context.documents.getSourceByUri(oldUri)?.root;
19
9
  if (rootFile) {
20
10
  let tsExt;
21
11
  (0, language_core_1.forEachEmbeddedFile)(rootFile, embedded => {
@@ -34,16 +24,16 @@ function register(context) {
34
24
  break;
35
25
  if (!plugin.provideFileRenameEdits)
36
26
  continue;
37
- const workspaceEdit = yield plugin.provideFileRenameEdits(oldUri, newUri, token);
27
+ const workspaceEdit = await plugin.provideFileRenameEdits(oldUri, newUri, token);
38
28
  if (workspaceEdit) {
39
29
  const result = (0, rename_1.embeddedEditToSourceEdit)(workspaceEdit, context.documents, 'fileName');
40
- if (result === null || result === void 0 ? void 0 : result.documentChanges) {
30
+ if (result?.documentChanges) {
41
31
  result.documentChanges = dedupe.withDocumentChanges(result.documentChanges);
42
32
  }
43
33
  return result;
44
34
  }
45
35
  }
46
- });
36
+ };
47
37
  }
48
38
  exports.register = register;
49
39
  //# sourceMappingURL=fileRename.js.map
@@ -6,10 +6,9 @@ const common_1 = require("../utils/common");
6
6
  function register(context) {
7
7
  return (uri, position, token) => {
8
8
  return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (plugin, document, position) => {
9
- var _a;
10
9
  if (token.isCancellationRequested)
11
10
  return;
12
- return (_a = plugin.provideHover) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, token);
11
+ return plugin.provideHover?.(document, position, token);
13
12
  }, (item, map) => {
14
13
  if (!map || !item.range)
15
14
  return item;
@@ -18,13 +17,10 @@ function register(context) {
18
17
  item.range = range;
19
18
  return item;
20
19
  }
21
- }, hovers => {
22
- var _a, _b;
23
- return ({
24
- contents: hovers.map(getHoverTexts).flat(),
25
- range: (_b = (_a = hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))) === null || _a === void 0 ? void 0 : _a.range) !== null && _b !== void 0 ? _b : hovers[0].range,
26
- });
27
- });
20
+ }, hovers => ({
21
+ contents: hovers.map(getHoverTexts).flat(),
22
+ range: hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))?.range ?? hovers[0].range,
23
+ }));
28
24
  };
29
25
  }
30
26
  exports.register = register;
@@ -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,7 +5,7 @@ const vscode = require("vscode-languageserver-protocol");
14
5
  const common_1 = require("../utils/common");
15
6
  const featureWorkers_1 = require("../utils/featureWorkers");
16
7
  function register(context) {
17
- return (uri, range, token) => __awaiter(this, void 0, void 0, function* () {
8
+ return async (uri, range, token) => {
18
9
  const document = context.getTextDocument(uri);
19
10
  if (!document)
20
11
  return;
@@ -26,7 +17,6 @@ function register(context) {
26
17
  /**
27
18
  * copy from ./codeActions.ts
28
19
  */
29
- var _a, _b;
30
20
  if (!file.capabilities.inlayHint)
31
21
  return [];
32
22
  let minStart;
@@ -34,8 +24,8 @@ function register(context) {
34
24
  for (const mapping of map.map.mappings) {
35
25
  const overlapRange = (0, common_1.getOverlapRange)(offsetRange.start, offsetRange.end, mapping.sourceRange[0], mapping.sourceRange[1]);
36
26
  if (overlapRange) {
37
- const start = (_a = map.map.toGeneratedOffset(overlapRange.start)) === null || _a === void 0 ? void 0 : _a[0];
38
- const end = (_b = map.map.toGeneratedOffset(overlapRange.end)) === null || _b === void 0 ? void 0 : _b[0];
27
+ const start = map.map.toGeneratedOffset(overlapRange.start)?.[0];
28
+ const end = map.map.toGeneratedOffset(overlapRange.end)?.[0];
39
29
  if (start !== undefined && end !== undefined) {
40
30
  minStart = minStart === undefined ? start : Math.min(start, minStart);
41
31
  maxEnd = maxEnd === undefined ? end : Math.max(end, maxEnd);
@@ -47,21 +37,25 @@ function register(context) {
47
37
  }
48
38
  return [];
49
39
  }, (plugin, document, arg) => {
50
- var _a;
51
40
  if (token.isCancellationRequested)
52
41
  return;
53
- return (_a = plugin.provideInlayHints) === null || _a === void 0 ? void 0 : _a.call(plugin, document, arg, token);
42
+ return plugin.provideInlayHints?.(document, arg, token);
54
43
  }, (inlayHints, map) => inlayHints.map((_inlayHint) => {
55
- var _a;
56
44
  if (!map)
57
45
  return _inlayHint;
58
46
  const position = map.toSourcePosition(_inlayHint.position);
59
- const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument)).filter(common_1.notEmpty);
47
+ const edits = _inlayHint.textEdits
48
+ ?.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument))
49
+ .filter(common_1.notEmpty);
60
50
  if (position) {
61
- return Object.assign(Object.assign({}, _inlayHint), { position, textEdits: edits });
51
+ return {
52
+ ..._inlayHint,
53
+ position,
54
+ textEdits: edits,
55
+ };
62
56
  }
63
57
  }).filter(common_1.notEmpty), arr => arr.flat());
64
- });
58
+ };
65
59
  }
66
60
  exports.register = register;
67
61
  //# sourceMappingURL=inlayHints.js.map
@@ -1,55 +1,43 @@
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");
14
5
  function register(context) {
15
6
  return (uri, position, token) => {
16
- return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
7
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), async (plugin, document, position) => {
17
8
  if (token.isCancellationRequested)
18
9
  return;
19
10
  const recursiveChecker = dedupe.createLocationSet();
20
11
  const result = [];
21
- yield withMirrors(document, position);
12
+ await withMirrors(document, position);
22
13
  return result;
23
- function withMirrors(document, position) {
24
- var _a, _b;
25
- return __awaiter(this, void 0, void 0, function* () {
26
- if (!plugin.provideReferences)
27
- return;
28
- if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
29
- return;
30
- recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
31
- const references = (_a = yield plugin.provideReferences(document, position, token)) !== null && _a !== void 0 ? _a : [];
32
- for (const reference of references) {
33
- let foundMirrorPosition = false;
34
- recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
35
- const mirrorMap = (_b = context.documents.getMirrorMapByUri(reference.uri)) === null || _b === void 0 ? void 0 : _b[1];
36
- if (mirrorMap) {
37
- for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
38
- if (!mapped[1].references)
39
- continue;
40
- if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
41
- continue;
42
- foundMirrorPosition = true;
43
- yield withMirrors(mirrorMap.document, mapped[0]);
44
- }
45
- }
46
- if (!foundMirrorPosition) {
47
- result.push(reference);
14
+ async function withMirrors(document, position) {
15
+ if (!plugin.provideReferences)
16
+ return;
17
+ if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
18
+ return;
19
+ recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
20
+ const references = await plugin.provideReferences(document, position, token) ?? [];
21
+ for (const reference of references) {
22
+ let foundMirrorPosition = false;
23
+ recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
24
+ const mirrorMap = context.documents.getMirrorMapByUri(reference.uri)?.[1];
25
+ if (mirrorMap) {
26
+ for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
27
+ if (!mapped[1].references)
28
+ continue;
29
+ if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
30
+ continue;
31
+ foundMirrorPosition = true;
32
+ await withMirrors(mirrorMap.document, mapped[0]);
48
33
  }
49
34
  }
50
- });
35
+ if (!foundMirrorPosition) {
36
+ result.push(reference);
37
+ }
38
+ }
51
39
  }
52
- }), (data) => {
40
+ }, (data) => {
53
41
  const results = [];
54
42
  for (const reference of data) {
55
43
  if (context.documents.hasVirtualFileByUri(reference.uri)) {