Lines 16-23
Link Here
|
16 |
|
16 |
|
17 |
import org.eclipse.jdt.core.ICompilationUnit; |
17 |
import org.eclipse.jdt.core.ICompilationUnit; |
18 |
import org.eclipse.jdt.core.IPackageFragment; |
18 |
import org.eclipse.jdt.core.IPackageFragment; |
19 |
|
19 |
import org.eclipse.jdt.core.dom.AST; |
20 |
import org.eclipse.jdt.core.dom.*; |
20 |
import org.eclipse.jdt.core.dom.ASTVisitor; |
|
|
21 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
22 |
import org.eclipse.jdt.core.dom.ImportDeclaration; |
23 |
import org.eclipse.jdt.core.dom.Name; |
24 |
import org.eclipse.jdt.core.dom.TypeDeclaration; |
21 |
|
25 |
|
22 |
public class ASTRewritingModifyingOtherTest extends ASTRewritingModifyingTest { |
26 |
public class ASTRewritingModifyingOtherTest extends ASTRewritingModifyingTest { |
23 |
private static final Class THIS = ASTRewritingModifyingOtherTest.class; |
27 |
private static final Class THIS = ASTRewritingModifyingOtherTest.class; |
Lines 186-234
Link Here
|
186 |
buf.append("}\n"); |
190 |
buf.append("}\n"); |
187 |
assertEqualString(preview, buf.toString()); |
191 |
assertEqualString(preview, buf.toString()); |
188 |
} |
192 |
} |
|
|
193 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308754 |
194 |
public void test0005() throws Exception { |
195 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0005", false, null); |
196 |
StringBuffer buf= new StringBuffer(); |
197 |
buf.append("package test0005;\n"); |
198 |
buf.append("@A(X.class) public class C {}"); |
199 |
ICompilationUnit cu= pack1.createCompilationUnit("C.java", buf.toString(), false, null); |
200 |
|
201 |
CompilationUnit astRoot= createCU(cu, true, AST.JLS3); |
202 |
astRoot.recordModifications(); |
203 |
{ |
204 |
// change to interface |
205 |
astRoot.accept(new ASTVisitor() { |
206 |
public boolean visit(TypeDeclaration node) { |
207 |
node.setInterface(true); |
208 |
return false; |
209 |
} |
210 |
}); |
211 |
} |
212 |
String preview= evaluateRewrite(cu, astRoot); |
213 |
|
214 |
buf= new StringBuffer(); |
215 |
buf.append("package test0005;\n"); |
216 |
buf.append("@A(X.class) public interface C {}"); |
217 |
assertEqualString(preview, buf.toString()); |
218 |
} |
219 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308754 |
220 |
public void test0006() throws Exception { |
221 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0006", false, null); |
222 |
StringBuffer buf= new StringBuffer(); |
223 |
buf.append("package test0006;\n"); |
224 |
buf.append("public @A(X.class) class C {}"); |
225 |
ICompilationUnit cu= pack1.createCompilationUnit("C.java", buf.toString(), false, null); |
226 |
|
227 |
CompilationUnit astRoot= createCU(cu, true, AST.JLS3); |
228 |
astRoot.recordModifications(); |
229 |
{ |
230 |
// change to interface |
231 |
astRoot.accept(new ASTVisitor() { |
232 |
public boolean visit(TypeDeclaration node) { |
233 |
node.setInterface(true); |
234 |
return false; |
235 |
} |
236 |
}); |
237 |
} |
238 |
String preview= evaluateRewrite(cu, astRoot); |
189 |
|
239 |
|
190 |
// public void _test000X() throws Exception { |
240 |
buf= new StringBuffer(); |
191 |
// IPackageFragment pack1= fSourceFolder.createPackageFragment("test0004", false, null); |
241 |
buf.append("package test0006;\n"); |
192 |
// StringBuffer buf= new StringBuffer(); |
242 |
buf.append("public @A(X.class) interface C {}"); |
193 |
// buf.append("package test0004;\n"); |
243 |
assertEqualString(preview, buf.toString()); |
194 |
// buf.append("\n"); |
244 |
} |
195 |
// buf.append("public class X {\n"); |
|
|
196 |
// buf.append(" void foo(){\n"); |
197 |
// buf.append(" //rien\n"); |
198 |
// buf.append(" \n"); |
199 |
// buf.append(" \n"); |
200 |
// buf.append(" \n"); |
201 |
// buf.append(" \n"); |
202 |
// buf.append(" }\n"); |
203 |
// buf.append("}\n"); |
204 |
// ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
205 |
// |
206 |
// CompilationUnit astRoot= parseCompilationUnit(cu, false); |
207 |
// |
208 |
// astRoot.recordModifications(); |
209 |
// |
210 |
// AST a = astRoot.getAST(); |
211 |
// |
212 |
// Comment[] comments = astRoot.getCommentTable(); |
213 |
// Comment comment1 = comments[0]; |
214 |
// Comment comment2 = a.newBlockComment(); |
215 |
// comment2.setSourceRange(comment1.getStartPosition(), comment1.getLength() - 2); |
216 |
// comments[0] = comment2; |
217 |
// |
218 |
// String preview = evaluateRewrite(cu, astRoot); |
219 |
// |
220 |
// buf= new StringBuffer(); |
221 |
// buf.append("package test0004;\n"); |
222 |
// buf.append("\n"); |
223 |
// buf.append("public class X {\n"); |
224 |
// buf.append("\n"); |
225 |
// buf.append("}\n"); |
226 |
// buf.append("class Y {\n"); |
227 |
// buf.append("\n"); |
228 |
// buf.append("}\n"); |
229 |
// buf.append("class Z {\n"); |
230 |
// buf.append("\n"); |
231 |
// buf.append("}\n"); |
232 |
// assertEqualString(preview, buf.toString()); |
233 |
// } |
234 |
} |
245 |
} |