@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,4 +1,4 @@
1
- import type * as vscode from 'vscode-languageserver-protocol';
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
3
  export interface PluginCallHierarchyData {
4
4
  uri: string;
@@ -9,7 +9,7 @@ export interface PluginCallHierarchyData {
9
9
  } | undefined;
10
10
  }
11
11
  export declare function register(context: LanguageServicePluginContext): {
12
- doPrepare(uri: string, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
12
+ doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
13
13
  getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
14
14
  getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
15
15
  };
@@ -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 path_1 = require("path");
4
+ const vscode = require("vscode-languageserver-protocol");
13
5
  const common_1 = require("../utils/common");
14
6
  const dedupe = require("../utils/dedupe");
15
7
  const featureWorkers_1 = require("../utils/featureWorkers");
16
8
  function register(context) {
17
9
  return {
18
- doPrepare(uri, position, token) {
19
- return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), (plugin, document, position, map) => __awaiter(this, void 0, void 0, function* () {
20
- var _a;
10
+ doPrepare(uri, position, token = vscode.CancellationToken.None) {
11
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), async (plugin, document, position, map) => {
21
12
  if (token.isCancellationRequested)
22
13
  return;
23
- const items = yield ((_a = plugin.provideCallHierarchyItems) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, token));
24
- items === null || items === void 0 ? void 0 : items.forEach(item => {
14
+ const items = await plugin.provideCallHierarchyItems?.(document, position, token);
15
+ items?.forEach(item => {
25
16
  item.data = {
26
17
  uri,
27
18
  original: {
@@ -34,35 +25,21 @@ function register(context) {
34
25
  };
35
26
  });
36
27
  return items;
37
- }), (data, sourceMap) => !sourceMap ? data : data
38
- .map(item => { var _a; return (_a = transformCallHierarchyItem(item, [])) === null || _a === void 0 ? void 0 : _a[0]; })
28
+ }, (data, sourceMap) => !sourceMap ? data : data
29
+ .map(item => transformCallHierarchyItem(item, [])?.[0])
39
30
  .filter(common_1.notEmpty), arr => dedupe.withLocations(arr.flat()));
40
31
  },
41
- getIncomingCalls(item, token) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const data = item.data;
44
- let incomingItems = [];
45
- if (data) {
46
- const plugin = context.plugins[data.pluginId];
47
- if (!plugin.provideCallHierarchyIncomingCalls)
48
- return incomingItems;
49
- Object.assign(item, data.original);
50
- if (data.map) {
51
- if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
52
- const _calls = yield plugin.provideCallHierarchyIncomingCalls(item, token);
53
- for (const _call of _calls) {
54
- const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
55
- if (!calls)
56
- continue;
57
- incomingItems.push({
58
- from: calls[0],
59
- fromRanges: calls[1],
60
- });
61
- }
62
- }
63
- }
64
- else {
65
- const _calls = yield plugin.provideCallHierarchyIncomingCalls(item, token);
32
+ async getIncomingCalls(item, token) {
33
+ const data = item.data;
34
+ let incomingItems = [];
35
+ if (data) {
36
+ const plugin = context.plugins[data.pluginId];
37
+ if (!plugin.provideCallHierarchyIncomingCalls)
38
+ return incomingItems;
39
+ Object.assign(item, data.original);
40
+ if (data.map) {
41
+ if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
42
+ const _calls = await plugin.provideCallHierarchyIncomingCalls(item, token);
66
43
  for (const _call of _calls) {
67
44
  const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
68
45
  if (!calls)
@@ -74,34 +51,32 @@ function register(context) {
74
51
  }
75
52
  }
76
53
  }
77
- return dedupe.withCallHierarchyIncomingCalls(incomingItems);
78
- });
79
- },
80
- getOutgoingCalls(item, token) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- const data = item.data;
83
- let items = [];
84
- if (data) {
85
- const plugin = context.plugins[data.pluginId];
86
- if (!plugin.provideCallHierarchyOutgoingCalls)
87
- return items;
88
- Object.assign(item, data.original);
89
- if (data.map) {
90
- if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
91
- const _calls = yield plugin.provideCallHierarchyOutgoingCalls(item, token);
92
- for (const call of _calls) {
93
- const calls = transformCallHierarchyItem(call.to, call.fromRanges);
94
- if (!calls)
95
- continue;
96
- items.push({
97
- to: calls[0],
98
- fromRanges: calls[1],
99
- });
100
- }
101
- }
54
+ else {
55
+ const _calls = await plugin.provideCallHierarchyIncomingCalls(item, token);
56
+ for (const _call of _calls) {
57
+ const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
58
+ if (!calls)
59
+ continue;
60
+ incomingItems.push({
61
+ from: calls[0],
62
+ fromRanges: calls[1],
63
+ });
102
64
  }
103
- else {
104
- const _calls = yield plugin.provideCallHierarchyOutgoingCalls(item, token);
65
+ }
66
+ }
67
+ return dedupe.withCallHierarchyIncomingCalls(incomingItems);
68
+ },
69
+ async getOutgoingCalls(item, token) {
70
+ const data = item.data;
71
+ let items = [];
72
+ if (data) {
73
+ const plugin = context.plugins[data.pluginId];
74
+ if (!plugin.provideCallHierarchyOutgoingCalls)
75
+ return items;
76
+ Object.assign(item, data.original);
77
+ if (data.map) {
78
+ if (context.documents.hasVirtualFileByUri(data.map.embeddedDocumentUri)) {
79
+ const _calls = await plugin.provideCallHierarchyOutgoingCalls(item, token);
105
80
  for (const call of _calls) {
106
81
  const calls = transformCallHierarchyItem(call.to, call.fromRanges);
107
82
  if (!calls)
@@ -113,8 +88,20 @@ function register(context) {
113
88
  }
114
89
  }
115
90
  }
116
- return dedupe.withCallHierarchyOutgoingCalls(items);
117
- });
91
+ else {
92
+ const _calls = await plugin.provideCallHierarchyOutgoingCalls(item, token);
93
+ for (const call of _calls) {
94
+ const calls = transformCallHierarchyItem(call.to, call.fromRanges);
95
+ if (!calls)
96
+ continue;
97
+ items.push({
98
+ to: calls[0],
99
+ fromRanges: calls[1],
100
+ });
101
+ }
102
+ }
103
+ }
104
+ return dedupe.withCallHierarchyOutgoingCalls(items);
118
105
  },
119
106
  };
120
107
  function transformCallHierarchyItem(tsItem, tsRanges) {
@@ -133,15 +120,20 @@ function register(context) {
133
120
  if (!selectionRange)
134
121
  continue;
135
122
  const vueRanges = tsRanges.map(tsRange => map.toSourceRange(tsRange)).filter(common_1.notEmpty);
136
- const vueItem = Object.assign(Object.assign({}, tsItem), { name: tsItem.name === path_1.posix.basename(context.uriToFileName(map.virtualFileDocument.uri)) ? path_1.posix.basename(context.uriToFileName(map.sourceFileDocument.uri)) : tsItem.name, uri: map.sourceFileDocument.uri,
123
+ const vueItem = {
124
+ ...tsItem,
125
+ name: tsItem.name === path_1.posix.basename(context.uriToFileName(map.virtualFileDocument.uri)) ? path_1.posix.basename(context.uriToFileName(map.sourceFileDocument.uri)) : tsItem.name,
126
+ uri: map.sourceFileDocument.uri,
137
127
  // TS Bug: `range: range` not works
138
128
  range: {
139
129
  start: range.start,
140
130
  end: range.end,
141
- }, selectionRange: {
131
+ },
132
+ selectionRange: {
142
133
  start: selectionRange.start,
143
134
  end: selectionRange.end,
144
- } });
135
+ },
136
+ };
145
137
  selectionRange.end;
146
138
  return [vueItem, vueRanges];
147
139
  }
@@ -1,3 +1,3 @@
1
- import type * as vscode from 'vscode-languageserver-protocol';
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
- export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeAction, token: vscode.CancellationToken) => Promise<vscode.CodeAction>;
3
+ export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
@@ -1,36 +1,27 @@
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 rename_1 = require("./rename");
13
5
  function register(context) {
14
- return (item, token) => __awaiter(this, void 0, void 0, function* () {
15
- var _a, _b, _c, _d, _e, _f;
6
+ return async (item, token = vscode.CancellationToken.None) => {
16
7
  const data = item.data;
17
- if ((data === null || data === void 0 ? void 0 : data.type) === 'plugin') {
8
+ if (data?.type === 'plugin') {
18
9
  const plugin = context.plugins[data.pluginId];
19
10
  if (!plugin.resolveCodeAction)
20
11
  return item;
21
12
  Object.assign(item, data.original);
22
- item = yield plugin.resolveCodeAction(item, token);
13
+ item = await plugin.resolveCodeAction(item, token);
23
14
  if (item.edit) {
24
15
  item.edit = (0, rename_1.embeddedEditToSourceEdit)(item.edit, context.documents, 'codeAction', { [data.uri]: data.version });
25
16
  }
26
17
  }
27
- if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
28
- const fixes = (_c = (_b = (_a = context.ruleFixes) === null || _a === void 0 ? void 0 : _a[data.documentUri]) === null || _b === void 0 ? void 0 : _b[data.ruleId]) === null || _c === void 0 ? void 0 : _c[data.ruleFixIndex];
29
- const fix = fixes === null || fixes === void 0 ? void 0 : fixes[1][data.index];
18
+ if (data?.type === 'rule') {
19
+ const fixes = context.ruleFixes?.[data.documentUri]?.[data.ruleId]?.[data.ruleFixIndex];
20
+ const fix = fixes?.[1][data.index];
30
21
  if (fix) {
31
- let edit = (_e = yield ((_d = fix.getWorkspaceEdit) === null || _d === void 0 ? void 0 : _d.call(fix, fixes[0]))) !== null && _e !== void 0 ? _e : undefined;
22
+ let edit = await fix.getWorkspaceEdit?.(fixes[0]) ?? undefined;
32
23
  if (!edit) {
33
- const edits = yield ((_f = fix.getEdits) === null || _f === void 0 ? void 0 : _f.call(fix, fixes[0]));
24
+ const edits = await fix.getEdits?.(fixes[0]);
34
25
  if (edits) {
35
26
  edit = {
36
27
  documentChanges: [{
@@ -49,7 +40,7 @@ function register(context) {
49
40
  }
50
41
  }
51
42
  return item;
52
- });
43
+ };
53
44
  }
54
45
  exports.register = register;
55
46
  //# sourceMappingURL=codeActionResolve.js.map
@@ -17,4 +17,4 @@ export interface RuleCodeActionData {
17
17
  ruleFixIndex: number;
18
18
  index: number;
19
19
  }
20
- export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
20
+ export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | 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 transformer = require("../transformer");
@@ -16,8 +7,7 @@ const dedupe = require("../utils/dedupe");
16
7
  const featureWorkers_1 = require("../utils/featureWorkers");
17
8
  const rename_1 = require("./rename");
18
9
  function register(context) {
19
- return (uri, range, codeActionContext, token) => __awaiter(this, void 0, void 0, function* () {
20
- var _a, _b, _c, _d, _e;
10
+ return async (uri, range, codeActionContext, token = vscode.CancellationToken.None) => {
21
11
  const sourceDocument = context.getTextDocument(uri);
22
12
  if (!sourceDocument)
23
13
  return;
@@ -25,8 +15,7 @@ function register(context) {
25
15
  start: sourceDocument.offsetAt(range.start),
26
16
  end: sourceDocument.offsetAt(range.end),
27
17
  };
28
- const pluginActions = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (_arg, map, file) => {
29
- var _a, _b;
18
+ const pluginActions = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (_arg, map, file) => {
30
19
  if (!file.capabilities.codeAction)
31
20
  return [];
32
21
  const _codeActionContext = {
@@ -38,8 +27,8 @@ function register(context) {
38
27
  for (const mapping of map.map.mappings) {
39
28
  const overlapRange = (0, common_1.getOverlapRange)(offsetRange.start, offsetRange.end, mapping.sourceRange[0], mapping.sourceRange[1]);
40
29
  if (overlapRange) {
41
- const start = (_a = map.map.toGeneratedOffset(overlapRange.start)) === null || _a === void 0 ? void 0 : _a[0];
42
- const end = (_b = map.map.toGeneratedOffset(overlapRange.end)) === null || _b === void 0 ? void 0 : _b[0];
30
+ const start = map.map.toGeneratedOffset(overlapRange.start)?.[0];
31
+ const end = map.map.toGeneratedOffset(overlapRange.end)?.[0];
43
32
  if (start !== undefined && end !== undefined) {
44
33
  minStart = minStart === undefined ? start : Math.min(start, minStart);
45
34
  maxEnd = maxEnd === undefined ? end : Math.max(end, maxEnd);
@@ -53,8 +42,7 @@ function register(context) {
53
42
  }];
54
43
  }
55
44
  return [];
56
- }, (plugin, document, { range, codeActionContext }) => __awaiter(this, void 0, void 0, function* () {
57
- var _f;
45
+ }, async (plugin, document, { range, codeActionContext }) => {
58
46
  if (token.isCancellationRequested)
59
47
  return;
60
48
  const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
@@ -64,13 +52,19 @@ function register(context) {
64
52
  // console.warn('[volar/plugin-api] diagnostic version mismatch', data.version, sourceDocument.version);
65
53
  return false;
66
54
  }
67
- return (data === null || data === void 0 ? void 0 : data.type) === 'plugin' && (data === null || data === void 0 ? void 0 : data.pluginOrRuleId) === pluginId;
55
+ return data?.type === 'plugin' && data?.pluginOrRuleId === pluginId;
68
56
  }).map(diagnostic => {
69
57
  const data = diagnostic.data;
70
- return Object.assign(Object.assign({}, diagnostic), data.original);
58
+ return {
59
+ ...diagnostic,
60
+ ...data.original,
61
+ };
71
62
  });
72
- const codeActions = yield ((_f = plugin.provideCodeActions) === null || _f === void 0 ? void 0 : _f.call(plugin, document, range, Object.assign(Object.assign({}, codeActionContext), { diagnostics }), token));
73
- codeActions === null || codeActions === void 0 ? void 0 : codeActions.forEach(codeAction => {
63
+ const codeActions = await plugin.provideCodeActions?.(document, range, {
64
+ ...codeActionContext,
65
+ diagnostics,
66
+ }, token);
67
+ codeActions?.forEach(codeAction => {
74
68
  codeAction.data = {
75
69
  uri,
76
70
  version: sourceDocument.version,
@@ -83,7 +77,7 @@ function register(context) {
83
77
  };
84
78
  });
85
79
  return codeActions;
86
- }), (_codeActions, sourceMap) => _codeActions.map(_codeAction => {
80
+ }, (_codeActions, sourceMap) => _codeActions.map(_codeAction => {
87
81
  if (!sourceMap)
88
82
  return _codeAction;
89
83
  if (_codeAction.edit) {
@@ -104,8 +98,8 @@ function register(context) {
104
98
  // console.warn('[volar/rules-api] diagnostic version mismatch', data.version, sourceDocument.version);
105
99
  continue;
106
100
  }
107
- if ((data === null || data === void 0 ? void 0 : data.type) === 'rule') {
108
- const fixes = (_c = (_b = (_a = context.ruleFixes) === null || _a === void 0 ? void 0 : _a[data.documentUri]) === null || _b === void 0 ? void 0 : _b[data.pluginOrRuleId]) === null || _c === void 0 ? void 0 : _c[data.ruleFixIndex];
101
+ if (data?.type === 'rule') {
102
+ const fixes = context.ruleFixes?.[data.documentUri]?.[data.pluginOrRuleId]?.[data.ruleFixIndex];
109
103
  if (fixes) {
110
104
  for (let i = 0; i < fixes[1].length; i++) {
111
105
  const fix = fixes[1][i];
@@ -114,7 +108,7 @@ function register(context) {
114
108
  matchKinds.push(undefined);
115
109
  }
116
110
  else {
117
- for (const kind of (_d = fix.kinds) !== null && _d !== void 0 ? _d : ['quickfix']) {
111
+ for (const kind of fix.kinds ?? ['quickfix']) {
118
112
  const matchOnly = matchOnlyKind(codeActionContext.only, kind);
119
113
  if (matchOnly) {
120
114
  matchKinds.push(matchOnly);
@@ -123,7 +117,7 @@ function register(context) {
123
117
  }
124
118
  for (const matchKind of matchKinds) {
125
119
  const action = {
126
- title: (_e = fix.title) !== null && _e !== void 0 ? _e : `Fix: ${diagnostic.message}`,
120
+ title: fix.title ?? `Fix: ${diagnostic.message}`,
127
121
  kind: matchKind,
128
122
  diagnostics: [diagnostic],
129
123
  data: {
@@ -144,10 +138,10 @@ function register(context) {
144
138
  }
145
139
  }
146
140
  return [
147
- ...pluginActions !== null && pluginActions !== void 0 ? pluginActions : [],
141
+ ...pluginActions ?? [],
148
142
  ...ruleActions,
149
143
  ];
150
- });
144
+ };
151
145
  }
152
146
  exports.register = register;
153
147
  function matchOnlyKind(only, kind) {
@@ -12,4 +12,4 @@ export interface PluginReferencesCodeLensData {
12
12
  location: vscode.Location;
13
13
  pluginId: string;
14
14
  }
15
- export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
15
+ export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
@@ -1,28 +1,17 @@
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 vscode = require("vscode-languageserver-protocol");
14
5
  const common_1 = require("../utils/common");
15
6
  function register(context) {
16
- return (uri, token) => __awaiter(this, void 0, void 0, function* () {
17
- var _a, _b, _c;
18
- const referencesCodeLendsEnabled = (_b = yield ((_a = context.configurationHost) === null || _a === void 0 ? void 0 : _a.getConfiguration('volar.codeLens.references'))) !== null && _b !== void 0 ? _b : true;
19
- return (_c = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], (plugin, document) => __awaiter(this, void 0, void 0, function* () {
20
- var _d, _e;
7
+ return async (uri, token = vscode.CancellationToken.None) => {
8
+ const referencesCodeLendsEnabled = await context.configurationHost?.getConfiguration('volar.codeLens.references') ?? true;
9
+ return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], async (plugin, document) => {
21
10
  if (token.isCancellationRequested)
22
11
  return;
23
- let codeLens = yield ((_d = plugin.provideCodeLenses) === null || _d === void 0 ? void 0 : _d.call(plugin, document, token));
12
+ let codeLens = await plugin.provideCodeLenses?.(document, token);
24
13
  const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
25
- codeLens === null || codeLens === void 0 ? void 0 : codeLens.forEach(codeLens => {
14
+ codeLens?.forEach(codeLens => {
26
15
  codeLens.data = {
27
16
  kind: 'normal',
28
17
  uri,
@@ -33,28 +22,31 @@ function register(context) {
33
22
  };
34
23
  });
35
24
  if (referencesCodeLendsEnabled) {
36
- const referencesCodeLensLocs = yield ((_e = plugin.provideReferencesCodeLenses) === null || _e === void 0 ? void 0 : _e.call(plugin, document, token));
37
- const referencesCodeLens = referencesCodeLensLocs === null || referencesCodeLensLocs === void 0 ? void 0 : referencesCodeLensLocs.map(loc => vscode.CodeLens.create(loc.range, {
25
+ const referencesCodeLensLocs = await plugin.provideReferencesCodeLenses?.(document, token);
26
+ const referencesCodeLens = referencesCodeLensLocs?.map(loc => vscode.CodeLens.create(loc.range, {
38
27
  kind: 'references',
39
28
  uri,
40
29
  location: loc,
41
30
  pluginId,
42
31
  }));
43
32
  codeLens = [
44
- ...codeLens !== null && codeLens !== void 0 ? codeLens : [],
45
- ...referencesCodeLens !== null && referencesCodeLens !== void 0 ? referencesCodeLens : [],
33
+ ...codeLens ?? [],
34
+ ...referencesCodeLens ?? [],
46
35
  ];
47
36
  }
48
37
  return codeLens;
49
- }), (data, map) => data.map(codeLens => {
38
+ }, (data, map) => data.map(codeLens => {
50
39
  if (!map)
51
40
  return codeLens;
52
41
  const range = map.toSourceRange(codeLens.range);
53
42
  if (range) {
54
- return Object.assign(Object.assign({}, codeLens), { range });
43
+ return {
44
+ ...codeLens,
45
+ range,
46
+ };
55
47
  }
56
- }).filter(common_1.notEmpty), arr => arr.flat())) !== null && _c !== void 0 ? _c : [];
57
- });
48
+ }).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
49
+ };
58
50
  }
59
51
  exports.register = register;
60
52
  //# sourceMappingURL=codeLens.js.map
@@ -2,4 +2,4 @@ import * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { LanguageServicePluginContext } from '../types';
3
3
  export declare const showReferencesCommand: string;
4
4
  export type ShowReferencesCommandData = [string, vscode.Position, vscode.Location[]];
5
- export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token: vscode.CancellationToken) => Promise<vscode.CodeLens>;
5
+ export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
@@ -1,35 +1,26 @@
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 = exports.showReferencesCommand = void 0;
3
+ const vscode = require("vscode-languageserver-protocol");
12
4
  const references = require("./references");
13
5
  exports.showReferencesCommand = `volar.${Math.random().toString(36).slice(2)}.show-references`;
14
6
  function register(context) {
15
7
  const findReferences = references.register(context);
16
- return (item, token) => __awaiter(this, void 0, void 0, function* () {
17
- var _a;
8
+ return async (item, token = vscode.CancellationToken.None) => {
18
9
  const data = item.data;
19
- if ((data === null || data === void 0 ? void 0 : data.kind) === 'normal') {
10
+ if (data?.kind === 'normal') {
20
11
  const plugin = context.plugins[data.pluginId];
21
12
  if (!plugin.resolveCodeLens)
22
13
  return item;
23
14
  Object.assign(item, data.original);
24
- item = yield plugin.resolveCodeLens(item, token);
15
+ item = await plugin.resolveCodeLens(item, token);
25
16
  // item.range already transformed in codeLens request
26
17
  }
27
- if ((data === null || data === void 0 ? void 0 : data.kind) === 'references') {
28
- let references = (_a = yield findReferences(data.uri, item.range.start, token)) !== null && _a !== void 0 ? _a : [];
18
+ if (data?.kind === 'references') {
19
+ let references = await findReferences(data.uri, item.range.start, token) ?? [];
29
20
  const plugin = context.plugins[data.pluginId];
30
21
  const document = context.getTextDocument(data.uri);
31
22
  if (document && plugin.resolveReferencesCodeLens) {
32
- references = yield plugin.resolveReferencesCodeLens(document, data.location, references, token);
23
+ references = await plugin.resolveReferencesCodeLens(document, data.location, references, token);
33
24
  }
34
25
  item.command = {
35
26
  title: references.length === 1 ? '1 reference' : `${references.length} references`,
@@ -38,7 +29,7 @@ function register(context) {
38
29
  };
39
30
  }
40
31
  return item;
41
- });
32
+ };
42
33
  }
43
34
  exports.register = register;
44
35
  //# sourceMappingURL=codeLensResolve.js.map
@@ -8,4 +8,4 @@ export interface PluginCompletionData {
8
8
  embeddedDocumentUri: string;
9
9
  } | undefined;
10
10
  }
11
- export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, completionContext: vscode.CompletionContext | undefined, token: vscode.CancellationToken) => Promise<vscode.CompletionList>;
11
+ export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;