Removes the current path.
Visistor:
BooleanLiteral(path) {
path.remove();
}
In:
var bar;
true
Out:
var bar;
Replaces the current path with an array of nodes.
Visistor:
BooleanLiteral(path) {
const nodes = [
t.identifier("foo"),
t.identifier("bar")
];
path.replaceWithMultiple(nodes);
}
In:
true
Out:
foo
bar
Replaces the current path with the replacement. Replacement will be parsed and must be an expression.
Visistor:
BooleanLiteral(path) {
path.replaceWithSourceString('Date.now()')
}
In:
true
Out:
Date.now()
Replaces the current path a node.
Visistor:
BooleanLiteral(path) {
path.replaceWithMultiple(t.identifier("bar"));
}
In:
true
Out:
bar
Inserts nodes before the current one.
Visistor:
BooleanLiteral(path) {
const nodes = [
t.returnStatement()
];
path.insertBefore(nodes);
}
In:
true
Out:
return;
true
Inserts nodes after the current one.
Generates an uniq ID and returns it as an identifier.
Visistor:
Identifier(path) {
path.node.name = path.scope.generateUidIdentifier().name;
}
In:
var foo = "test";
Out:
var _temp = "test";
Generates an uniq ID and returns it as a string.
Visistor:
Identifier(path) {
path.node.name = path.scope.generateUid();
}
In:
var foo = "test";
Out:
var _temp = "test";
Generates an uniq ID based on the name of the node and returns it as an identifier.
Visistor:
Identifier(path) {
path.node.name = path.scope.generateUidIdentifierBasedOnNode(path.node).name;
}
In:
var foo = "test";
Out:
var _foo = "test";
Rename the given name in the current scope.
Visistor:
Identifier(path) {
path.scope.rename("foo");
}
In:
var foo = "test";
Out:
var _foo = "test";
Returns true if a label matches the name exists in the current scope.
Visistor:
BooleanLiteral(path) {
console.log(path.scope.hasLabel("foo"))
}
In:
foo: {
true // log false
}
Returns the label matching the name from the current scope.
Visistor:
Program(path) {
console.log(path.scope.getLabel("foo"))
}
In:
foo: {
}
Returns the binding matching the name.
Returns the identifier matching the name.
Returns the identifier matching the name in the current scope.
Returns true if an identifier matches the name in the current scope.
Returns true if an identifier matches the name in the parent scope.
Moves a binding to a given scope.