clausreinke / estr

(repo no longer active) ESTR - ECMAScript traversals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESTR - ECMAScript traversals

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

Commandline usage

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

Assumptions

  • 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)

About

(repo no longer active) ESTR - ECMAScript traversals


Languages

Language:JavaScript 98.5%Language:Vim Script 1.5%