01: package org.acm.seguin.refactor.type;
02:
03: import net.sourceforge.jrefactory.ast.SimpleNode;
04: import net.sourceforge.jrefactory.ast.ASTName;
05: import net.sourceforge.jrefactory.factory.NameFactory;
06: import org.acm.seguin.summary.query.GetTypeSummary;
07: import org.acm.seguin.summary.TypeSummary;
08: import org.acm.seguin.refactor.TransformAST;
09:
10: /**
11: * This object traverses the syntax tree and renames the types. An old and a
12: * new value are provided.
13: *
14: *@author Chris Seguin
15: *@created October 23, 1999
16: */
17: public class RenameTypeTransform extends TransformAST {
18: private ASTName oldName;
19: private ASTName newName;
20: private TypeSummary summary;
21:
22: /**
23: * Constructor for the RenameTypeTransform object
24: *
25: *@param oldValue the old name
26: *@param newValue the new name
27: *@param init Description of Parameter
28: */
29: public RenameTypeTransform(ASTName oldValue, ASTName newValue,
30: TypeSummary init) {
31: oldName = oldValue;
32: newName = newValue;
33: summary = init;
34: }
35:
36: /**
37: * Constructor for the RenameTypeTransform object
38: *
39: *@param oldPackageName the old package
40: *@param newPackageName Description of Parameter
41: *@param className Description of Parameter
42: */
43: public RenameTypeTransform(String oldPackageName,
44: String newPackageName, String className) {
45: newName = NameFactory.getName(newPackageName, className);
46: oldName = NameFactory.getName(oldPackageName, className);
47: summary = GetTypeSummary.query(oldPackageName, className);
48: }
49:
50: /**
51: * Constructor for the RenameTypeTransform object
52: *
53: *@param oldPackageName the old package
54: *@param newValue the new name
55: *@param init Description of Parameter
56: */
57: public RenameTypeTransform(String oldPackageName, ASTName newValue,
58: TypeSummary init) {
59: newName = newValue;
60: oldName = new ASTName();
61: oldName.fromString(oldPackageName);
62: oldName.addNamePart(newName
63: .getNamePart(newName.getNameSize() - 1));
64: summary = init;
65: }
66:
67: /**
68: * Update the syntax tree
69: *
70: *@param root the root of the syntax tree
71: */
72: public void update(SimpleNode root) {
73: RenameTypeVisitor rtv = new RenameTypeVisitor();
74: root.jjtAccept(rtv, new RenameTypeData(oldName, newName,
75: summary));
76: }
77: }
|