@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 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) => {
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) {
@@ -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) => {
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
@@ -1,35 +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 = exports.showReferencesCommand = void 0;
12
3
  const references = require("./references");
13
4
  exports.showReferencesCommand = `volar.${Math.random().toString(36).slice(2)}.show-references`;
14
5
  function register(context) {
15
6
  const findReferences = references.register(context);
16
- return (item, token) => __awaiter(this, void 0, void 0, function* () {
17
- var _a;
7
+ return async (item, token) => {
18
8
  const data = item.data;
19
- if ((data === null || data === void 0 ? void 0 : data.kind) === 'normal') {
9
+ if (data?.kind === 'normal') {
20
10
  const plugin = context.plugins[data.pluginId];
21
11
  if (!plugin.resolveCodeLens)
22
12
  return item;
23
13
  Object.assign(item, data.original);
24
- item = yield plugin.resolveCodeLens(item, token);
14
+ item = await plugin.resolveCodeLens(item, token);
25
15
  // item.range already transformed in codeLens request
26
16
  }
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 : [];
17
+ if (data?.kind === 'references') {
18
+ let references = await findReferences(data.uri, item.range.start, token) ?? [];
29
19
  const plugin = context.plugins[data.pluginId];
30
20
  const document = context.getTextDocument(data.uri);
31
21
  if (document && plugin.resolveReferencesCodeLens) {
32
- references = yield plugin.resolveReferencesCodeLens(document, data.location, references, token);
22
+ references = await plugin.resolveReferencesCodeLens(document, data.location, references, token);
33
23
  }
34
24
  item.command = {
35
25
  title: references.length === 1 ? '1 reference' : `${references.length} references`,
@@ -38,7 +28,7 @@ function register(context) {
38
28
  };
39
29
  }
40
30
  return item;
41
- });
31
+ };
42
32
  }
43
33
  exports.register = register;
44
34
  //# sourceMappingURL=codeLensResolve.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 transformer = require("../transformer");
@@ -14,14 +5,13 @@ 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 = {
8
+ return async (uri, position, completionContext, token) => {
9
+ completionContext ??= {
20
10
  triggerKind: vscode.CompletionTriggerKind.Invoked,
21
- });
11
+ };
22
12
  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) {
13
+ if (completionContext?.triggerKind === vscode.CompletionTriggerKind.TriggerForIncompleteCompletions
14
+ && cache?.uri === uri) {
25
15
  for (const cacheData of cache.data) {
26
16
  if (!cacheData.list.isIncomplete)
27
17
  continue;
@@ -30,7 +20,7 @@ function register(context) {
30
20
  for (const mapped of map.toGeneratedPositions(position, data => !!data.completion)) {
31
21
  if (!cacheData.plugin.provideCompletionItems)
32
22
  continue;
33
- const embeddedCompletionList = yield cacheData.plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
23
+ const embeddedCompletionList = await cacheData.plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
34
24
  if (!embeddedCompletionList) {
35
25
  cacheData.list.isIncomplete = false;
36
26
  continue;
@@ -53,7 +43,7 @@ function register(context) {
53
43
  else if (document = context.getTextDocument(uri)) {
54
44
  if (!cacheData.plugin.provideCompletionItems)
55
45
  continue;
56
- const completionList = yield cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
46
+ const completionList = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
57
47
  if (!completionList) {
58
48
  cacheData.list.isIncomplete = false;
59
49
  continue;
@@ -74,7 +64,7 @@ function register(context) {
74
64
  }
75
65
  }
76
66
  else {
77
- const rootFile = (_a = context.documents.getSourceByUri(uri)) === null || _a === void 0 ? void 0 : _a.root;
67
+ const rootFile = context.documents.getSourceByUri(uri)?.root;
78
68
  cache = {
79
69
  uri,
80
70
  data: [],
@@ -83,8 +73,7 @@ function register(context) {
83
73
  // monky fix https://github.com/johnsoncodehk/volar/issues/1358
84
74
  let isFirstMapping = true;
85
75
  if (rootFile) {
86
- yield (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, (_, map) => __awaiter(this, void 0, void 0, function* () {
87
- var _c;
76
+ await (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, async (_, map) => {
88
77
  const plugins = Object.values(context.plugins).sort(sortPlugins);
89
78
  let _data;
90
79
  for (const mapped of map.toGeneratedPositions(position, data => {
@@ -98,18 +87,18 @@ function register(context) {
98
87
  continue;
99
88
  if (plugin.isAdditionalCompletion && !isFirstMapping)
100
89
  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)))
90
+ if (completionContext?.triggerCharacter && !plugin.triggerCharacters?.includes(completionContext.triggerCharacter))
102
91
  continue;
103
92
  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))
93
+ if (cache.mainCompletion && (!isAdditional || cache?.mainCompletion.documentUri !== map.virtualFileDocument.uri))
105
94
  continue;
106
95
  // 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)))
96
+ if (plugin.isAdditionalCompletion && cache?.data.some(data => data.plugin === plugin))
108
97
  continue;
109
- const embeddedCompletionList = yield plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
98
+ const embeddedCompletionList = await plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
110
99
  if (!embeddedCompletionList || !embeddedCompletionList.items.length)
111
100
  continue;
112
- if (typeof (_data === null || _data === void 0 ? void 0 : _data.completion) === 'object' && _data.completion.autoImportOnly) {
101
+ if (typeof _data?.completion === 'object' && _data.completion.autoImportOnly) {
113
102
  embeddedCompletionList.items = embeddedCompletionList.items.filter(item => !!item.labelDetails);
114
103
  }
115
104
  if (!isAdditional) {
@@ -138,7 +127,7 @@ function register(context) {
138
127
  isFirstMapping = false;
139
128
  }
140
129
  return true;
141
- }));
130
+ });
142
131
  }
143
132
  if (document = context.getTextDocument(uri)) {
144
133
  const plugins = Object.values(context.plugins).sort(sortPlugins);
@@ -149,14 +138,14 @@ function register(context) {
149
138
  continue;
150
139
  if (plugin.isAdditionalCompletion && !isFirstMapping)
151
140
  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)))
141
+ if (completionContext?.triggerCharacter && !plugin.triggerCharacters?.includes(completionContext.triggerCharacter))
153
142
  continue;
154
143
  if (cache.mainCompletion && (!plugin.isAdditionalCompletion || cache.mainCompletion.documentUri !== document.uri))
155
144
  continue;
156
145
  // 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)))
146
+ if (plugin.isAdditionalCompletion && cache?.data.some(data => data.plugin === plugin))
158
147
  continue;
159
- const completionList = yield plugin.provideCompletionItems(document, position, completionContext, token);
148
+ const completionList = await plugin.provideCompletionItems(document, position, completionContext, token);
160
149
  if (!completionList || !completionList.items.length)
161
150
  continue;
162
151
  if (!plugin.isAdditionalCompletion) {
@@ -187,14 +176,13 @@ function register(context) {
187
176
  return (b.isAdditionalCompletion ? -1 : 1) - (a.isAdditionalCompletion ? -1 : 1);
188
177
  }
189
178
  function combineCompletionList(lists) {
190
- var _a;
191
179
  return {
192
180
  isIncomplete: lists.some(list => list.isIncomplete),
193
- itemDefaults: (_a = lists.find(list => list.itemDefaults)) === null || _a === void 0 ? void 0 : _a.itemDefaults,
181
+ itemDefaults: lists.find(list => list.itemDefaults)?.itemDefaults,
194
182
  items: lists.map(list => list.items).flat(),
195
183
  };
196
184
  }
197
- });
185
+ };
198
186
  }
199
187
  exports.register = register;
200
188
  //# sourceMappingURL=complete.js.map
@@ -1,17 +1,8 @@
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");
13
4
  function register(context) {
14
- return (item, token) => __awaiter(this, void 0, void 0, function* () {
5
+ return async (item, token) => {
15
6
  const data = item.data;
16
7
  if (data) {
17
8
  const plugin = context.plugins[data.pluginId];
@@ -20,10 +11,9 @@ function register(context) {
20
11
  item = Object.assign(item, data.original);
21
12
  if (data.map) {
22
13
  for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
23
- item = yield plugin.resolveCompletionItem(item, token);
14
+ item = await plugin.resolveCompletionItem(item, token);
24
15
  item = transformer.asCompletionItem(item, embeddedRange => {
25
- var _a;
26
- let range = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange);
16
+ let range = plugin.resolveEmbeddedRange?.(embeddedRange);
27
17
  if (range)
28
18
  return range;
29
19
  return map.toSourceRange(embeddedRange);
@@ -31,7 +21,7 @@ function register(context) {
31
21
  }
32
22
  }
33
23
  else {
34
- item = yield plugin.resolveCompletionItem(item, token);
24
+ item = await plugin.resolveCompletionItem(item, token);
35
25
  }
36
26
  }
37
27
  // TODO: monkey fix import ts file icon
@@ -39,7 +29,7 @@ function register(context) {
39
29
  item.detail = item.detail;
40
30
  }
41
31
  return item;
42
- });
32
+ };
43
33
  }
44
34
  exports.register = register;
45
35
  //# sourceMappingURL=completeResolve.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 featureWorkers_1 = require("../utils/featureWorkers");
@@ -14,49 +5,49 @@ const dedupe = require("../utils/dedupe");
14
5
  const common_1 = require("../utils/common");
15
6
  function register(context, apiName, isValidMapping, isValidMirrorPosition) {
16
7
  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 (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), async (plugin, document, position) => {
18
9
  if (token.isCancellationRequested)
19
10
  return;
20
11
  const recursiveChecker = dedupe.createLocationSet();
21
12
  const result = [];
22
- yield withMirrors(document, position, undefined);
13
+ await withMirrors(document, position, undefined);
23
14
  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
- }
15
+ async function withMirrors(document, position, originDefinition) {
16
+ const api = plugin[apiName];
17
+ if (!api)
18
+ return;
19
+ if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
20
+ return;
21
+ recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
22
+ const definitions = await api?.(document, position, token) ?? [];
23
+ for (const definition of definitions) {
24
+ let foundMirrorPosition = false;
25
+ recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
26
+ const mirrorMap = context.documents.getMirrorMapByUri(definition.targetUri)?.[1];
27
+ if (mirrorMap) {
28
+ for (const mapped of mirrorMap.findMirrorPositions(definition.targetSelectionRange.start)) {
29
+ if (!isValidMirrorPosition(mapped[1]))
30
+ continue;
31
+ if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
32
+ continue;
33
+ foundMirrorPosition = true;
34
+ await withMirrors(mirrorMap.document, mapped[0], originDefinition ?? definition);
35
+ }
36
+ }
37
+ if (!foundMirrorPosition) {
38
+ if (originDefinition) {
39
+ result.push({
40
+ ...definition,
41
+ originSelectionRange: originDefinition.originSelectionRange,
42
+ });
47
43
  }
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
- }
44
+ else {
45
+ result.push(definition);
55
46
  }
56
47
  }
57
- });
48
+ }
58
49
  }
59
- }), (data, sourceMap) => data.map(link => {
50
+ }, (data, sourceMap) => data.map(link => {
60
51
  if (link.originSelectionRange && sourceMap) {
61
52
  const originSelectionRange = toSourcePositionPreferSurroundedPosition(sourceMap, link.originSelectionRange, position);
62
53
  if (!originSelectionRange)
@@ -72,7 +63,7 @@ function register(context, apiName, isValidMapping, isValidMirrorPosition) {
72
63
  let targetRange = targetSourceMap.toSourceRange(link.targetRange);
73
64
  link.targetUri = targetSourceMap.sourceFileDocument.uri;
74
65
  // loose range mapping to for template slots, slot properties
75
- link.targetRange = targetRange !== null && targetRange !== void 0 ? targetRange : targetSelectionRange;
66
+ link.targetRange = targetRange ?? targetSelectionRange;
76
67
  link.targetSelectionRange = targetSelectionRange;
77
68
  }
78
69
  if (context.documents.hasVirtualFileByUri(link.targetUri) && !foundTargetSelectionRange) {