-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Scope.prototype.rename(oldName, newName) #133
Comments
FWIW, this is the implementation I use in jscodeshift: https://github.com/facebook/jscodeshift/blob/v0.3.8/src/collections/VariableDeclarator.js#L74-L102 |
Just for clarity, this is the problem I'm trying to solve. I have an object, var x = foo.a;
/*
Result:
var x = foo.b;
*/ I search for member expressions whereby the object matches var ref = foo;
ref.a;
/*
Desired result:
var ref = foo;
ref.b;
*/ |
This year is 2021, Not support scope rename? |
pr has been submitted. Add rename function into scope, like Babel function path.scope.rename(oldName, newName) |
@OliverJAsh asked on https://gitter.im/benjamn/recast if it was possible to determine what declaration(s) were responsible for a given variable reference.
Here's the code I came up with at first:
As I was writing it out, I realized the common case (renaming) could be accomplished with a much nicer API:
Open question: what should
Scope.prototype.rename
return? Perhaps a list of paths to references, since scanning for references in nested scopes is potentially expensive?The text was updated successfully, but these errors were encountered: