Hi Ariya,
> I looked at the code, it's quite impressive :)
thanks. It has become rather more complex than I'd like for
something as fundamental as scoping.
I've had a quick look. Oddly, it has BlockStatement as scope starter,
and is missing CatchClause. So it doesn't look complete yet, but
could probably be completed and still be simpler than the code I
use for renaming in scope_utils.js. Indeed, even my own code for
scope tracking in tags.js was much simpler.
But there are oddities in JS scoping, like the interaction of var
and function declarations with function scope and catch scope
(function and catch scope differ, leading to further interactions,
some of which are best dealt with by ruling out otherwise
syntactically valid code).
And renaming deals with two scoped ASTs: before and after
renaming. One has to check that the name change does not
change the scope structure - renamed variable occurrences
must not be captured by existing binders, and the renamed
binder must not capture existing variable occurrences.
To support such validity checks, I had to track rather more
information than I'd like.
> and I'm sure Orion's Content Assist is doing related stuff.
Is the author on this list? I'd like to hear more about status and plans.
> My spare time is currently rather going on the negative side, I really
> like to complete my attempt on identifier highlight (see
>
http://code.google.com/p/esprima/issues/detail?id=98). Possiblly even
> extending it to a simple refactoring example. If I still struggle for
> this example, would you be willing to donate your binding scope
> resolving routine for Esprima example?
Interesting. I am planning to make estr usable as a library for JS
code, including browser code (the fs dependency is already factored
out, but I have to decide on the module format), and that would be a
good example. I want to get some practice with codemirror, too. Do
you want to import estr into esprima, or do you want to wait until I
get round to hack up such an example in estr?
If the former, just let me know what format you prefer for the
information. Currently, scope_utils.js findVar logs to stdout (estr's
undocumented 'findVar file.js var line column' command). It could
return a JS object representing the info. That should suffice for
identifier highlighting. Or you could adapt scope_utils.js rename
for the refactoring. I only ask that bug reports and fixes get
forwarded to estr;-)
Meanwhile, I guess I will have to look for testers more widely,
probably on js-tools.
Claus