@vue/language-service 3.0.5 → 3.0.7-alpha.0

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.
package/lib/data.js CHANGED
@@ -38,7 +38,6 @@ function loadTemplateData(lang) {
38
38
  data = require('../data/template/en.json');
39
39
  }
40
40
  resolveReferences(data);
41
- // oxlint-disable-next-line no-useless-spread
42
41
  for (const attr of [...data.globalAttributes ?? []]) {
43
42
  if (!attr.name.startsWith('v-')) {
44
43
  data.globalAttributes?.push({ ...attr, name: `:${attr.name}` }, { ...attr, name: `v-bind:${attr.name}` });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = create;
4
+ const language_core_1 = require("@vue/language-core");
4
5
  const utils_1 = require("../utils");
5
6
  function create({ getDocumentHighlights }) {
6
7
  return {
@@ -16,7 +17,22 @@ function create({ getDocumentHighlights }) {
16
17
  return;
17
18
  }
18
19
  const { root } = info;
19
- const result = await getDocumentHighlights(root.fileName, document.offsetAt(position));
20
+ const { template } = root.sfc;
21
+ const offset = document.offsetAt(position);
22
+ if (template?.ast && offset >= template.startTagEnd && offset <= template.endTagStart) {
23
+ const pos = offset - template.startTagEnd;
24
+ for (const node of (0, language_core_1.forEachElementNode)(template.ast)) {
25
+ if (pos < node.loc.start.offset || pos > node.loc.end.offset) {
26
+ continue;
27
+ }
28
+ for (const tagOffset of (0, language_core_1.getElementTagOffsets)(node, template)) {
29
+ if (pos >= tagOffset && pos <= tagOffset + node.tag.length) {
30
+ return;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ const result = await getDocumentHighlights(root.fileName, offset);
20
36
  return result
21
37
  ?.filter(({ fileName }) => fileName === root.fileName)
22
38
  .flatMap(({ highlightSpans }) => highlightSpans)
@@ -41,7 +41,7 @@ Failed to write the global types file. Make sure that:
41
41
  1. "node_modules" directory exists.
42
42
  2. "${vueCompilerOptions.lib}" is installed as a direct dependency.
43
43
 
44
- Alternatively, you can manually set "vueCompilerOptions.globalTypesPath" in your "tsconfig.json".
44
+ Alternatively, you can manually set "vueCompilerOptions.globalTypesPath" in your "tsconfig.json" or "jsconfig.json".
45
45
 
46
46
  If all dependencies are installed, try running the "vue.action.restartServer" command to restart Vue and TS servers.
47
47
  `.trim(),
@@ -182,7 +182,6 @@ function create(languageId, { getComponentNames, getElementAttrs, getComponentPr
182
182
  prop = {
183
183
  name,
184
184
  kind: 'prop',
185
- isGlobal: true,
186
185
  };
187
186
  }
188
187
  }
@@ -190,7 +189,7 @@ function create(languageId, { getComponentNames, getElementAttrs, getComponentPr
190
189
  if (prop) {
191
190
  const { isEvent, propName } = getPropName(prop.name, prop.kind === 'event');
192
191
  if (prop.kind === 'prop') {
193
- if (!prop.isGlobal || specialProps.has(propName)) {
192
+ if (!prop.isGlobal) {
194
193
  item.kind = 5;
195
194
  }
196
195
  }
@@ -200,7 +199,7 @@ function create(languageId, { getComponentNames, getElementAttrs, getComponentPr
200
199
  tokens.push('\u0004');
201
200
  }
202
201
  }
203
- if (!prop.isGlobal || specialProps.has(propName)) {
202
+ if (!prop.isGlobal) {
204
203
  tokens.push('\u0000');
205
204
  if (item.label.startsWith(':')) {
206
205
  tokens.push('\u0001');
@@ -243,6 +242,9 @@ function create(languageId, { getComponentNames, getElementAttrs, getComponentPr
243
242
  tokens.push('\u0001');
244
243
  }
245
244
  item.sortText = tokens.join('') + (item.sortText ?? item.label);
245
+ if (item.label === 'v-for') {
246
+ item.textEdit.newText = item.label + '="${1:value} in ${2:source}"';
247
+ }
246
248
  }
247
249
  },
248
250
  provideHover(document, position, token) {
@@ -466,28 +468,25 @@ function create(languageId, { getComponentNames, getElementAttrs, getComponentPr
466
468
  ...attrs.map(attr => ({ name: attr })),
467
469
  ]) {
468
470
  if (prop.name.startsWith('onUpdate:')) {
469
- const isGlobal = !propNameSet.has(prop.name);
470
- models.push([isGlobal, prop.name.slice('onUpdate:'.length)]);
471
+ models.push(prop.name.slice('onUpdate:'.length));
471
472
  }
472
473
  }
473
474
  for (const event of events) {
474
475
  if (event.startsWith('update:')) {
475
- models.push([false, event.slice('update:'.length)]);
476
+ models.push(event.slice('update:'.length));
476
477
  }
477
478
  }
478
- for (const [isGlobal, model] of models) {
479
+ for (const model of models) {
479
480
  const name = casing.attr === nameCasing_1.AttrNameCasing.Camel ? model : (0, language_core_1.hyphenateAttr)(model);
480
481
  attributes.push({ name: 'v-model:' + name });
481
482
  propMap.set('v-model:' + name, {
482
483
  name,
483
484
  kind: 'prop',
484
- isGlobal,
485
485
  });
486
486
  if (model === 'modelValue') {
487
487
  propMap.set('v-model', {
488
488
  name,
489
489
  kind: 'prop',
490
- isGlobal,
491
490
  });
492
491
  }
493
492
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "3.0.5",
3
+ "version": "3.0.7-alpha.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "data",
@@ -17,8 +17,8 @@
17
17
  "update-html-data": "node ./scripts/update-html-data.js"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-service": "2.4.22",
21
- "@vue/language-core": "3.0.5",
20
+ "@volar/language-service": "2.4.23",
21
+ "@vue/language-core": "3.0.7-alpha.0",
22
22
  "@vue/shared": "^3.5.0",
23
23
  "path-browserify": "^1.0.1",
24
24
  "volar-service-css": "0.0.65",
@@ -34,11 +34,11 @@
34
34
  "devDependencies": {
35
35
  "@types/node": "^22.10.4",
36
36
  "@types/path-browserify": "^1.0.1",
37
- "@volar/kit": "2.4.22",
38
- "@volar/typescript": "2.4.22",
37
+ "@volar/kit": "2.4.23",
38
+ "@volar/typescript": "2.4.23",
39
39
  "@vue/compiler-dom": "^3.5.0",
40
- "@vue/typescript-plugin": "3.0.5",
40
+ "@vue/typescript-plugin": "3.0.7-alpha.0",
41
41
  "vscode-css-languageservice": "^6.3.1"
42
42
  },
43
- "gitHead": "036b6b1882179d35586e16f2a5cba5150e5d18e6"
43
+ "gitHead": "a66f2330b5aa6f811f571159245c46af0c36c534"
44
44
  }
@@ -1,4 +0,0 @@
1
- import type * as html from 'vscode-html-languageservice';
2
- export declare function loadTemplateData(lang: string): html.HTMLDataV1;
3
- export declare function loadLanguageBlocks(lang: string): html.HTMLDataV1;
4
- export declare function loadModelModifiersData(lang: string): html.HTMLDataV1;
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadTemplateData = loadTemplateData;
4
- exports.loadLanguageBlocks = loadLanguageBlocks;
5
- exports.loadModelModifiersData = loadModelModifiersData;
6
- let locale;
7
- function loadTemplateData(lang) {
8
- lang = lang.toLowerCase();
9
- let data;
10
- if (lang === 'ja') {
11
- data = require('../../data/template/ja.json');
12
- }
13
- else if (lang === 'fr') {
14
- data = require('../../data/template/fr.json');
15
- }
16
- else if (lang === 'ko') {
17
- data = require('../../data/template/ko.json');
18
- }
19
- else if (lang === 'pt-br') {
20
- data = require('../../data/template/pt.json');
21
- }
22
- else if (lang === 'zh-cn') {
23
- data = require('../../data/template/zh-cn.json');
24
- }
25
- else if (lang === 'zh-tw') {
26
- data = require('../../data/template/zh-hk.json');
27
- }
28
- else if (lang === 'it') {
29
- data = require('../../data/template/it.json');
30
- }
31
- else if (lang === 'cs') {
32
- data = require('../../data/template/cs.json');
33
- }
34
- else if (lang === 'ru') {
35
- data = require('../../data/template/ru.json');
36
- }
37
- else {
38
- data = require('../../data/template/en.json');
39
- }
40
- resolveReferences(data);
41
- // oxlint-disable-next-line no-useless-spread
42
- for (const attr of [...data.globalAttributes ?? []]) {
43
- if (!attr.name.startsWith('v-')) {
44
- data.globalAttributes?.push({ ...attr, name: `:${attr.name}` }, { ...attr, name: `v-bind:${attr.name}` });
45
- }
46
- }
47
- const vOn = data.globalAttributes?.find(d => d.name === 'v-on');
48
- const vSlot = data.globalAttributes?.find(d => d.name === 'v-slot');
49
- const vBind = data.globalAttributes?.find(d => d.name === 'v-bind');
50
- if (vOn) {
51
- data.globalAttributes?.push({ ...vOn, name: '@' });
52
- }
53
- if (vSlot) {
54
- data.globalAttributes?.push({ ...vSlot, name: '#' });
55
- }
56
- if (vBind) {
57
- data.globalAttributes?.push({ ...vBind, name: ':' });
58
- }
59
- return data;
60
- }
61
- function loadLanguageBlocks(lang) {
62
- lang = lang.toLowerCase();
63
- let data;
64
- if (lang === 'ja') {
65
- data = require('../../data/language-blocks/ja.json');
66
- }
67
- else if (lang === 'fr') {
68
- data = require('../../data/language-blocks/fr.json');
69
- }
70
- else if (lang === 'ko') {
71
- data = require('../../data/language-blocks/ko.json');
72
- }
73
- else if (lang === 'pt-br') {
74
- data = require('../../data/language-blocks/pt.json');
75
- }
76
- else if (lang === 'zh-cn') {
77
- data = require('../../data/language-blocks/zh-cn.json');
78
- }
79
- else if (lang === 'zh-tw') {
80
- data = require('../../data/language-blocks/zh-hk.json');
81
- }
82
- else if (lang === 'it') {
83
- data = require('../../data/language-blocks/it.json');
84
- }
85
- else if (lang === 'cs') {
86
- data = require('../../data/language-blocks/cs.json');
87
- }
88
- else if (lang === 'ru') {
89
- data = require('../../data/language-blocks/ru.json');
90
- }
91
- else {
92
- data = require('../../data/language-blocks/en.json');
93
- }
94
- resolveReferences(data);
95
- return data;
96
- }
97
- function loadModelModifiersData(lang) {
98
- lang = lang.toLowerCase();
99
- let data;
100
- if (lang === 'ja') {
101
- data = require('../../data/model-modifiers/ja.json');
102
- }
103
- else if (lang === 'fr') {
104
- data = require('../../data/model-modifiers/fr.json');
105
- }
106
- else if (lang === 'ko') {
107
- data = require('../../data/model-modifiers/ko.json');
108
- }
109
- else if (lang === 'pt-br') {
110
- data = require('../../data/model-modifiers/pt.json');
111
- }
112
- else if (lang === 'zh-cn') {
113
- data = require('../../data/model-modifiers/zh-cn.json');
114
- }
115
- else if (lang === 'zh-tw') {
116
- data = require('../../data/model-modifiers/zh-hk.json');
117
- }
118
- else if (lang === 'it') {
119
- data = require('../../data/model-modifiers/it.json');
120
- }
121
- else if (lang === 'cs') {
122
- data = require('../../data/model-modifiers/cs.json');
123
- }
124
- else if (lang === 'ru') {
125
- data = require('../../data/model-modifiers/ru.json');
126
- }
127
- else {
128
- data = require('../../data/model-modifiers/en.json');
129
- }
130
- resolveReferences(data);
131
- return data;
132
- }
133
- function resolveReferences(data) {
134
- locale ??= require('../../data/locale.json');
135
- for (const item of [
136
- ...data.globalAttributes ?? [],
137
- ...data.tags?.flatMap(tag => [tag, ...tag.attributes]) ?? [],
138
- ]) {
139
- if (typeof item.references === 'string') {
140
- const relativeUrl = item.references;
141
- item.references = locale.map(({ name, url }) => ({
142
- name,
143
- url: url + relativeUrl,
144
- }));
145
- }
146
- }
147
- }
148
- //# sourceMappingURL=data.js.map
@@ -1,3 +0,0 @@
1
- import type { TextDocument } from '@volar/language-service';
2
- export declare function sleep(ms: number): Promise<unknown>;
3
- export declare function isTsDocument(document: TextDocument): boolean;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sleep = sleep;
4
- exports.isTsDocument = isTsDocument;
5
- function sleep(ms) {
6
- return new Promise(resolve => setTimeout(resolve, ms));
7
- }
8
- function isTsDocument(document) {
9
- return document.languageId === 'javascript'
10
- || document.languageId === 'typescript'
11
- || document.languageId === 'javascriptreact'
12
- || document.languageId === 'typescriptreact';
13
- }
14
- //# sourceMappingURL=utils.js.map
@@ -1,2 +0,0 @@
1
- import type { LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
2
- export declare function create(ts: typeof import('typescript'), getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=vue-autoinsert-dotvalue.d%20copy.js.map
@@ -1,2 +0,0 @@
1
- import type { LanguageServicePlugin } from '@volar/language-service';
2
- export declare function create(): LanguageServicePlugin;
@@ -1,84 +0,0 @@
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 vscode_uri_1 = require("vscode-uri");
6
- const utils_1 = require("./utils");
7
- function create() {
8
- return {
9
- name: 'vue-complete-define-assignment',
10
- capabilities: {
11
- completionProvider: {},
12
- },
13
- create(context) {
14
- return {
15
- isAdditionalCompletion: true,
16
- async provideCompletionItems(document) {
17
- if (!(0, utils_1.isTsDocument)(document)) {
18
- return;
19
- }
20
- const enabled = await context.env.getConfiguration?.('vue.suggest.defineAssignment') ?? true;
21
- if (!enabled) {
22
- return;
23
- }
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
- const { sfc } = root;
36
- const codegen = language_core_1.tsCodegen.get(sfc);
37
- const scriptSetup = sfc.scriptSetup;
38
- const scriptSetupRanges = codegen?.getScriptSetupRanges();
39
- if (!scriptSetup || !scriptSetupRanges) {
40
- return;
41
- }
42
- const result = [];
43
- const mappings = [...context.language.maps.forEach(virtualCode)];
44
- addDefineCompletionItem(scriptSetupRanges.defineProps?.statement, scriptSetupRanges.withDefaults?.exp ?? scriptSetupRanges.defineProps?.exp, 'props');
45
- addDefineCompletionItem(scriptSetupRanges.defineEmits?.statement, scriptSetupRanges.defineEmits?.exp, 'emit');
46
- addDefineCompletionItem(scriptSetupRanges.defineSlots?.statement, scriptSetupRanges.defineSlots?.exp, 'slots');
47
- return {
48
- isIncomplete: false,
49
- items: result,
50
- };
51
- function addDefineCompletionItem(statement, exp, name) {
52
- if (!exp || exp.start !== statement?.start) {
53
- return;
54
- }
55
- let offset;
56
- for (const [, map] of mappings) {
57
- for (const [generatedOffset] of map.toGeneratedLocation(scriptSetup.startTagEnd + exp.start)) {
58
- offset = generatedOffset;
59
- break;
60
- }
61
- }
62
- if (offset === undefined) {
63
- return;
64
- }
65
- const pos = document.positionAt(offset);
66
- result.push({
67
- label: name,
68
- kind: 6,
69
- commitCharacters: ['.', ',', ';'],
70
- additionalTextEdits: [{
71
- newText: `const ${name} = `,
72
- range: {
73
- start: pos,
74
- end: pos,
75
- },
76
- }],
77
- });
78
- }
79
- },
80
- };
81
- },
82
- };
83
- }
84
- //# sourceMappingURL=vue-complete-define-assignment.js.map
@@ -1,7 +0,0 @@
1
- import type { LanguageServicePlugin } from '@volar/language-service';
2
- import type * as ts from 'typescript';
3
- export declare function create(ts: typeof import('typescript')): LanguageServicePlugin;
4
- /**
5
- * Refactored from https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/script/definePropsDestructure.ts
6
- */
7
- export declare function findDestructuredProps(ts: typeof import('typescript'), ast: ts.SourceFile, props: MapIterator<string>): [ts.Identifier, boolean][];
@@ -1,220 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = create;
4
- exports.findDestructuredProps = findDestructuredProps;
5
- const language_core_1 = require("@vue/language-core");
6
- const vscode_uri_1 = require("vscode-uri");
7
- function create(ts) {
8
- return {
9
- name: 'vue-destructured-props-hints',
10
- capabilities: {
11
- inlayHintProvider: {},
12
- },
13
- create(context) {
14
- return {
15
- async provideInlayHints(document) {
16
- const enabled = await context.env.getConfiguration?.('vue.inlayHints.destructuredProps') ?? false;
17
- if (!enabled) {
18
- return;
19
- }
20
- const uri = vscode_uri_1.URI.parse(document.uri);
21
- const decoded = context.decodeEmbeddedDocumentUri(uri);
22
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
23
- const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
24
- if (!sourceScript?.generated || virtualCode?.id !== 'main') {
25
- return;
26
- }
27
- const root = sourceScript.generated.root;
28
- if (!(root instanceof language_core_1.VueVirtualCode)) {
29
- return;
30
- }
31
- const result = [];
32
- const codegen = language_core_1.tsCodegen.get(root.sfc);
33
- const scriptSetupRanges = codegen?.getScriptSetupRanges();
34
- if (!scriptSetupRanges?.defineProps?.destructured || !root.sfc.scriptSetup?.ast) {
35
- return;
36
- }
37
- for (const [prop, isShorthand] of findDestructuredProps(ts, root.sfc.scriptSetup.ast, scriptSetupRanges.defineProps.destructured.keys())) {
38
- const name = prop.text;
39
- const end = prop.getEnd();
40
- const pos = isShorthand ? end : end - name.length;
41
- const label = isShorthand ? `: props.${name}` : 'props.';
42
- result.push({
43
- label,
44
- position: document.positionAt(root.sfc.scriptSetup.startTagEnd + pos),
45
- kind: 2,
46
- });
47
- }
48
- return result;
49
- },
50
- };
51
- },
52
- };
53
- }
54
- /**
55
- * Refactored from https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/script/definePropsDestructure.ts
56
- */
57
- function findDestructuredProps(ts, ast, props) {
58
- const rootScope = Object.create(null);
59
- const scopeStack = [rootScope];
60
- let currentScope = rootScope;
61
- const excludedIds = new WeakSet();
62
- const parentStack = [];
63
- for (const prop of props) {
64
- rootScope[prop] = true;
65
- }
66
- function pushScope() {
67
- scopeStack.push(currentScope = Object.create(currentScope));
68
- }
69
- function popScope() {
70
- scopeStack.pop();
71
- currentScope = scopeStack[scopeStack.length - 1] || null;
72
- }
73
- function registerLocalBinding(id) {
74
- excludedIds.add(id);
75
- if (currentScope) {
76
- currentScope[id.text] = false;
77
- }
78
- }
79
- const references = [];
80
- walkScope(ast, true);
81
- walk(ast);
82
- return references;
83
- function walkScope(node, isRoot = false) {
84
- ts.forEachChild(node, stmt => {
85
- if (ts.isVariableStatement(stmt)) {
86
- for (const decl of stmt.declarationList.declarations) {
87
- walkVariableDeclaration(decl, isRoot);
88
- }
89
- }
90
- else if (ts.isFunctionDeclaration(stmt)
91
- || ts.isClassDeclaration(stmt)) {
92
- const declare = ts.getModifiers(stmt)?.find(modifier => modifier.kind === ts.SyntaxKind.DeclareKeyword);
93
- if (!stmt.name || declare) {
94
- return;
95
- }
96
- registerLocalBinding(stmt.name);
97
- }
98
- else if ((ts.isForOfStatement(stmt) || ts.isForInStatement(stmt))
99
- && ts.isVariableDeclarationList(stmt.initializer)) {
100
- walkVariableDeclaration(stmt.initializer.declarations[0], isRoot);
101
- }
102
- else if (ts.isLabeledStatement(stmt)
103
- && ts.isVariableDeclaration(stmt.statement)) {
104
- walkVariableDeclaration(stmt.statement, isRoot);
105
- }
106
- });
107
- }
108
- function walkVariableDeclaration(decl, isRoot = false) {
109
- const { initializer, name } = decl;
110
- const isDefineProps = isRoot
111
- && initializer
112
- && ts.isCallExpression(initializer)
113
- && initializer.expression.getText(ast) === 'defineProps';
114
- for (const { id } of (0, language_core_1.collectIdentifiers)(ts, name)) {
115
- if (isDefineProps) {
116
- excludedIds.add(id);
117
- }
118
- else {
119
- registerLocalBinding(id);
120
- }
121
- }
122
- }
123
- function walkFunctionDeclaration(node) {
124
- const { name, parameters } = node;
125
- if (name && ts.isIdentifier(name)) {
126
- registerLocalBinding(name);
127
- }
128
- for (const p of parameters) {
129
- for (const { id } of (0, language_core_1.collectIdentifiers)(ts, p)) {
130
- registerLocalBinding(id);
131
- }
132
- }
133
- }
134
- function walk(parent) {
135
- ts.forEachChild(parent, node => {
136
- if (enter(node) ?? true) {
137
- walk(node);
138
- leave(node);
139
- }
140
- });
141
- function enter(node) {
142
- if (parent) {
143
- parentStack.push(parent);
144
- }
145
- if (ts.isTypeLiteralNode(node)
146
- || ts.isTypeReferenceNode(node)) {
147
- return false;
148
- }
149
- if (ts.isFunctionLike(node)) {
150
- pushScope();
151
- walkFunctionDeclaration(node);
152
- if ('body' in node) {
153
- walkScope(node.body);
154
- }
155
- return;
156
- }
157
- if (ts.isCatchClause(node)) {
158
- pushScope();
159
- const { variableDeclaration: p } = node;
160
- if (p && ts.isIdentifier(p.name)) {
161
- registerLocalBinding(p.name);
162
- }
163
- walkScope(node.block);
164
- return;
165
- }
166
- if (ts.isBlock(node)
167
- && !ts.isFunctionLike(parent)
168
- && !ts.isCatchClause(parent)) {
169
- pushScope();
170
- walkScope(node);
171
- return;
172
- }
173
- if (ts.isIdentifier(node)
174
- && isReferencedIdentifier(node, parent)
175
- && !excludedIds.has(node)) {
176
- const name = node.text;
177
- if (currentScope[name]) {
178
- const isShorthand = ts.isShorthandPropertyAssignment(parent);
179
- references.push([node, isShorthand]);
180
- }
181
- }
182
- }
183
- function leave(node) {
184
- if (parent) {
185
- parentStack.pop();
186
- }
187
- if (ts.isFunctionLike(node)
188
- || ts.isCatchClause(node)
189
- || (ts.isBlock(node)
190
- && !ts.isFunctionLike(parent)
191
- && !ts.isCatchClause(parent))) {
192
- popScope();
193
- }
194
- }
195
- }
196
- // TODO: more conditions
197
- function isReferencedIdentifier(id, parent) {
198
- if (!parent) {
199
- return false;
200
- }
201
- if (id.text === 'arguments') {
202
- return false;
203
- }
204
- if (ts.isExpressionWithTypeArguments(parent)
205
- || ts.isInterfaceDeclaration(parent)
206
- || ts.isTypeAliasDeclaration(parent)
207
- || ts.isPropertySignature(parent)) {
208
- return false;
209
- }
210
- if (ts.isPropertyAccessExpression(parent)
211
- || ts.isPropertyAssignment(parent)
212
- || ts.isPropertyDeclaration(parent)) {
213
- if (parent.name === id) {
214
- return false;
215
- }
216
- }
217
- return true;
218
- }
219
- }
220
- //# sourceMappingURL=vue-destructured-props-hints.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=vue-diagnostic-global-types.js.map
@@ -1,2 +0,0 @@
1
- import type { LanguageServicePlugin } from '@volar/language-service';
2
- export declare function create(): LanguageServicePlugin;
@@ -1,109 +0,0 @@
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 vscode_uri_1 = require("vscode-uri");
6
- function create() {
7
- return {
8
- name: 'vue-document-links',
9
- capabilities: {
10
- documentLinkProvider: {},
11
- },
12
- create(context) {
13
- return {
14
- provideDocumentLinks(document) {
15
- const uri = vscode_uri_1.URI.parse(document.uri);
16
- const decoded = context.decodeEmbeddedDocumentUri(uri);
17
- const sourceScript = decoded && context.language.scripts.get(decoded[0]);
18
- const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
19
- if (!sourceScript?.generated || (virtualCode?.id !== 'template' && virtualCode?.id !== 'scriptsetup_raw')) {
20
- return;
21
- }
22
- const root = sourceScript.generated.root;
23
- if (!(root instanceof language_core_1.VueVirtualCode)) {
24
- return;
25
- }
26
- const { sfc } = root;
27
- const codegen = language_core_1.tsCodegen.get(sfc);
28
- const result = [];
29
- if (virtualCode.id === 'template') {
30
- const scopedClasses = codegen?.getGeneratedTemplate()?.scopedClasses ?? [];
31
- const styleClasses = new Map();
32
- const option = root.vueCompilerOptions.resolveStyleClassNames;
33
- for (let i = 0; i < sfc.styles.length; i++) {
34
- const style = sfc.styles[i];
35
- if (option === true || (option === 'scoped' && style.scoped)) {
36
- for (const className of style.classNames) {
37
- if (!styleClasses.has(className.text.slice(1))) {
38
- styleClasses.set(className.text.slice(1), []);
39
- }
40
- styleClasses.get(className.text.slice(1)).push({
41
- index: i,
42
- style,
43
- classOffset: className.offset,
44
- });
45
- }
46
- }
47
- }
48
- for (const { className, offset } of scopedClasses) {
49
- const styles = styleClasses.get(className);
50
- if (styles) {
51
- for (const style of styles) {
52
- const styleDocumentUri = context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index);
53
- const styleVirtualCode = sourceScript.generated.embeddedCodes.get('style_' + style.index);
54
- if (!styleVirtualCode) {
55
- continue;
56
- }
57
- const styleDocument = context.documents.get(styleDocumentUri, styleVirtualCode.languageId, styleVirtualCode.snapshot);
58
- const start = styleDocument.positionAt(style.classOffset);
59
- const end = styleDocument.positionAt(style.classOffset + className.length + 1);
60
- result.push({
61
- range: {
62
- start: document.positionAt(offset),
63
- end: document.positionAt(offset + className.length),
64
- },
65
- target: context.encodeEmbeddedDocumentUri(decoded[0], 'style_' + style.index)
66
- + `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
67
- });
68
- }
69
- }
70
- }
71
- }
72
- else if (virtualCode.id === 'scriptsetup_raw') {
73
- if (!sfc.scriptSetup) {
74
- return;
75
- }
76
- const templateVirtualCode = sourceScript.generated.embeddedCodes.get('template');
77
- if (!templateVirtualCode) {
78
- return;
79
- }
80
- const templateDocumentUri = context.encodeEmbeddedDocumentUri(decoded[0], 'template');
81
- const templateDocument = context.documents.get(templateDocumentUri, templateVirtualCode.languageId, templateVirtualCode.snapshot);
82
- const templateRefs = codegen?.getGeneratedTemplate()?.templateRefs;
83
- const useTemplateRefs = codegen?.getScriptSetupRanges()?.useTemplateRef ?? [];
84
- for (const { arg } of useTemplateRefs) {
85
- if (!arg) {
86
- continue;
87
- }
88
- const name = sfc.scriptSetup.content.slice(arg.start + 1, arg.end - 1);
89
- for (const { offset } of templateRefs?.get(name) ?? []) {
90
- const start = templateDocument.positionAt(offset);
91
- const end = templateDocument.positionAt(offset + name.length);
92
- result.push({
93
- range: {
94
- start: document.positionAt(arg.start + 1),
95
- end: document.positionAt(arg.end - 1),
96
- },
97
- target: templateDocumentUri
98
- + `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
99
- });
100
- }
101
- }
102
- }
103
- return result;
104
- },
105
- };
106
- },
107
- };
108
- }
109
- //# sourceMappingURL=vue-document-links.js.map
package/lib/types.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export declare enum TagNameCasing {
2
- Kebab = 0,
3
- Pascal = 1,
4
- }
5
- export declare enum AttrNameCasing {
6
- Kebab = 0,
7
- Camel = 1,
8
- }
9
- export declare const commands: {
10
- parseSfc: string;
11
- };
12
- export * from '@volar/language-service/lib/types';
13
- export * from '@vue/language-core/lib/types';
package/lib/types.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.commands = exports.AttrNameCasing = exports.TagNameCasing = void 0;
18
- var TagNameCasing;
19
- (function (TagNameCasing) {
20
- TagNameCasing[TagNameCasing["Kebab"] = 0] = "Kebab";
21
- TagNameCasing[TagNameCasing["Pascal"] = 1] = "Pascal";
22
- })(TagNameCasing || (exports.TagNameCasing = TagNameCasing = {}));
23
- var AttrNameCasing;
24
- (function (AttrNameCasing) {
25
- AttrNameCasing[AttrNameCasing["Kebab"] = 0] = "Kebab";
26
- AttrNameCasing[AttrNameCasing["Camel"] = 1] = "Camel";
27
- })(AttrNameCasing || (exports.AttrNameCasing = AttrNameCasing = {}));
28
- exports.commands = {
29
- parseSfc: 'vue.parseSfc',
30
- };
31
- // only export types of depend packages
32
- __exportStar(require("@volar/language-service/lib/types"), exports);
33
- __exportStar(require("@vue/language-core/lib/types"), exports);
34
- //# sourceMappingURL=types.js.map