[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java 1.5



Hey there! 

I'm working with Java 1.5 Grammar provided by SableCC in its web page. My goal in this step is kind of duplicating each class which appears in a Java File, changing it's name and inheriting from the class itself.

For example

class A { }
class B { }

would generate the following classes:

class A_Validate extends A { }
class B_Validate extends B { }

I am creating a ANormalClassDeclaration node, to represent each of this new classes, and setting it's parameters equals to each main class. The problem is that when I make "newClass.setClassBody( mainClass.getClassBody() )" , the main class will no more have this class body. I mean, I don't want to remove main classes, only to add the new ones to the tree. I want to keep the same body in each pair of classes (main and generated one), but I think I must clone somehow the classes' bodies. Is there any easy way to solve my problem?

(for each class, final result in my program is now: class A class A_Validate extends A { } )




Thanks for the attention.

Best Regards,
Duarte Martins