In the last post I mentioned about a syntax-sensitive grep tool for code
searching. Lately, when digger around to find a nodejs refactoring tool, I found
graspjs, very similar tool out there.
Pretty much the exactly idea of sgrep, isn’t it? Graspjs is
aiming at code refactoring rather that searching. So it designs a little new
language of what you are searching and capturing. The backward of it is user
needs to learn something new. The good part is that with this little
domain-specific language, code structure is much esaier to address rather
regular expression. To me, the DSL is clear and easy to use if you got some
Though graspjs should be a great code searching tool. I don’t think it would be
sufficient as a refactoring tool. Handling code in grammar level (instead of
char sequence) is good. But it is not good enough for refactoring. Imagine you
want to rename a local variable, in grammar level you could say that you want to find
the declaration and usage of it and do the replace. The bad part is in the AST
you don’t have concept of scope. So if you declare another local variable in a
different scope with the same name, graspjs would replace both of them.
it as a refactor tool. You desire a better one.