Comparing version 0.1.1 to 0.1.2
@@ -13,3 +13,3 @@ var Variable = require('./variable'); | ||
this.scope = scope; | ||
this.variable = scope.resolveVariable(Variable.extractName(node)); | ||
this.variable = scope.resolveVariable(Variable.extractId(node)); | ||
if (this.variable) { | ||
@@ -23,5 +23,6 @@ this.variable.references.push(this); | ||
case 'Identifier': | ||
case 'MemberExpression': | ||
case 'ThisExpression': | ||
return true; | ||
case 'MemberExpression': | ||
return Reference.isRequired(node.object); | ||
case 'CallExpression': | ||
@@ -28,0 +29,0 @@ case 'NewExpression': |
@@ -15,15 +15,14 @@ | ||
Variable.extractName = function(node) { | ||
Variable.extractId = function(node) { | ||
switch (node.type) { | ||
case 'Identifier': | ||
return node.name; | ||
case 'ThisExpression': | ||
return 'this'; | ||
return node; | ||
case 'MemberExpression': | ||
return Variable.extractName(node.object); | ||
return Variable.extractId(node.object); | ||
case 'CallExpression': | ||
case 'NewExpression': | ||
return Variable.extractName(node.callee); | ||
return Variable.extractId(node.callee); | ||
} | ||
throw new Error('Invalid node type: ' + node.type); | ||
}; |
{ | ||
"name": "ast-scope", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A JavaScript AST scope analyzer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11028