Permalink
Browse files

Clear scopes on AST before analysis

Issue #819
1 parent 141eba1 commit 3f4794d39aa87163cb96a43fa48635a0a6f16b95 @marijnh marijnh committed Dec 7, 2016
Showing with 12 additions and 1 deletion.
  1. +7 −0 lib/infer.js
  2. +5 −1 lib/tern.js
View
@@ -1160,6 +1160,13 @@
});
scopeGatherer.ForOfStatement = scopeGatherer.ForInStatement
+ function rmScope(node) { if (node.scope) node.scope = null }
+ var scopeClearer = {BlockStatement: rmScope, Function: rmScope, CatchClause: rmScope,
+ ForInStateMent: rmScope, ForStatement: rmScope}
+ exports.clearScopes = function(ast) {
+ walk.simple(ast, scopeClearer)
+ };
+
// CONSTRAINT GATHERING PASS
var propName = exports.propName = function(node, inferInScope) {
View
@@ -152,7 +152,10 @@
this.budgets = Object.create(null);
for (var i = 0; i < this.files.length; ++i) {
var file = this.files[i];
- file.scope = null;
+ if (file.scope) {
+ infer.clearScopes(file.ast);
+ file.scope = null;
+ }
}
this.signal("postReset");
},
@@ -294,6 +297,7 @@
if (text != null) {
if (known.scope) {
srv.needsPurge.push(name);
+ infer.clearScopes(known.ast);
known.scope = null;
}
updateText(known, text, srv);

0 comments on commit 3f4794d

Please sign in to comment.