|
Lines 6039-6045
Link Here
|
| 6039 |
buf.append("import java.lang.annotation.ElementType;\n"); |
6039 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6040 |
buf.append("public class E {\n"); |
6040 |
buf.append("public class E {\n"); |
| 6041 |
buf.append(" public void foo() {\n"); |
6041 |
buf.append(" public void foo() {\n"); |
| 6042 |
buf.append(" int [] i [] @Annot1 @Annot2 [] @Annot1 @Annot3 [] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size()] @Annot2 @Annot1 [][]@Annot3 @Annot2 @Annot1 [];\n"); |
6042 |
buf.append(" int [] i []@Annot1 @Annot2 [] @Annot1 @Annot3 [] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size()] @Annot2 @Annot1 [][] @Annot3 @Annot2 @Annot1 [];\n"); |
| 6043 |
buf.append(" int [] j [][] = new int @Annot2 [2] @Annot2 [] @Annot1 [], k [][] = new int [2] [10] [size()];\n"); |
6043 |
buf.append(" int [] j [][] = new int @Annot2 [2] @Annot2 [] @Annot1 [], k [][] = new int [2] [10] [size()];\n"); |
| 6044 |
buf.append(" }\n"); |
6044 |
buf.append(" }\n"); |
| 6045 |
buf.append(" public int size() { return 2; }\n"); |
6045 |
buf.append(" public int size() { return 2; }\n"); |
|
Lines 6059-6065
Link Here
|
| 6059 |
buf.append("import java.lang.annotation.ElementType;\n"); |
6059 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6060 |
buf.append("public class E {\n"); |
6060 |
buf.append("public class E {\n"); |
| 6061 |
buf.append(" public void foo() {\n"); |
6061 |
buf.append(" public void foo() {\n"); |
| 6062 |
buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[][]{})] [];\n"); |
6062 |
buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2]@Annot2 @Annot3[size(new int[][]{})] [];\n"); |
| 6063 |
buf.append(" int [] j [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[]{})] @Annot1 @Annot3 [], k [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [10] @Annot1 @Annot3 [size(new int[][]{})];\n"); |
6063 |
buf.append(" int [] j [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[]{})] @Annot1 @Annot3 [], k [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [10] @Annot1 @Annot3 [size(new int[][]{})];\n"); |
| 6064 |
buf.append(" }\n"); |
6064 |
buf.append(" }\n"); |
| 6065 |
buf.append(" public int size(Object obj) { return 2; }\n"); |
6065 |
buf.append(" public int size(Object obj) { return 2; }\n"); |
|
Lines 6094-6100
Link Here
|
| 6094 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
6094 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6095 |
listRewrite.remove((ASTNode)dim.annotations().get(0), null); |
6095 |
listRewrite.remove((ASTNode)dim.annotations().get(0), null); |
| 6096 |
listRewrite.remove((ASTNode)dim.annotations().get(1), null); |
6096 |
listRewrite.remove((ASTNode)dim.annotations().get(1), null); |
| 6097 |
rewrite.set(creation, ArrayCreation.TYPE_PROPERTY, arrayType, null); |
|
|
| 6098 |
} |
6097 |
} |
| 6099 |
{ |
6098 |
{ |
| 6100 |
statement = (VariableDeclarationStatement) statements.get(1); |
6099 |
statement = (VariableDeclarationStatement) statements.get(1); |
|
Lines 6120-6126
Link Here
|
| 6120 |
buf.append("import java.lang.annotation.ElementType;\n"); |
6119 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6121 |
buf.append("public class E {\n"); |
6120 |
buf.append("public class E {\n"); |
| 6122 |
buf.append(" public void foo() {\n"); |
6121 |
buf.append(" public void foo() {\n"); |
| 6123 |
buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2] [size(new int[][]{})] [];\n"); |
6122 |
buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2][size(new int[][]{})] [];\n"); |
| 6124 |
buf.append(" int [] j [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[]{})], k [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [10];\n"); |
6123 |
buf.append(" int [] j [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[]{})], k [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [10];\n"); |
| 6125 |
buf.append(" }\n"); |
6124 |
buf.append(" }\n"); |
| 6126 |
buf.append(" public int size(Object obj) { return 2; }\n"); |
6125 |
buf.append(" public int size(Object obj) { return 2; }\n"); |
|
Lines 6156-6162
Link Here
|
| 6156 |
assertTrue("Incorrect Formatting", doc.get().equals(formattedString)); |
6155 |
assertTrue("Incorrect Formatting", doc.get().equals(formattedString)); |
| 6157 |
} |
6156 |
} |
| 6158 |
|
6157 |
|
| 6159 |
} |
6158 |
public void testBug417923a_since_8() throws Exception { |
|
|
6159 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6160 |
StringBuffer buf= new StringBuffer(); |
| 6161 |
buf.append("package test1;\n"); |
| 6162 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6163 |
buf.append("public class X {\n"); |
| 6164 |
buf.append(" public void foo() {\n"); |
| 6165 |
buf.append(" int [] i [][] = new int @Annot1[][][];\n"); |
| 6166 |
buf.append(" int [] j [][] = new int @Annot1 [][][];\n"); |
| 6167 |
buf.append(" int [] k [][] = new int @Annot1 [][][];\n"); |
| 6168 |
buf.append(" int [] l [][] = new int /* comment @ [] */@Annot1[][][];\n"); |
| 6169 |
buf.append(" int [] m [][] = new int /* comment @ [] */ @Annot1[][][];\n"); |
| 6170 |
buf.append(" int [] n [][] = new int /* comment @ [] */ @Annot1 [][][];\n"); |
| 6171 |
buf.append(" int [] o [][] = new int @Annot1/* comment @ [] */[][][];\n"); |
| 6172 |
buf.append(" int [] p [][] = new int @Annot1 /* comment @ [] */ [][][];\n"); |
| 6173 |
buf.append(" int [] q [][] = new int @Annot1 /* comment @ [] */[][][];\n"); |
| 6174 |
buf.append(" }\n"); |
| 6175 |
buf.append("}\n"); |
| 6176 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6177 |
buf.append("@interface Annot1 {}\n"); |
| 6178 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6160 |
|
6179 |
|
|
|
6180 |
CompilationUnit astRoot= createAST(cu); |
| 6181 |
AST ast = astRoot.getAST(); |
| 6182 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6161 |
|
6183 |
|
|
|
6184 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6185 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6186 |
Block block= methodDecl.getBody(); |
| 6187 |
List statements= block.statements(); |
| 6162 |
|
6188 |
|
|
|
6189 |
for (int i = 0; i < 9; ++i) { |
| 6190 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6191 |
List fragments = statement.fragments(); |
| 6192 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6193 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6194 |
ArrayType arrayType = ast.newArrayType(ast.newPrimitiveType(PrimitiveType.INT), 3); |
| 6195 |
rewrite.set(creation, ArrayCreation.TYPE_PROPERTY, arrayType, null); |
| 6196 |
} |
| 6197 |
|
| 6198 |
String preview= evaluateRewrite(cu, rewrite); |
| 6199 |
buf= new StringBuffer(); |
| 6200 |
buf.append("package test1;\n"); |
| 6201 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6202 |
buf.append("public class X {\n"); |
| 6203 |
buf.append(" public void foo() {\n"); |
| 6204 |
buf.append(" int [] i [][] = new int[][][];\n"); |
| 6205 |
buf.append(" int [] j [][] = new int[][][];\n"); |
| 6206 |
buf.append(" int [] k [][] = new int[][][];\n"); |
| 6207 |
buf.append(" int [] l [][] = new int[][][];\n"); |
| 6208 |
buf.append(" int [] m [][] = new int[][][];\n"); |
| 6209 |
buf.append(" int [] n [][] = new int[][][];\n"); |
| 6210 |
buf.append(" int [] o [][] = new int[][][];\n"); |
| 6211 |
buf.append(" int [] p [][] = new int[][][];\n"); |
| 6212 |
buf.append(" int [] q [][] = new int[][][];\n"); |
| 6213 |
buf.append(" }\n"); |
| 6214 |
buf.append("}\n"); |
| 6215 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6216 |
buf.append("@interface Annot1 {}\n"); |
| 6217 |
assertEqualString(preview, buf.toString()); |
| 6218 |
} |
| 6219 |
public void testBug417923b_since_8() throws Exception { |
| 6220 |
IPackageFragment pack1 = this.sourceFolder.createPackageFragment("test1", false, null); |
| 6221 |
StringBuffer buf= new StringBuffer(); |
| 6222 |
buf.append("package test1;\n"); |
| 6223 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6224 |
buf.append("public class X {\n"); |
| 6225 |
buf.append(" public void foo() {\n"); |
| 6226 |
buf.append(" int [] i [][] = new int[] @Annot1[][];\n"); |
| 6227 |
buf.append(" int [] j [][] = new int[] @Annot1 [][];\n"); |
| 6228 |
buf.append(" int [] k [][] = new int[] @Annot1 [][];\n"); |
| 6229 |
buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1[][];\n"); |
| 6230 |
buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1[][];\n"); |
| 6231 |
buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); |
| 6232 |
buf.append(" int [] o [][] = new int[] @Annot1/* comment @ [] */[][];\n"); |
| 6233 |
buf.append(" int [] p [][] = new int[] @Annot1 /* comment @ [] */ [][];\n"); |
| 6234 |
buf.append(" int [] q [][] = new int[] @Annot1 /* comment @ [] */[][];\n"); |
| 6235 |
buf.append(" }\n"); |
| 6236 |
buf.append("}\n"); |
| 6237 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6238 |
buf.append("@interface Annot1 {}\n"); |
| 6239 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6240 |
|
| 6241 |
CompilationUnit astRoot= createAST(cu); |
| 6242 |
AST ast = astRoot.getAST(); |
| 6243 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6244 |
|
| 6245 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6246 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6247 |
Block block= methodDecl.getBody(); |
| 6248 |
List statements= block.statements(); |
| 6249 |
|
| 6250 |
for (int i = 0; i < 9; ++i) { |
| 6251 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6252 |
List fragments = statement.fragments(); |
| 6253 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6254 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6255 |
ArrayType arrayType = ast.newArrayType(ast.newPrimitiveType(PrimitiveType.INT), 3); |
| 6256 |
rewrite.set(creation, ArrayCreation.TYPE_PROPERTY, arrayType, null); |
| 6257 |
} |
| 6258 |
|
| 6259 |
String preview= evaluateRewrite(cu, rewrite); |
| 6260 |
buf= new StringBuffer(); |
| 6261 |
buf.append("package test1;\n"); |
| 6262 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6263 |
buf.append("public class X {\n"); |
| 6264 |
buf.append(" public void foo() {\n"); |
| 6265 |
buf.append(" int [] i [][] = new int[][][];\n"); |
| 6266 |
buf.append(" int [] j [][] = new int[][][];\n"); |
| 6267 |
buf.append(" int [] k [][] = new int[][][];\n"); |
| 6268 |
buf.append(" int [] l [][] = new int[][][];\n"); |
| 6269 |
buf.append(" int [] m [][] = new int[][][];\n"); |
| 6270 |
buf.append(" int [] n [][] = new int[][][];\n"); |
| 6271 |
buf.append(" int [] o [][] = new int[][][];\n"); |
| 6272 |
buf.append(" int [] p [][] = new int[][][];\n"); |
| 6273 |
buf.append(" int [] q [][] = new int[][][];\n"); |
| 6274 |
buf.append(" }\n"); |
| 6275 |
buf.append("}\n"); |
| 6276 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6277 |
buf.append("@interface Annot1 {}\n"); |
| 6278 |
assertEqualString(preview, buf.toString()); |
| 6279 |
} |
| 6280 |
|
| 6281 |
public void testBug417923c_since_8() throws Exception { |
| 6282 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6283 |
StringBuffer buf= new StringBuffer(); |
| 6284 |
buf.append("package test1;\n"); |
| 6285 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6286 |
buf.append("public class X {\n"); |
| 6287 |
buf.append(" public void foo() {\n"); |
| 6288 |
buf.append(" int [] i [][] = new int @Annot1[][][];\n"); |
| 6289 |
buf.append(" int [] j [][] = new int @Annot1 [][][];\n"); |
| 6290 |
buf.append(" int [] k [][] = new int @Annot1 [][][];\n"); |
| 6291 |
buf.append(" int [] l [][] = new int /* comment @ [] */@Annot1[][][];\n"); |
| 6292 |
buf.append(" int [] m [][] = new int /* comment @ [] */ @Annot1[][][];\n"); |
| 6293 |
buf.append(" int [] n [][] = new int /* comment @ [] */ @Annot1 [][][];\n"); |
| 6294 |
buf.append(" int [] o [][] = new int @Annot1/* comment @ [] */[][][];\n"); |
| 6295 |
buf.append(" int [] p [][] = new int @Annot1 /* comment @ [] */ [][][];\n"); |
| 6296 |
buf.append(" int [] q [][] = new int @Annot1 /* comment @ [] */[][][];\n"); |
| 6297 |
buf.append(" }\n"); |
| 6298 |
buf.append("}\n"); |
| 6299 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6300 |
buf.append("@interface Annot1 {}\n"); |
| 6301 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6302 |
|
| 6303 |
CompilationUnit astRoot= createAST(cu); |
| 6304 |
AST ast = astRoot.getAST(); |
| 6305 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6306 |
|
| 6307 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6308 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6309 |
Block block= methodDecl.getBody(); |
| 6310 |
List statements= block.statements(); |
| 6311 |
|
| 6312 |
for (int i = 0; i < 9; ++i) { |
| 6313 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6314 |
List fragments = statement.fragments(); |
| 6315 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6316 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6317 |
ArrayType arrayType = creation.getType(); |
| 6318 |
|
| 6319 |
Dimension dim = (Dimension) arrayType.dimensions().get(0); |
| 6320 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6321 |
listRewrite.remove((ASTNode)dim.annotations().get(0), null); |
| 6322 |
} |
| 6323 |
|
| 6324 |
String preview= evaluateRewrite(cu, rewrite); |
| 6325 |
buf= new StringBuffer(); |
| 6326 |
buf.append("package test1;\n"); |
| 6327 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6328 |
buf.append("public class X {\n"); |
| 6329 |
buf.append(" public void foo() {\n"); |
| 6330 |
buf.append(" int [] i [][] = new int[][][];\n"); |
| 6331 |
buf.append(" int [] j [][] = new int[][][];\n"); |
| 6332 |
buf.append(" int [] k [][] = new int[][][];\n"); |
| 6333 |
buf.append(" int [] l [][] = new int [][][];\n"); |
| 6334 |
buf.append(" int [] m [][] = new int /* comment @ [] */[][][];\n"); |
| 6335 |
buf.append(" int [] n [][] = new int /* comment @ [] */[][][];\n"); |
| 6336 |
buf.append(" int [] o [][] = new int/* comment @ [] */[][][];\n"); |
| 6337 |
buf.append(" int [] p [][] = new int/* comment @ [] */ [][][];\n"); |
| 6338 |
buf.append(" int [] q [][] = new int/* comment @ [] */[][][];\n"); |
| 6339 |
buf.append(" }\n"); |
| 6340 |
buf.append("}\n"); |
| 6341 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6342 |
buf.append("@interface Annot1 {}\n"); |
| 6343 |
assertEqualString(preview, buf.toString()); |
| 6344 |
} |
| 6345 |
|
| 6346 |
public void testBug417923d_since_8() throws Exception { |
| 6347 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6348 |
StringBuffer buf= new StringBuffer(); |
| 6349 |
buf.append("package test1;\n"); |
| 6350 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6351 |
buf.append("public class X {\n"); |
| 6352 |
buf.append(" public void foo() {\n"); |
| 6353 |
buf.append(" int [] i [][] = new int[] @Annot1[][];\n"); |
| 6354 |
buf.append(" int [] j [][] = new int[] @Annot1 [][];\n"); |
| 6355 |
buf.append(" int [] k [][] = new int[] @Annot1 [][];\n"); |
| 6356 |
buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1[][];\n"); |
| 6357 |
buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1[][];\n"); |
| 6358 |
buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); |
| 6359 |
buf.append(" int [] o [][] = new int[] @Annot1/* comment @ [] */[][];\n"); |
| 6360 |
buf.append(" int [] p [][] = new int[] @Annot1 /* comment @ [] */ [][];\n"); |
| 6361 |
buf.append(" int [] q [][] = new int[] @Annot1 /* comment @ [] */[][];\n"); |
| 6362 |
buf.append(" }\n"); |
| 6363 |
buf.append("}\n"); |
| 6364 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6365 |
buf.append("@interface Annot1 {}\n"); |
| 6366 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6367 |
|
| 6368 |
CompilationUnit astRoot= createAST(cu); |
| 6369 |
AST ast = astRoot.getAST(); |
| 6370 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6371 |
|
| 6372 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6373 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6374 |
Block block= methodDecl.getBody(); |
| 6375 |
List statements= block.statements(); |
| 6376 |
|
| 6377 |
for (int i = 0; i < 9; ++i) { |
| 6378 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6379 |
List fragments = statement.fragments(); |
| 6380 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6381 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6382 |
ArrayType arrayType = creation.getType(); |
| 6383 |
|
| 6384 |
Dimension dim = (Dimension) arrayType.dimensions().get(1); |
| 6385 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6386 |
listRewrite.remove((ASTNode)dim.annotations().get(0), null); |
| 6387 |
} |
| 6388 |
|
| 6389 |
String preview= evaluateRewrite(cu, rewrite); |
| 6390 |
buf= new StringBuffer(); |
| 6391 |
buf.append("package test1;\n"); |
| 6392 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6393 |
buf.append("public class X {\n"); |
| 6394 |
buf.append(" public void foo() {\n"); |
| 6395 |
buf.append(" int [] i [][] = new int[][][];\n"); |
| 6396 |
buf.append(" int [] j [][] = new int[][][];\n"); |
| 6397 |
buf.append(" int [] k [][] = new int[][][];\n"); |
| 6398 |
buf.append(" int [] l [][] = new int[] [][];\n"); |
| 6399 |
buf.append(" int [] m [][] = new int[] /* comment @ [] */[][];\n"); |
| 6400 |
buf.append(" int [] n [][] = new int[] /* comment @ [] */[][];\n"); |
| 6401 |
buf.append(" int [] o [][] = new int[]/* comment @ [] */[][];\n"); |
| 6402 |
buf.append(" int [] p [][] = new int[]/* comment @ [] */ [][];\n"); |
| 6403 |
buf.append(" int [] q [][] = new int[]/* comment @ [] */[][];\n"); |
| 6404 |
buf.append(" }\n"); |
| 6405 |
buf.append("}\n"); |
| 6406 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6407 |
buf.append("@interface Annot1 {}\n"); |
| 6408 |
assertEqualString(preview, buf.toString()); |
| 6409 |
} |
| 6410 |
|
| 6411 |
public void testBug417923e_since_8() throws Exception { |
| 6412 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6413 |
StringBuffer buf= new StringBuffer(); |
| 6414 |
buf.append("package test1;\n"); |
| 6415 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6416 |
buf.append("public class X {\n"); |
| 6417 |
buf.append(" public void foo() {\n"); |
| 6418 |
buf.append(" int[][][] i = new int[][][];\n"); |
| 6419 |
buf.append(" int[][][] j = new int [][][];\n"); |
| 6420 |
buf.append(" int[][][] k = new int [][][];\n"); |
| 6421 |
buf.append(" int[][][] l = new int/* comment */[][][];\n"); |
| 6422 |
buf.append(" int[][][] m = new int /* comment [] */ [][][];\n"); |
| 6423 |
buf.append(" int[][][] n = new int /* comment [] */ [][][];\n"); |
| 6424 |
buf.append(" }\n"); |
| 6425 |
buf.append("}\n"); |
| 6426 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6427 |
buf.append("@interface Annot1 {}\n"); |
| 6428 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6429 |
|
| 6430 |
CompilationUnit astRoot= createAST(cu); |
| 6431 |
AST ast = astRoot.getAST(); |
| 6432 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6433 |
|
| 6434 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6435 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6436 |
Block block= methodDecl.getBody(); |
| 6437 |
List statements= block.statements(); |
| 6438 |
|
| 6439 |
for (int i = 0; i < 6; ++i) { |
| 6440 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6441 |
List fragments = statement.fragments(); |
| 6442 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6443 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6444 |
ArrayType arrayType = creation.getType(); |
| 6445 |
|
| 6446 |
Dimension dim = (Dimension) arrayType.dimensions().get(0); |
| 6447 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6448 |
MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); |
| 6449 |
markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); |
| 6450 |
listRewrite.insertAt(markerAnnotation, 0, null); |
| 6451 |
} |
| 6452 |
|
| 6453 |
String preview= evaluateRewrite(cu, rewrite); |
| 6454 |
buf= new StringBuffer(); |
| 6455 |
buf.append("package test1;\n"); |
| 6456 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6457 |
buf.append("public class X {\n"); |
| 6458 |
buf.append(" public void foo() {\n"); |
| 6459 |
buf.append(" int[][][] i = new int @Annot1 [][][];\n"); |
| 6460 |
buf.append(" int[][][] j = new int @Annot1 [][][];\n"); |
| 6461 |
buf.append(" int[][][] k = new int @Annot1 [][][];\n"); |
| 6462 |
buf.append(" int[][][] l = new int @Annot1 /* comment */[][][];\n"); |
| 6463 |
buf.append(" int[][][] m = new int @Annot1 /* comment [] */ [][][];\n"); |
| 6464 |
buf.append(" int[][][] n = new int @Annot1 /* comment [] */ [][][];\n"); |
| 6465 |
buf.append(" }\n"); |
| 6466 |
buf.append("}\n"); |
| 6467 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6468 |
buf.append("@interface Annot1 {}\n"); |
| 6469 |
assertEqualString(preview, buf.toString()); |
| 6470 |
} |
| 6471 |
|
| 6472 |
public void testBug417923f_since_8() throws Exception { |
| 6473 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6474 |
StringBuffer buf= new StringBuffer(); |
| 6475 |
buf.append("package test1;\n"); |
| 6476 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6477 |
buf.append("public class X {\n"); |
| 6478 |
buf.append(" public void foo() {\n"); |
| 6479 |
buf.append(" int[][][] i = new int[][][];\n"); |
| 6480 |
buf.append(" int[][][] j = new int[] [][];\n"); |
| 6481 |
buf.append(" int[][][] k = new int[] [][];\n"); |
| 6482 |
buf.append(" int[][][] l = new int[]/* comment */[][];\n"); |
| 6483 |
buf.append(" int[][][] m = new int[] /* comment [] */ [][];\n"); |
| 6484 |
buf.append(" int[][][] n = new int[] /* comment [] */ [][];\n"); |
| 6485 |
buf.append(" }\n"); |
| 6486 |
buf.append("}\n"); |
| 6487 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6488 |
buf.append("@interface Annot1 {}\n"); |
| 6489 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6490 |
|
| 6491 |
CompilationUnit astRoot= createAST(cu); |
| 6492 |
AST ast = astRoot.getAST(); |
| 6493 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6494 |
|
| 6495 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6496 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6497 |
Block block= methodDecl.getBody(); |
| 6498 |
List statements= block.statements(); |
| 6499 |
|
| 6500 |
for (int i = 0; i < 6; ++i) { |
| 6501 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6502 |
List fragments = statement.fragments(); |
| 6503 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6504 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6505 |
ArrayType arrayType = creation.getType(); |
| 6506 |
|
| 6507 |
Dimension dim = (Dimension) arrayType.dimensions().get(1); |
| 6508 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6509 |
MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); |
| 6510 |
markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); |
| 6511 |
listRewrite.insertAt(markerAnnotation, 0, null); |
| 6512 |
} |
| 6513 |
|
| 6514 |
String preview= evaluateRewrite(cu, rewrite); |
| 6515 |
buf= new StringBuffer(); |
| 6516 |
buf.append("package test1;\n"); |
| 6517 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6518 |
buf.append("public class X {\n"); |
| 6519 |
buf.append(" public void foo() {\n"); |
| 6520 |
buf.append(" int[][][] i = new int[] @Annot1 [][];\n"); |
| 6521 |
buf.append(" int[][][] j = new int[] @Annot1 [][];\n"); |
| 6522 |
buf.append(" int[][][] k = new int[] @Annot1 [][];\n"); |
| 6523 |
buf.append(" int[][][] l = new int[] @Annot1 /* comment */[][];\n"); |
| 6524 |
buf.append(" int[][][] m = new int[] @Annot1 /* comment [] */ [][];\n"); |
| 6525 |
buf.append(" int[][][] n = new int[] @Annot1 /* comment [] */ [][];\n"); |
| 6526 |
buf.append(" }\n"); |
| 6527 |
buf.append("}\n"); |
| 6528 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6529 |
buf.append("@interface Annot1 {}\n"); |
| 6530 |
assertEqualString(preview, buf.toString()); |
| 6531 |
} |
| 6532 |
|
| 6533 |
public void testBug417923g_since_8() throws Exception { |
| 6534 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6535 |
StringBuffer buf= new StringBuffer(); |
| 6536 |
buf.append("package test1;\n"); |
| 6537 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6538 |
buf.append("public class X {\n"); |
| 6539 |
buf.append(" public void foo() {\n"); |
| 6540 |
buf.append(" int[][][] i;\n"); |
| 6541 |
buf.append(" int [][][] j;\n"); |
| 6542 |
buf.append(" int [][][] k;\n"); |
| 6543 |
buf.append(" int/* comment */[][][] l;\n"); |
| 6544 |
buf.append(" int /* comment [] */ [][][] m;\n"); |
| 6545 |
buf.append(" int /* comment [] */ [][][] n;\n"); |
| 6546 |
buf.append(" }\n"); |
| 6547 |
buf.append("}\n"); |
| 6548 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6549 |
buf.append("@interface Annot1 {}\n"); |
| 6550 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6551 |
|
| 6552 |
CompilationUnit astRoot= createAST(cu); |
| 6553 |
AST ast = astRoot.getAST(); |
| 6554 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6555 |
|
| 6556 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6557 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6558 |
Block block= methodDecl.getBody(); |
| 6559 |
List statements= block.statements(); |
| 6560 |
|
| 6561 |
for (int i = 0; i < 6; ++i) { |
| 6562 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6563 |
ArrayType arrayType = (ArrayType) statement.getType(); |
| 6564 |
Dimension dim = (Dimension) arrayType.dimensions().get(0); |
| 6565 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6566 |
MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); |
| 6567 |
markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); |
| 6568 |
listRewrite.insertAt(markerAnnotation, 0, null); |
| 6569 |
} |
| 6570 |
String preview= evaluateRewrite(cu, rewrite); |
| 6571 |
buf= new StringBuffer(); |
| 6572 |
buf.append("package test1;\n"); |
| 6573 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6574 |
buf.append("public class X {\n"); |
| 6575 |
buf.append(" public void foo() {\n"); |
| 6576 |
buf.append(" int @Annot1 [][][] i;\n"); |
| 6577 |
buf.append(" int @Annot1 [][][] j;\n"); |
| 6578 |
buf.append(" int @Annot1 [][][] k;\n"); |
| 6579 |
buf.append(" int @Annot1 /* comment */[][][] l;\n"); |
| 6580 |
buf.append(" int @Annot1 /* comment [] */ [][][] m;\n"); |
| 6581 |
buf.append(" int @Annot1 /* comment [] */ [][][] n;\n"); |
| 6582 |
buf.append(" }\n"); |
| 6583 |
buf.append("}\n"); |
| 6584 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6585 |
buf.append("@interface Annot1 {}\n"); |
| 6586 |
assertEqualString(preview, buf.toString()); |
| 6587 |
} |
| 6588 |
public void testBug417923h_since_8() throws Exception { |
| 6589 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6590 |
StringBuffer buf= new StringBuffer(); |
| 6591 |
buf.append("package test1;\n"); |
| 6592 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6593 |
buf.append("public class X {\n"); |
| 6594 |
buf.append(" public void foo() {\n"); |
| 6595 |
buf.append(" int[][][] i;\n"); |
| 6596 |
buf.append(" int[] [][] j;\n"); |
| 6597 |
buf.append(" int[] [][] k;\n"); |
| 6598 |
buf.append(" int[]/* comment */[][] l;\n"); |
| 6599 |
buf.append(" int[] /* comment [] */ [][] m;\n"); |
| 6600 |
buf.append(" int[] /* comment [] */ [][] n;\n"); |
| 6601 |
buf.append(" }\n"); |
| 6602 |
buf.append("}\n"); |
| 6603 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6604 |
buf.append("@interface Annot1 {}\n"); |
| 6605 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6606 |
|
| 6607 |
CompilationUnit astRoot= createAST(cu); |
| 6608 |
AST ast = astRoot.getAST(); |
| 6609 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6610 |
|
| 6611 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6612 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6613 |
Block block= methodDecl.getBody(); |
| 6614 |
List statements= block.statements(); |
| 6615 |
|
| 6616 |
for (int i = 0; i < 6; ++i) { |
| 6617 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6618 |
ArrayType arrayType = (ArrayType) statement.getType(); |
| 6619 |
Dimension dim = (Dimension) arrayType.dimensions().get(1); |
| 6620 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6621 |
MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); |
| 6622 |
markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); |
| 6623 |
listRewrite.insertAt(markerAnnotation, 0, null); |
| 6624 |
} |
| 6625 |
String preview= evaluateRewrite(cu, rewrite); |
| 6626 |
buf= new StringBuffer(); |
| 6627 |
buf.append("package test1;\n"); |
| 6628 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6629 |
buf.append("public class X {\n"); |
| 6630 |
buf.append(" public void foo() {\n"); |
| 6631 |
buf.append(" int[] @Annot1 [][] i;\n"); |
| 6632 |
buf.append(" int[] @Annot1 [][] j;\n"); |
| 6633 |
buf.append(" int[] @Annot1 [][] k;\n"); |
| 6634 |
buf.append(" int[] @Annot1 /* comment */[][] l;\n"); |
| 6635 |
buf.append(" int[] @Annot1 /* comment [] */ [][] m;\n"); |
| 6636 |
buf.append(" int[] @Annot1 /* comment [] */ [][] n;\n"); |
| 6637 |
buf.append(" }\n"); |
| 6638 |
buf.append("}\n"); |
| 6639 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6640 |
buf.append("@interface Annot1 {}\n"); |
| 6641 |
assertEqualString(preview, buf.toString()); |
| 6642 |
} |
| 6643 |
|
| 6644 |
public void testBug417923i_since_8() throws Exception { |
| 6645 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6646 |
StringBuffer buf= new StringBuffer(); |
| 6647 |
buf.append("package test1;\n"); |
| 6648 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6649 |
buf.append("public class X {\n"); |
| 6650 |
buf.append(" public void foo() {\n"); |
| 6651 |
buf.append(" int @Annot1[][][] i;\n"); |
| 6652 |
buf.append(" int @Annot1 [][][] j;\n"); |
| 6653 |
buf.append(" int @Annot1 [][][] k;\n"); |
| 6654 |
buf.append(" int/* comment @ [] */@Annot1[][][] l;\n"); |
| 6655 |
buf.append(" int /* comment @ [] */ @Annot1[][][] m;\n"); |
| 6656 |
buf.append(" int /* comment @ [] */ @Annot1 [][][] n;\n"); |
| 6657 |
buf.append(" int @Annot1/* comment @ [] */[][][] o;\n"); |
| 6658 |
buf.append(" int @Annot1 /* comment @ [] */ [][][] p;\n"); |
| 6659 |
buf.append(" int @Annot1 /* comment @ [] */[][][] q;\n"); |
| 6660 |
buf.append(" }\n"); |
| 6661 |
buf.append("}\n"); |
| 6662 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6663 |
buf.append("@interface Annot1 {}\n"); |
| 6664 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6665 |
|
| 6666 |
CompilationUnit astRoot= createAST(cu); |
| 6667 |
AST ast = astRoot.getAST(); |
| 6668 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6669 |
|
| 6670 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6671 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6672 |
Block block= methodDecl.getBody(); |
| 6673 |
List statements= block.statements(); |
| 6674 |
|
| 6675 |
for (int i = 0; i < 9; ++i) { |
| 6676 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6677 |
ArrayType arrayType = (ArrayType) statement.getType(); |
| 6678 |
Dimension dim = (Dimension) arrayType.dimensions().get(0); |
| 6679 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6680 |
listRewrite.remove((ASTNode) dim.annotations().get(0), null); |
| 6681 |
} |
| 6682 |
String preview= evaluateRewrite(cu, rewrite); |
| 6683 |
buf= new StringBuffer(); |
| 6684 |
buf.append("package test1;\n"); |
| 6685 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6686 |
buf.append("public class X {\n"); |
| 6687 |
buf.append(" public void foo() {\n"); |
| 6688 |
buf.append(" int[][][] i;\n"); |
| 6689 |
buf.append(" int[][][] j;\n"); |
| 6690 |
buf.append(" int[][][] k;\n"); |
| 6691 |
buf.append(" int[][][] l;\n"); |
| 6692 |
buf.append(" int /* comment @ [] */[][][] m;\n"); |
| 6693 |
buf.append(" int /* comment @ [] */[][][] n;\n"); |
| 6694 |
buf.append(" int/* comment @ [] */[][][] o;\n"); |
| 6695 |
buf.append(" int/* comment @ [] */ [][][] p;\n"); |
| 6696 |
buf.append(" int/* comment @ [] */[][][] q;\n"); |
| 6697 |
buf.append(" }\n"); |
| 6698 |
buf.append("}\n"); |
| 6699 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6700 |
buf.append("@interface Annot1 {}\n"); |
| 6701 |
assertEqualString(preview, buf.toString()); |
| 6702 |
} |
| 6703 |
|
| 6704 |
public void testBug417923j_since_8() throws Exception { |
| 6705 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6706 |
StringBuffer buf= new StringBuffer(); |
| 6707 |
buf.append("package test1;\n"); |
| 6708 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6709 |
buf.append("public class X {\n"); |
| 6710 |
buf.append(" public void foo() {\n"); |
| 6711 |
buf.append(" int[] @Annot1[][] i;\n"); |
| 6712 |
buf.append(" int[] @Annot1 [][] j;\n"); |
| 6713 |
buf.append(" int[] @Annot1 [][] k;\n"); |
| 6714 |
buf.append(" int[]/* comment @ [] */@Annot1[][] l;\n"); |
| 6715 |
buf.append(" int[] /* comment @ [] */ @Annot1[][] m;\n"); |
| 6716 |
buf.append(" int[] /* comment @ [] */ @Annot1 [][] n;\n"); |
| 6717 |
buf.append(" int[] @Annot1/* comment @ [] */[][] o;\n"); |
| 6718 |
buf.append(" int[] @Annot1 /* comment @ [] */ [][] p;\n"); |
| 6719 |
buf.append(" int[] @Annot1 /* comment @ [] */[][] q;\n"); |
| 6720 |
buf.append(" }\n"); |
| 6721 |
buf.append("}\n"); |
| 6722 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6723 |
buf.append("@interface Annot1 {}\n"); |
| 6724 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6725 |
|
| 6726 |
CompilationUnit astRoot= createAST(cu); |
| 6727 |
AST ast = astRoot.getAST(); |
| 6728 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6729 |
|
| 6730 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6731 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6732 |
Block block= methodDecl.getBody(); |
| 6733 |
List statements= block.statements(); |
| 6734 |
|
| 6735 |
for (int i = 0; i < 9; ++i) { |
| 6736 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6737 |
ArrayType arrayType = (ArrayType) statement.getType(); |
| 6738 |
Dimension dim = (Dimension) arrayType.dimensions().get(1); |
| 6739 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6740 |
listRewrite.remove((ASTNode) dim.annotations().get(0), null); |
| 6741 |
} |
| 6742 |
String preview= evaluateRewrite(cu, rewrite); |
| 6743 |
buf= new StringBuffer(); |
| 6744 |
buf.append("package test1;\n"); |
| 6745 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6746 |
buf.append("public class X {\n"); |
| 6747 |
buf.append(" public void foo() {\n"); |
| 6748 |
buf.append(" int[][][] i;\n"); |
| 6749 |
buf.append(" int[][][] j;\n"); |
| 6750 |
buf.append(" int[][][] k;\n"); |
| 6751 |
buf.append(" int[][][] l;\n"); |
| 6752 |
buf.append(" int[] /* comment @ [] */[][] m;\n"); |
| 6753 |
buf.append(" int[] /* comment @ [] */[][] n;\n"); |
| 6754 |
buf.append(" int[]/* comment @ [] */[][] o;\n"); |
| 6755 |
buf.append(" int[]/* comment @ [] */ [][] p;\n"); |
| 6756 |
buf.append(" int[]/* comment @ [] */[][] q;\n"); |
| 6757 |
buf.append(" }\n"); |
| 6758 |
buf.append("}\n"); |
| 6759 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6760 |
buf.append("@interface Annot1 {}\n"); |
| 6761 |
assertEqualString(preview, buf.toString()); |
| 6762 |
} |
| 6763 |
|
| 6764 |
public void testBug417923k_since_8() throws Exception { |
| 6765 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6766 |
StringBuffer buf= new StringBuffer(); |
| 6767 |
buf.append("package test1;\n"); |
| 6768 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6769 |
buf.append("public class X {\n"); |
| 6770 |
buf.append(" public void foo() {\n"); |
| 6771 |
buf.append(" int [] i [][] = new int[] @Annot1 @Annot2[][];\n"); |
| 6772 |
buf.append(" int [] j [][] = new int[] @Annot1 @Annot2[][];\n"); |
| 6773 |
buf.append(" int [] k [][] = new int[] @Annot1 @Annot2 [][];\n"); |
| 6774 |
buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1 @Annot2[][];\n"); |
| 6775 |
buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1 @Annot2 [][];\n"); |
| 6776 |
buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 @Annot2 [][];\n"); |
| 6777 |
buf.append(" int [] o [][] = new int[] @Annot1 @Annot2/* comment @ [] */[][];\n"); |
| 6778 |
buf.append(" int [] p [][] = new int[] @Annot1 @Annot2/* comment @ [] */ [][];\n"); |
| 6779 |
buf.append(" int [] q [][] = new int[] @Annot1 @Annot2/* comment @ [] */[][];\n"); |
| 6780 |
buf.append(" }\n"); |
| 6781 |
buf.append("}\n"); |
| 6782 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6783 |
buf.append("@interface Annot1 {}\n"); |
| 6784 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6785 |
|
| 6786 |
CompilationUnit astRoot= createAST(cu); |
| 6787 |
AST ast = astRoot.getAST(); |
| 6788 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6789 |
|
| 6790 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6791 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6792 |
Block block= methodDecl.getBody(); |
| 6793 |
List statements= block.statements(); |
| 6794 |
|
| 6795 |
for (int i = 0; i < 9; ++i) { |
| 6796 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6797 |
List fragments = statement.fragments(); |
| 6798 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6799 |
ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); |
| 6800 |
ArrayType arrayType = creation.getType(); |
| 6801 |
|
| 6802 |
Dimension dim = (Dimension) arrayType.dimensions().get(1); |
| 6803 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6804 |
listRewrite.remove((ASTNode)dim.annotations().get(1), null); |
| 6805 |
} |
| 6806 |
|
| 6807 |
String preview= evaluateRewrite(cu, rewrite); |
| 6808 |
buf= new StringBuffer(); |
| 6809 |
buf.append("package test1;\n"); |
| 6810 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6811 |
buf.append("public class X {\n"); |
| 6812 |
buf.append(" public void foo() {\n"); |
| 6813 |
buf.append(" int [] i [][] = new int[] @Annot1[][];\n"); |
| 6814 |
buf.append(" int [] j [][] = new int[] @Annot1[][];\n"); |
| 6815 |
buf.append(" int [] k [][] = new int[] @Annot1 [][];\n"); |
| 6816 |
buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1[][];\n"); |
| 6817 |
buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); |
| 6818 |
buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); |
| 6819 |
buf.append(" int [] o [][] = new int[] @Annot1/* comment @ [] */[][];\n"); |
| 6820 |
buf.append(" int [] p [][] = new int[] @Annot1/* comment @ [] */ [][];\n"); |
| 6821 |
buf.append(" int [] q [][] = new int[] @Annot1/* comment @ [] */[][];\n"); |
| 6822 |
buf.append(" }\n"); |
| 6823 |
buf.append("}\n"); |
| 6824 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6825 |
buf.append("@interface Annot1 {}\n"); |
| 6826 |
assertEqualString(preview, buf.toString()); |
| 6827 |
} |
| 6828 |
|
| 6829 |
public void testBug417923l_since_8() throws Exception { |
| 6830 |
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); |
| 6831 |
StringBuffer buf= new StringBuffer(); |
| 6832 |
buf.append("package test1;\n"); |
| 6833 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6834 |
buf.append("public class X {\n"); |
| 6835 |
buf.append(" public void foo() {\n"); |
| 6836 |
buf.append(" int[] @Annot1 @Annot2[][] i;\n"); |
| 6837 |
buf.append(" int[] @Annot1 @Annot2 [][] j;\n"); |
| 6838 |
buf.append(" int[] @Annot1 @Annot2 [][] k;\n"); |
| 6839 |
buf.append(" int[]/* comment @ [] */@Annot1 @Annot2[][] l;\n"); |
| 6840 |
buf.append(" int[] /* comment @ [] */ @Annot1 @Annot2 [][] m;\n"); |
| 6841 |
buf.append(" int[] /* comment @ [] */ @Annot1 @Annot2 [][] n;\n"); |
| 6842 |
buf.append(" int[] @Annot1 @Annot2/* comment @ [] */[][] o;\n"); |
| 6843 |
buf.append(" int[] @Annot1 @Annot2/* comment @ [] */ [][] p;\n"); |
| 6844 |
buf.append(" int[] @Annot1 @Annot2/* comment @ [] */[][] q;\n"); |
| 6845 |
buf.append(" }\n"); |
| 6846 |
buf.append("}\n"); |
| 6847 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6848 |
buf.append("@interface Annot1 {}\n"); |
| 6849 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
| 6850 |
|
| 6851 |
CompilationUnit astRoot= createAST(cu); |
| 6852 |
AST ast = astRoot.getAST(); |
| 6853 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 6854 |
|
| 6855 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6856 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6857 |
Block block= methodDecl.getBody(); |
| 6858 |
List statements= block.statements(); |
| 6859 |
|
| 6860 |
for (int i = 0; i < 9; ++i) { |
| 6861 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); |
| 6862 |
ArrayType arrayType = (ArrayType) statement.getType(); |
| 6863 |
Dimension dim = (Dimension) arrayType.dimensions().get(1); |
| 6864 |
ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); |
| 6865 |
listRewrite.remove((ASTNode) dim.annotations().get(1), null); |
| 6866 |
} |
| 6867 |
String preview= evaluateRewrite(cu, rewrite); |
| 6868 |
buf= new StringBuffer(); |
| 6869 |
buf.append("package test1;\n"); |
| 6870 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6871 |
buf.append("public class X {\n"); |
| 6872 |
buf.append(" public void foo() {\n"); |
| 6873 |
buf.append(" int[] @Annot1[][] i;\n"); |
| 6874 |
buf.append(" int[] @Annot1 [][] j;\n"); |
| 6875 |
buf.append(" int[] @Annot1 [][] k;\n"); |
| 6876 |
buf.append(" int[]/* comment @ [] */@Annot1[][] l;\n"); |
| 6877 |
buf.append(" int[] /* comment @ [] */ @Annot1 [][] m;\n"); |
| 6878 |
buf.append(" int[] /* comment @ [] */ @Annot1 [][] n;\n"); |
| 6879 |
buf.append(" int[] @Annot1/* comment @ [] */[][] o;\n"); |
| 6880 |
buf.append(" int[] @Annot1/* comment @ [] */ [][] p;\n"); |
| 6881 |
buf.append(" int[] @Annot1/* comment @ [] */[][] q;\n"); |
| 6882 |
buf.append(" }\n"); |
| 6883 |
buf.append("}\n"); |
| 6884 |
buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); |
| 6885 |
buf.append("@interface Annot1 {}\n"); |
| 6886 |
assertEqualString(preview, buf.toString()); |
| 6887 |
} |
| 6888 |
|
| 6889 |
} |