01: /*
02: * Author: Chris Seguin
03: *
04: * This software has been developed under the copyleft
05: * rules of the GNU General Public License. Please
06: * consult the GNU General Public License for more
07: * details about use and distribution of this software.
08: */
09: package org.acm.seguin.refactor.method;
10:
11: import net.sourceforge.jrefactory.ast.ASTClassBody;
12: import net.sourceforge.jrefactory.ast.ASTInterfaceBody;
13: import net.sourceforge.jrefactory.ast.SimpleNode;
14: import net.sourceforge.jrefactory.parser.ChildrenVisitor;
15:
16: /**
17: * Adds a method to the tree
18: *
19: *@author Chris Seguin
20: */
21: public class AddMethodVisitor extends ChildrenVisitor {
22: private SimpleNode method;
23:
24: /**
25: * Constructor for the AddMethodVisitor object
26: *
27: *@param init Description of Parameter
28: */
29: public AddMethodVisitor(SimpleNode init) {
30: method = init;
31: }
32:
33: /**
34: * Visit a class body
35: *
36: *@param node the class body node
37: *@param data the data for the visitor
38: *@return always returns null
39: */
40: public Object visit(ASTClassBody node, Object data) {
41: node.jjtInsertChild(method, node.jjtGetNumChildren());
42: return null;
43: }
44:
45: /**
46: * Visit an interface body
47: *
48: *@param node the interface body node
49: *@param data data for the visitor
50: *@return always returns null
51: */
52: public Object visit(ASTInterfaceBody node, Object data) {
53: node.jjtInsertChild(method, node.jjtGetNumChildren());
54: return null;
55: }
56: }
|