On Feb 2, 2005, at 5:45 AM, martinus wrote:

> This is very cool. Would it be possible to use PraseTree for a
> refactoring toolkit?

Hrm. Not having written a refactoring toolkit, I can only speculate. 
I'd say it has an OK chance at it, but ParseTree itself is a very very 
thin layer to (what I'm guessing) is a lot of infrastructure needed to 
do a full refactoring tool.

The problem is that the parse tree doesn't preserve comments at all. 
This alone could make a good refactoring browser difficult. My guess is 
that you'd use ParseTree just for analysis and something like emacs or 
freeride to do the actual work.

As an aside, I wrote a (very) quick proof of concept for RubyInline 
that uses ParseTree. It is called Ruby2Ruby. It allows you to 
"translate" ruby into ruby by providing a to_ruby method on the Method 
class. By doing something like: obj.method(:meth).to_ruby you get a 
string back that is (as close as we can get it) a reconstruction of the 
method's source code. to_ruby is actually pretty small. It grabs the 
parse tree for the method in question, and runs it through a rather 
small (because it is incomplete) and simple (because SexpProcessor's 
architecture is really cool) class called RubyToRubyProcessor. Not much 
work. It took me roughly 30 minutes to get the PoC done.