add Scope::getFunctionParent method
This commit is contained in:
@@ -299,11 +299,21 @@ Scope.prototype.push = function (opts) {
|
||||
*/
|
||||
|
||||
Scope.prototype.add = function (node) {
|
||||
var scope = this.getFunctionParent();
|
||||
scope._add(node, scope.references);
|
||||
};
|
||||
|
||||
/**
|
||||
* Walk up the scope tree until we hit either a Function or reach the
|
||||
* very top at hit Program.
|
||||
*/
|
||||
|
||||
Scope.prototype.getFunctionParent = function () {
|
||||
var scope = this;
|
||||
while (scope.parent && !t.isFunction(scope.block)) {
|
||||
scope = scope.parent;
|
||||
}
|
||||
scope._add(node, scope.references);
|
||||
return scope;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user