Lines 42-47
Link Here
|
42 |
|
42 |
|
43 |
import com.sun.source.tree.ClassTree; |
43 |
import com.sun.source.tree.ClassTree; |
44 |
import com.sun.source.tree.ExpressionTree; |
44 |
import com.sun.source.tree.ExpressionTree; |
|
|
45 |
import com.sun.source.tree.IdentifierTree; |
45 |
import com.sun.source.tree.MethodTree; |
46 |
import com.sun.source.tree.MethodTree; |
46 |
import com.sun.source.tree.ModifiersTree; |
47 |
import com.sun.source.tree.ModifiersTree; |
47 |
import com.sun.source.tree.TypeParameterTree; |
48 |
import com.sun.source.tree.TypeParameterTree; |
Lines 119-124
Link Here
|
119 |
assertEquals(golden, res); |
120 |
assertEquals(golden, res); |
120 |
} |
121 |
} |
121 |
|
122 |
|
|
|
123 |
public void testRewriteRewrittenTree2() throws Exception { |
124 |
testFile = new File(getWorkDir(), "Test.java"); |
125 |
TestUtilities.copyStringToFile(testFile, |
126 |
"package hierbas.del.litoral;\n\n" + |
127 |
"public class Test {\n" + |
128 |
" String a;\n" + |
129 |
"}\n" |
130 |
); |
131 |
String golden = |
132 |
"package hierbas.del.litoral;\n\n" + |
133 |
"public class Test {\n" + |
134 |
" Object a;\n" + |
135 |
"}\n"; |
136 |
JavaSource testSource = JavaSource.forFileObject(FileUtil.toFileObject(testFile)); |
137 |
Task<WorkingCopy> task = new Task<WorkingCopy>() { |
138 |
|
139 |
public void run(WorkingCopy workingCopy) throws java.io.IOException { |
140 |
workingCopy.toPhase(Phase.RESOLVED); |
141 |
TreeMaker make = workingCopy.getTreeMaker(); |
142 |
|
143 |
ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0); |
144 |
VariableTree var = (VariableTree) clazz.getMembers().get(1); |
145 |
IdentifierTree i = make.Identifier("Test"); |
146 |
|
147 |
workingCopy.rewrite(var.getType(), i); |
148 |
workingCopy.rewrite(i, make.Identifier("Object")); |
149 |
} |
150 |
|
151 |
}; |
152 |
testSource.runModificationTask(task).commit(); |
153 |
String res = TestUtilities.copyFileToString(testFile); |
154 |
System.err.println(res); |
155 |
assertEquals(golden, res); |
156 |
} |
157 |
|
122 |
String getGoldenPckg() { |
158 |
String getGoldenPckg() { |
123 |
return ""; |
159 |
return ""; |
124 |
} |
160 |
} |