Javascript tool for working with Javascript code, using esprima. Estr has a commandline interface, using nodejs, but its modules can also be used from the browser. There is an in-browser demo showing scoped variable highlighting, navigation to variable occurrences, and variable renaming.
Estr currently supports:
-
generating scope-aware tags from esprima ASTs, for use with the scoped_tags Vim mode
-
renaming a variable (this will currently output the modified file to stdout instead of replacing the file)
-
find variable binding and other occurrences
node estr.js tags ..paths
traverse paths, extract tags from .js-files, write to file "tags"
node estr.js rename file.js oldName <line> <column> newName
rename oldName (at <line> <column>) to newName
node estr findVar file.js name <line> <column>
find binding and other occurrences for name
-
in rename, point to the beginning of an oldName occurrence; all oldName occurrences in the same scope will be renamed, provided that
- oldName/newName are valid Identifiers
- a binding for oldName is available
- no existing binding for newName in the same scope
- no existing occurrences of newName will be captured by renamed binding
- no renamed occurrences of oldName will be captured by existing binding
- renaming is not affected by same-name hoisting over catch (language edge case)