@vue/language-service 3.0.3 → 3.0.5

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 (40) hide show
  1. package/index.d.ts +1 -12
  2. package/index.js +25 -20
  3. package/lib/data.d.ts +4 -0
  4. package/lib/data.js +148 -0
  5. package/lib/plugins/css.js +9 -17
  6. package/lib/plugins/typescript-semantic-tokens.d.ts +2 -2
  7. package/lib/plugins/typescript-semantic-tokens.js +7 -15
  8. package/lib/plugins/vue-autoinsert-dotvalue.d copy.d.ts +2 -0
  9. package/lib/plugins/vue-autoinsert-dotvalue.d copy.js +3 -0
  10. package/lib/plugins/vue-autoinsert-dotvalue.d.ts +2 -2
  11. package/lib/plugins/vue-autoinsert-dotvalue.js +19 -47
  12. package/lib/plugins/vue-autoinsert-space.js +2 -6
  13. package/lib/plugins/vue-compiler-dom-errors.js +17 -35
  14. package/lib/plugins/vue-component-semantic-tokens.d.ts +2 -2
  15. package/lib/plugins/vue-component-semantic-tokens.js +35 -49
  16. package/lib/plugins/vue-destructured-props-hints.d.ts +7 -0
  17. package/lib/plugins/vue-destructured-props-hints.js +220 -0
  18. package/lib/plugins/vue-document-drop.d.ts +2 -2
  19. package/lib/plugins/vue-document-drop.js +14 -31
  20. package/lib/plugins/vue-document-highlights.d.ts +1 -2
  21. package/lib/plugins/vue-document-highlights.js +5 -12
  22. package/lib/plugins/vue-extract-file.d.ts +2 -2
  23. package/lib/plugins/vue-extract-file.js +11 -26
  24. package/lib/plugins/vue-global-types-error.js +17 -14
  25. package/lib/plugins/vue-inlayhints.js +14 -15
  26. package/lib/plugins/vue-missing-props-hints.d.ts +2 -2
  27. package/lib/plugins/vue-missing-props-hints.js +10 -26
  28. package/lib/plugins/vue-scoped-class-links.d.ts +2 -0
  29. package/lib/plugins/vue-scoped-class-links.js +62 -0
  30. package/lib/plugins/vue-sfc.js +141 -144
  31. package/lib/plugins/vue-suggest-define-assignment.js +4 -14
  32. package/lib/plugins/vue-template-ref-links.d.ts +2 -0
  33. package/lib/plugins/vue-template-ref-links.js +57 -0
  34. package/lib/plugins/vue-template.d.ts +2 -2
  35. package/lib/plugins/vue-template.js +322 -356
  36. package/lib/plugins/vue-twoslash-queries.d.ts +2 -2
  37. package/lib/plugins/vue-twoslash-queries.js +7 -16
  38. package/lib/utils.d.ts +8 -0
  39. package/lib/utils.js +43 -0
  40. package/package.json +7 -7
@@ -3,39 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = create;
4
4
  exports.findDestructuredProps = findDestructuredProps;
5
5
  const language_core_1 = require("@vue/language-core");
6
- const vscode_uri_1 = require("vscode-uri");
6
+ const utils_1 = require("../utils");
7
7
  function create(ts) {
8
8
  return {
9
- name: 'vue-inlay-hints',
9
+ name: 'vue-inlayhints',
10
10
  capabilities: {
11
11
  inlayHintProvider: {},
12
12
  },
13
13
  create(context) {
14
14
  return {
15
15
  async provideInlayHints(document, range) {
16
- const uri = vscode_uri_1.URI.parse(document.uri);
17
- const decoded = context.decodeEmbeddedDocumentUri(uri);
18
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
19
- const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
20
- if (!(virtualCode instanceof language_core_1.VueVirtualCode)) {
16
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, 'main');
17
+ if (!info) {
21
18
  return;
22
19
  }
20
+ const { root } = info;
23
21
  const settings = {};
24
22
  async function getSettingEnabled(key) {
25
23
  return settings[key] ??= await context.env.getConfiguration?.(key) ?? false;
26
24
  }
27
25
  const result = [];
28
- const codegen = language_core_1.tsCodegen.get(virtualCode.sfc);
26
+ const { sfc } = root;
27
+ const codegen = language_core_1.tsCodegen.get(sfc);
29
28
  const inlayHints = [
30
29
  ...codegen?.getGeneratedTemplate()?.inlayHints ?? [],
31
30
  ...codegen?.getGeneratedScript()?.inlayHints ?? [],
32
31
  ];
33
32
  const scriptSetupRanges = codegen?.getScriptSetupRanges();
34
- if (scriptSetupRanges?.defineProps?.destructured && virtualCode.sfc.scriptSetup?.ast) {
33
+ if (scriptSetupRanges?.defineProps?.destructured && sfc.scriptSetup?.ast) {
35
34
  const setting = 'vue.inlayHints.destructuredProps';
36
35
  const enabled = await getSettingEnabled(setting);
37
36
  if (enabled) {
38
- for (const [prop, isShorthand] of findDestructuredProps(ts, virtualCode.sfc.scriptSetup.ast, scriptSetupRanges.defineProps.destructured.keys())) {
37
+ for (const [prop, isShorthand] of findDestructuredProps(ts, sfc.scriptSetup.ast, scriptSetupRanges.defineProps.destructured.keys())) {
39
38
  const name = prop.text;
40
39
  const end = prop.getEnd();
41
40
  const pos = isShorthand ? end : end - name.length;
@@ -50,9 +49,9 @@ function create(ts) {
50
49
  }
51
50
  }
52
51
  const blocks = [
53
- virtualCode.sfc.template,
54
- virtualCode.sfc.script,
55
- virtualCode.sfc.scriptSetup,
52
+ sfc.template,
53
+ sfc.script,
54
+ sfc.scriptSetup,
56
55
  ];
57
56
  const start = document.offsetAt(range.start);
58
57
  const end = document.offsetAt(range.end);
@@ -149,7 +148,7 @@ function findDestructuredProps(ts, ast, props) {
149
148
  && initializer
150
149
  && ts.isCallExpression(initializer)
151
150
  && initializer.expression.getText(ast) === 'defineProps';
152
- for (const { id } of (0, language_core_1.collectIdentifiers)(ts, name)) {
151
+ for (const { id } of (0, language_core_1.collectBindingIdentifiers)(ts, name)) {
153
152
  if (isDefineProps) {
154
153
  excludedIds.add(id);
155
154
  }
@@ -164,7 +163,7 @@ function findDestructuredProps(ts, ast, props) {
164
163
  registerLocalBinding(name);
165
164
  }
166
165
  for (const p of parameters) {
167
- for (const { id } of (0, language_core_1.collectIdentifiers)(ts, p)) {
166
+ for (const { id } of (0, language_core_1.collectBindingIdentifiers)(ts, p)) {
168
167
  registerLocalBinding(id);
169
168
  }
170
169
  }
@@ -1,2 +1,2 @@
1
- import type { LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
2
- export declare function create(getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
1
+ import type { LanguageServicePlugin } from '@volar/language-service';
2
+ export declare function create({ getComponentNames, getElementNames, getComponentProps }: import('@vue/typescript-plugin/lib/requests').Requests): LanguageServicePlugin;
@@ -3,49 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = create;
4
4
  const language_core_1 = require("@vue/language-core");
5
5
  const html = require("vscode-html-languageservice");
6
- const vscode_uri_1 = require("vscode-uri");
7
6
  const nameCasing_1 = require("../nameCasing");
8
- function create(getTsPluginClient) {
7
+ const utils_1 = require("../utils");
8
+ function create({ getComponentNames, getElementNames, getComponentProps }) {
9
9
  return {
10
10
  name: 'vue-missing-props-hints',
11
11
  capabilities: {
12
12
  inlayHintProvider: {},
13
13
  },
14
14
  create(context) {
15
- const tsPluginClient = getTsPluginClient?.(context);
16
15
  let intrinsicElementNames;
17
16
  return {
18
17
  async provideInlayHints(document, range, cancellationToken) {
19
- if (!isSupportedDocument(document)) {
20
- return;
21
- }
22
- if (!context.project.vue) {
18
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, 'template');
19
+ if (!info) {
23
20
  return;
24
21
  }
22
+ const { sourceScript, root } = info;
25
23
  const enabled = await context.env.getConfiguration?.('vue.inlayHints.missingProps') ?? false;
26
24
  if (!enabled) {
27
25
  return;
28
26
  }
29
- const uri = vscode_uri_1.URI.parse(document.uri);
30
- const decoded = context.decodeEmbeddedDocumentUri(uri);
31
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
32
- const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
33
- if (!virtualCode) {
34
- return;
35
- }
36
- const root = sourceScript?.generated?.root;
37
- if (!(root instanceof language_core_1.VueVirtualCode)) {
38
- return;
39
- }
40
27
  const scanner = getScanner(context, document);
41
28
  if (!scanner) {
42
29
  return;
43
30
  }
44
31
  const result = [];
45
- const casing = await (0, nameCasing_1.checkCasing)(context, decoded[0]);
46
- const components = await tsPluginClient?.getComponentNames(root.fileName) ?? [];
32
+ const casing = await (0, nameCasing_1.checkCasing)(context, sourceScript.id);
33
+ const components = await getComponentNames(root.fileName) ?? [];
47
34
  const componentProps = {};
48
- intrinsicElementNames ??= new Set(await tsPluginClient?.getElementNames(root.fileName) ?? []);
35
+ intrinsicElementNames ??= new Set(await getElementNames(root.fileName) ?? []);
49
36
  let token;
50
37
  let current;
51
38
  while ((token = scanner.scan()) !== html.TokenType.EOS) {
@@ -68,7 +55,7 @@ function create(getTsPluginClient) {
68
55
  if (cancellationToken.isCancellationRequested) {
69
56
  break;
70
57
  }
71
- componentProps[checkTag] = (await tsPluginClient?.getComponentProps(root.fileName, checkTag) ?? [])
58
+ componentProps[checkTag] = (await getComponentProps(root.fileName, checkTag) ?? [])
72
59
  .filter(prop => prop.required)
73
60
  .map(prop => prop.name);
74
61
  }
@@ -99,7 +86,7 @@ function create(getTsPluginClient) {
99
86
  attrText = attrText.slice('v-model:'.length);
100
87
  }
101
88
  else if (attrText === 'v-model') {
102
- attrText = context.project.vue.compilerOptions.target >= 3 ? 'modelValue' : 'value'; // TODO: support for experimentalModelPropName?
89
+ attrText = root.vueCompilerOptions.target >= 3 ? 'modelValue' : 'value'; // TODO: support for experimentalModelPropName?
103
90
  }
104
91
  else if (attrText.startsWith('v-on:')) {
105
92
  attrText = 'on-' + (0, language_core_1.hyphenateAttr)(attrText.slice('v-on:'.length));
@@ -151,8 +138,5 @@ function create(getTsPluginClient) {
151
138
  }
152
139
  }
153
140
  }
154
- function isSupportedDocument(document) {
155
- return document.languageId === 'jade' || document.languageId === 'html';
156
- }
157
141
  }
158
142
  //# sourceMappingURL=vue-missing-props-hints.js.map
@@ -0,0 +1,2 @@
1
+ import type { LanguageServicePlugin } from '@volar/language-service';
2
+ export declare function create(): LanguageServicePlugin;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = create;
4
+ const language_core_1 = require("@vue/language-core");
5
+ const utils_1 = require("../utils");
6
+ function create() {
7
+ return {
8
+ name: 'vue-scoped-class-links',
9
+ capabilities: {
10
+ documentLinkProvider: {},
11
+ },
12
+ create(context) {
13
+ return {
14
+ provideDocumentLinks(document) {
15
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, 'template');
16
+ if (!info) {
17
+ return;
18
+ }
19
+ const { sourceScript, root } = info;
20
+ const { sfc } = root;
21
+ const codegen = language_core_1.tsCodegen.get(sfc);
22
+ const option = root.vueCompilerOptions.resolveStyleClassNames;
23
+ const scopedClasses = codegen?.getGeneratedTemplate()?.scopedClasses ?? [];
24
+ const styleClasses = new Map();
25
+ for (let i = 0; i < sfc.styles.length; i++) {
26
+ const style = sfc.styles[i];
27
+ if (option !== true && !(option === 'scoped' && style.scoped)) {
28
+ continue;
29
+ }
30
+ const styleDocumentUri = context.encodeEmbeddedDocumentUri(sourceScript.id, 'style_' + i);
31
+ const styleVirtualCode = sourceScript.generated.embeddedCodes.get('style_' + i);
32
+ if (!styleVirtualCode) {
33
+ continue;
34
+ }
35
+ const styleDocument = context.documents.get(styleDocumentUri, styleVirtualCode.languageId, styleVirtualCode.snapshot);
36
+ for (const { text, offset } of style.classNames) {
37
+ const start = styleDocument.positionAt(offset);
38
+ const end = styleDocument.positionAt(offset + text.length);
39
+ const target = styleDocumentUri
40
+ + `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`;
41
+ if (!styleClasses.has(text)) {
42
+ styleClasses.set(text, []);
43
+ }
44
+ styleClasses.get(text).push(target);
45
+ }
46
+ }
47
+ return scopedClasses.flatMap(({ className, offset }) => {
48
+ const range = {
49
+ start: document.positionAt(offset),
50
+ end: document.positionAt(offset + className.length),
51
+ };
52
+ return styleClasses.get('.' + className)?.map(target => ({
53
+ range,
54
+ target,
55
+ })) ?? [];
56
+ });
57
+ },
58
+ };
59
+ },
60
+ };
61
+ }
62
+ //# sourceMappingURL=vue-scoped-class-links.js.map
@@ -4,8 +4,8 @@ exports.create = create;
4
4
  const language_core_1 = require("@vue/language-core");
5
5
  const volar_service_html_1 = require("volar-service-html");
6
6
  const html = require("vscode-html-languageservice");
7
- const vscode_uri_1 = require("vscode-uri");
8
- const data_1 = require("./data");
7
+ const data_1 = require("../data");
8
+ const utils_1 = require("../utils");
9
9
  let sfcDataProvider;
10
10
  function create() {
11
11
  const htmlService = (0, volar_service_html_1.create)({
@@ -16,25 +16,28 @@ function create() {
16
16
  return [sfcDataProvider];
17
17
  },
18
18
  async getFormattingOptions(document, options, context) {
19
- return await worker(document, context, async (root) => {
20
- const formatSettings = await context.env.getConfiguration?.('html.format') ?? {};
21
- const blockTypes = ['template', 'script', 'style'];
22
- for (const customBlock of root.sfc.customBlocks) {
23
- blockTypes.push(customBlock.type);
24
- }
25
- return {
26
- ...options,
27
- ...formatSettings,
28
- wrapAttributes: await context.env.getConfiguration?.('vue.format.wrapAttributes') ?? 'auto',
29
- unformatted: '',
30
- contentUnformatted: blockTypes.join(','),
31
- endWithNewline: options.insertFinalNewline
32
- ? true
33
- : options.trimFinalNewlines
34
- ? false
35
- : document.getText().endsWith('\n'),
36
- };
37
- }) ?? {};
19
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, 'root_tags');
20
+ if (!info) {
21
+ return {};
22
+ }
23
+ const { root } = info;
24
+ const formatSettings = await context.env.getConfiguration?.('html.format') ?? {};
25
+ const blockTypes = ['template', 'script', 'style'];
26
+ for (const customBlock of root.sfc.customBlocks) {
27
+ blockTypes.push(customBlock.type);
28
+ }
29
+ return {
30
+ ...options,
31
+ ...formatSettings,
32
+ wrapAttributes: await context.env.getConfiguration?.('vue.format.wrapAttributes') ?? 'auto',
33
+ unformatted: '',
34
+ contentUnformatted: blockTypes.join(','),
35
+ endWithNewline: options.insertFinalNewline
36
+ ? true
37
+ : options.trimFinalNewlines
38
+ ? false
39
+ : document.getText().endsWith('\n'),
40
+ };
38
41
  },
39
42
  });
40
43
  return {
@@ -72,123 +75,129 @@ function create() {
72
75
  }
73
76
  return options;
74
77
  },
75
- provideDiagnostics(document, token) {
76
- return worker(document, context, async (root) => {
77
- const { vueSfc, sfc } = root;
78
- if (!vueSfc) {
79
- return;
80
- }
81
- const originalResult = await htmlServiceInstance.provideDiagnostics?.(document, token);
82
- const sfcErrors = [];
83
- const { template } = sfc;
84
- const { startTagEnd = Infinity, endTagStart = -Infinity, } = template ?? {};
85
- for (const error of vueSfc.errors) {
86
- if ('code' in error) {
87
- const start = error.loc?.start.offset ?? 0;
88
- const end = error.loc?.end.offset ?? 0;
89
- if (end < startTagEnd || start >= endTagStart) {
90
- sfcErrors.push({
91
- range: {
92
- start: document.positionAt(start),
93
- end: document.positionAt(end),
94
- },
95
- severity: 1,
96
- code: error.code,
97
- source: 'vue',
98
- message: error.message,
99
- });
100
- }
78
+ async provideDiagnostics(document, token) {
79
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, 'root_tags');
80
+ if (!info) {
81
+ return [];
82
+ }
83
+ const { root } = info;
84
+ const { vueSfc, sfc } = root;
85
+ if (!vueSfc) {
86
+ return;
87
+ }
88
+ const originalResult = await htmlServiceInstance.provideDiagnostics?.(document, token);
89
+ const sfcErrors = [];
90
+ const { template } = sfc;
91
+ const { startTagEnd = Infinity, endTagStart = -Infinity, } = template ?? {};
92
+ for (const error of vueSfc.errors) {
93
+ if ('code' in error) {
94
+ const start = error.loc?.start.offset ?? 0;
95
+ const end = error.loc?.end.offset ?? 0;
96
+ if (end < startTagEnd || start >= endTagStart) {
97
+ sfcErrors.push({
98
+ range: {
99
+ start: document.positionAt(start),
100
+ end: document.positionAt(end),
101
+ },
102
+ severity: 1,
103
+ code: error.code,
104
+ source: 'vue',
105
+ message: error.message,
106
+ });
101
107
  }
102
108
  }
103
- return [
104
- ...originalResult ?? [],
105
- ...sfcErrors,
106
- ];
107
- });
109
+ }
110
+ return [
111
+ ...originalResult ?? [],
112
+ ...sfcErrors,
113
+ ];
108
114
  },
109
115
  provideDocumentSymbols(document) {
110
- return worker(document, context, root => {
111
- const result = [];
112
- const { sfc } = root;
113
- if (sfc.template) {
114
- result.push({
115
- name: 'template',
116
- kind: 2,
117
- range: {
118
- start: document.positionAt(sfc.template.start),
119
- end: document.positionAt(sfc.template.end),
120
- },
121
- selectionRange: {
122
- start: document.positionAt(sfc.template.start),
123
- end: document.positionAt(sfc.template.startTagEnd),
124
- },
125
- });
126
- }
127
- if (sfc.script) {
128
- result.push({
129
- name: 'script',
130
- kind: 2,
131
- range: {
132
- start: document.positionAt(sfc.script.start),
133
- end: document.positionAt(sfc.script.end),
134
- },
135
- selectionRange: {
136
- start: document.positionAt(sfc.script.start),
137
- end: document.positionAt(sfc.script.startTagEnd),
138
- },
139
- });
140
- }
141
- if (sfc.scriptSetup) {
142
- result.push({
143
- name: 'script setup',
144
- kind: 2,
145
- range: {
146
- start: document.positionAt(sfc.scriptSetup.start),
147
- end: document.positionAt(sfc.scriptSetup.end),
148
- },
149
- selectionRange: {
150
- start: document.positionAt(sfc.scriptSetup.start),
151
- end: document.positionAt(sfc.scriptSetup.startTagEnd),
152
- },
153
- });
154
- }
155
- for (const style of sfc.styles) {
156
- let name = 'style';
157
- if (style.scoped) {
158
- name += ' scoped';
159
- }
160
- if (style.module) {
161
- name += ' module';
162
- }
163
- result.push({
164
- name,
165
- kind: 2,
166
- range: {
167
- start: document.positionAt(style.start),
168
- end: document.positionAt(style.end),
169
- },
170
- selectionRange: {
171
- start: document.positionAt(style.start),
172
- end: document.positionAt(style.startTagEnd),
173
- },
174
- });
116
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, 'root_tags');
117
+ if (!info) {
118
+ return;
119
+ }
120
+ const { root } = info;
121
+ const result = [];
122
+ const { sfc } = root;
123
+ if (sfc.template) {
124
+ result.push({
125
+ name: 'template',
126
+ kind: 2,
127
+ range: {
128
+ start: document.positionAt(sfc.template.start),
129
+ end: document.positionAt(sfc.template.end),
130
+ },
131
+ selectionRange: {
132
+ start: document.positionAt(sfc.template.start),
133
+ end: document.positionAt(sfc.template.startTagEnd),
134
+ },
135
+ });
136
+ }
137
+ if (sfc.script) {
138
+ result.push({
139
+ name: 'script',
140
+ kind: 2,
141
+ range: {
142
+ start: document.positionAt(sfc.script.start),
143
+ end: document.positionAt(sfc.script.end),
144
+ },
145
+ selectionRange: {
146
+ start: document.positionAt(sfc.script.start),
147
+ end: document.positionAt(sfc.script.startTagEnd),
148
+ },
149
+ });
150
+ }
151
+ if (sfc.scriptSetup) {
152
+ result.push({
153
+ name: 'script setup',
154
+ kind: 2,
155
+ range: {
156
+ start: document.positionAt(sfc.scriptSetup.start),
157
+ end: document.positionAt(sfc.scriptSetup.end),
158
+ },
159
+ selectionRange: {
160
+ start: document.positionAt(sfc.scriptSetup.start),
161
+ end: document.positionAt(sfc.scriptSetup.startTagEnd),
162
+ },
163
+ });
164
+ }
165
+ for (const style of sfc.styles) {
166
+ let name = 'style';
167
+ if (style.scoped) {
168
+ name += ' scoped';
175
169
  }
176
- for (const customBlock of sfc.customBlocks) {
177
- result.push({
178
- name: `${customBlock.type}`,
179
- kind: 2,
180
- range: {
181
- start: document.positionAt(customBlock.start),
182
- end: document.positionAt(customBlock.end),
183
- },
184
- selectionRange: {
185
- start: document.positionAt(customBlock.start),
186
- end: document.positionAt(customBlock.startTagEnd),
187
- },
188
- });
170
+ if (style.module) {
171
+ name += ' module';
189
172
  }
190
- return result;
191
- });
173
+ result.push({
174
+ name,
175
+ kind: 2,
176
+ range: {
177
+ start: document.positionAt(style.start),
178
+ end: document.positionAt(style.end),
179
+ },
180
+ selectionRange: {
181
+ start: document.positionAt(style.start),
182
+ end: document.positionAt(style.startTagEnd),
183
+ },
184
+ });
185
+ }
186
+ for (const customBlock of sfc.customBlocks) {
187
+ result.push({
188
+ name: `${customBlock.type}`,
189
+ kind: 2,
190
+ range: {
191
+ start: document.positionAt(customBlock.start),
192
+ end: document.positionAt(customBlock.end),
193
+ },
194
+ selectionRange: {
195
+ start: document.positionAt(customBlock.start),
196
+ end: document.positionAt(customBlock.startTagEnd),
197
+ },
198
+ });
199
+ }
200
+ return result;
192
201
  },
193
202
  async provideCompletionItems(document, position, context, token) {
194
203
  const result = await htmlServiceInstance.provideCompletionItems?.(document, position, context, token);
@@ -262,18 +271,6 @@ function create() {
262
271
  };
263
272
  },
264
273
  };
265
- function worker(document, context, callback) {
266
- if (document.languageId !== 'vue-root-tags') {
267
- return;
268
- }
269
- const uri = vscode_uri_1.URI.parse(document.uri);
270
- const decoded = context.decodeEmbeddedDocumentUri(uri);
271
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
272
- const root = sourceScript?.generated?.root;
273
- if (root instanceof language_core_1.VueVirtualCode) {
274
- return callback(root);
275
- }
276
- }
277
274
  }
278
275
  function getStyleCompletionItem(styleItem, lang, attr) {
279
276
  return {
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = create;
4
4
  const language_core_1 = require("@vue/language-core");
5
- const vscode_uri_1 = require("vscode-uri");
6
- const utils_1 = require("./utils");
5
+ const utils_1 = require("../utils");
7
6
  function create() {
8
7
  return {
9
8
  name: 'vue-suggest-define-assignment',
@@ -14,24 +13,15 @@ function create() {
14
13
  return {
15
14
  isAdditionalCompletion: true,
16
15
  async provideCompletionItems(document) {
17
- if (!(0, utils_1.isTsDocument)(document)) {
16
+ const info = (0, utils_1.getEmbeddedInfo)(context, document, id => id.startsWith('script_'));
17
+ if (!info) {
18
18
  return;
19
19
  }
20
+ const { virtualCode, root } = info;
20
21
  const enabled = await context.env.getConfiguration?.('vue.suggest.defineAssignment') ?? true;
21
22
  if (!enabled) {
22
23
  return;
23
24
  }
24
- const uri = vscode_uri_1.URI.parse(document.uri);
25
- const decoded = context.decodeEmbeddedDocumentUri(uri);
26
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
27
- const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
28
- if (!sourceScript?.generated || !virtualCode) {
29
- return;
30
- }
31
- const root = sourceScript.generated.root;
32
- if (!(root instanceof language_core_1.VueVirtualCode)) {
33
- return;
34
- }
35
25
  const { sfc } = root;
36
26
  const codegen = language_core_1.tsCodegen.get(sfc);
37
27
  const scriptSetup = sfc.scriptSetup;
@@ -0,0 +1,2 @@
1
+ import type { LanguageServicePlugin } from '@volar/language-service';
2
+ export declare function create(): LanguageServicePlugin;