@vue/language-service 3.3.2 → 3.3.4

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.
@@ -93,25 +93,34 @@ function create(ts) {
93
93
  function findDestructuredProps(ts, ast, props) {
94
94
  const rootScope = Object.create(null);
95
95
  const scopeStack = [rootScope];
96
+ const functionScopeStack = [rootScope];
96
97
  let currentScope = rootScope;
97
98
  const excludedIds = new WeakSet();
98
99
  for (const prop of props) {
99
100
  rootScope[prop] = true;
100
101
  }
101
- function pushScope() {
102
- scopeStack.push(currentScope = Object.create(currentScope));
102
+ function pushScope(isFunctionScope = false) {
103
+ const scope = currentScope = Object.create(currentScope);
104
+ scopeStack.push(scope);
105
+ if (isFunctionScope) {
106
+ functionScopeStack.push(scope);
107
+ }
103
108
  }
104
- function popScope() {
109
+ function popScope(isFunctionScope = false) {
105
110
  scopeStack.pop();
106
- currentScope = scopeStack[scopeStack.length - 1] || null;
111
+ if (isFunctionScope) {
112
+ functionScopeStack.pop();
113
+ }
114
+ currentScope = scopeStack.at(-1) || null;
107
115
  }
108
- function registerLocalBinding(id) {
116
+ function registerLocalBinding(id, scope = currentScope) {
109
117
  excludedIds.add(id);
110
- if (currentScope) {
111
- currentScope[id.text] = false;
118
+ if (scope) {
119
+ scope[id.text] = false;
112
120
  }
113
121
  }
114
122
  const references = [];
123
+ walkFunctionScopeVarDeclarations(ast, true);
115
124
  walkScope(ast, true);
116
125
  walk(ast);
117
126
  return references;
@@ -140,7 +149,7 @@ function findDestructuredProps(ts, ast, props) {
140
149
  }
141
150
  });
142
151
  }
143
- function walkVariableDeclaration(decl, isRoot = false) {
152
+ function walkVariableDeclaration(decl, isRoot = false, scope = currentScope) {
144
153
  const { initializer, name } = decl;
145
154
  const isDefineProps = isRoot
146
155
  && initializer
@@ -151,10 +160,30 @@ function findDestructuredProps(ts, ast, props) {
151
160
  excludedIds.add(id);
152
161
  }
153
162
  else {
154
- registerLocalBinding(id);
163
+ registerLocalBinding(id, scope);
155
164
  }
156
165
  }
157
166
  }
167
+ function walkFunctionScopeVarDeclarations(scopeNode, isRoot = false) {
168
+ const scope = functionScopeStack.at(-1);
169
+ walk(scopeNode);
170
+ function walk(parent) {
171
+ ts.forEachChild(parent, node => {
172
+ if (ts.isFunctionLike(node)
173
+ || ts.isClassDeclaration(node)
174
+ || ts.isClassExpression(node)) {
175
+ return;
176
+ }
177
+ if (ts.isVariableDeclarationList(node)
178
+ && !(node.flags & ts.NodeFlags.BlockScoped)) {
179
+ for (const decl of node.declarations) {
180
+ walkVariableDeclaration(decl, isRoot && node.parent.parent === scopeNode, scope);
181
+ }
182
+ }
183
+ walk(node);
184
+ });
185
+ }
186
+ }
158
187
  function walkFunctionDeclaration(node) {
159
188
  const { name, parameters } = node;
160
189
  if (name && ts.isIdentifier(name)) {
@@ -179,9 +208,10 @@ function findDestructuredProps(ts, ast, props) {
179
208
  return false;
180
209
  }
181
210
  if (ts.isFunctionLike(node)) {
182
- pushScope();
211
+ pushScope(true);
183
212
  walkFunctionDeclaration(node);
184
- if ('body' in node) {
213
+ if ('body' in node && node.body) {
214
+ walkFunctionScopeVarDeclarations(node.body);
185
215
  walkScope(node.body);
186
216
  }
187
217
  return;
@@ -213,8 +243,10 @@ function findDestructuredProps(ts, ast, props) {
213
243
  }
214
244
  }
215
245
  function leave(node) {
216
- if (ts.isFunctionLike(node)
217
- || ts.isCatchClause(node)
246
+ if (ts.isFunctionLike(node)) {
247
+ popScope(true);
248
+ }
249
+ else if (ts.isCatchClause(node)
218
250
  || (ts.isBlock(node)
219
251
  && !ts.isFunctionLike(parent)
220
252
  && !ts.isCatchClause(parent))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-service",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "data",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@volar/language-service": "2.4.28",
23
- "@vue/language-core": "3.3.2",
23
+ "@vue/language-core": "3.3.4",
24
24
  "@vue/shared": "^3.5.0",
25
25
  "path-browserify": "^1.0.1",
26
26
  "volar-service-css": "0.0.71",
@@ -39,9 +39,9 @@
39
39
  "@volar/kit": "2.4.28",
40
40
  "@volar/typescript": "2.4.28",
41
41
  "@vue/compiler-dom": "^3.5.0",
42
- "@vue/typescript-plugin": "3.3.2",
42
+ "@vue/typescript-plugin": "3.3.4",
43
43
  "vscode-css-languageservice": "^6.3.10",
44
- "vue-component-meta": "3.3.2"
44
+ "vue-component-meta": "3.3.4"
45
45
  },
46
- "gitHead": "7a00047bb6d133bf26fa6e916e856fdca40b3c49"
46
+ "gitHead": "043a77b6182db32f4076f84a767c1c674ef2b149"
47
47
  }