add BindingIdentifier virtual type
This commit is contained in:
parent
708879ff1b
commit
52c3c143f9
@ -20,11 +20,8 @@ var visitor = {
|
|||||||
visitIdentifier(this, node, scope, state);
|
visitIdentifier(this, node, scope, state);
|
||||||
},
|
},
|
||||||
|
|
||||||
AssignmentExpression(node, parent, scope, state) {
|
BindingIdentifier(node, parent, scope, state) {
|
||||||
var ids = this.getBindingIdentifiers();
|
visitIdentifier(this, node, scope, state);
|
||||||
for (var name in ids) {
|
|
||||||
visitIdentifier(this, ids[name], scope, state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,13 @@ export var ReferencedIdentifier = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export var BindingIdentifier = {
|
||||||
|
types: ["Identifier"],
|
||||||
|
checkPath({ node, parent }, opts) {
|
||||||
|
return t.isBinding(node, parent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export var Expression = {
|
export var Expression = {
|
||||||
types: ["Expression"],
|
types: ["Expression"],
|
||||||
checkPath(path) {
|
checkPath(path) {
|
||||||
|
|||||||
@ -1,6 +1,20 @@
|
|||||||
|
import { getBindingIdentifiers } from "./retrievers";
|
||||||
import esutils from "esutils";
|
import esutils from "esutils";
|
||||||
import * as t from "./index";
|
import * as t from "./index";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function isBinding(node: Object, parent: Object): boolean {
|
||||||
|
var bindingKey = getBindingIdentifiers.keys[parent.type];
|
||||||
|
if (bindingKey) {
|
||||||
|
return parent[bindingKey] === node;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the input `node` is a reference to a bound variable.
|
* Check if the input `node` is a reference to a bound variable.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user