01: package org.acm.seguin.refactor.field;
02:
03: import net.sourceforge.jrefactory.ast.ASTClassBody;
04: import net.sourceforge.jrefactory.ast.ASTInterfaceBody;
05: import net.sourceforge.jrefactory.ast.SimpleNode;
06: import net.sourceforge.jrefactory.parser.ChildrenVisitor;
07:
08: /**
09: * Adds a field to the tree
10: *
11: *@author Chris Seguin
12: */
13: public class AddFieldVisitor extends ChildrenVisitor {
14: private SimpleNode field;
15:
16: /**
17: * Constructor for the AddFieldVisitor object
18: *
19: *@param init Description of Parameter
20: */
21: public AddFieldVisitor(SimpleNode init) {
22: field = init;
23: }
24:
25: /**
26: * Visit a class body
27: *
28: *@param node the class body node
29: *@param data the data for the visitor
30: *@return always returns null
31: */
32: public Object visit(ASTClassBody node, Object data) {
33: node.jjtInsertChild(field, node.jjtGetNumChildren());
34: return null;
35: }
36:
37: /**
38: * Visit an interface body
39: *
40: *@param node the interface body node
41: *@param data data for the visitor
42: *@return always returns null
43: */
44: public Object visit(ASTInterfaceBody node, Object data) {
45: node.jjtInsertChild(field, node.jjtGetNumChildren());
46: return null;
47: }
48: }
|