|
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 6120-6126
Link Here
|
| 6120 |
buf.append("import java.lang.annotation.ElementType;\n"); |
6120 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6121 |
buf.append("public class E {\n"); |
6121 |
buf.append("public class E {\n"); |
| 6122 |
buf.append(" public void foo() {\n"); |
6122 |
buf.append(" public void foo() {\n"); |
| 6123 |
buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2] [size(new int[][]{})] [];\n"); |
6123 |
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"); |
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"); |
| 6125 |
buf.append(" }\n"); |
6125 |
buf.append(" }\n"); |
| 6126 |
buf.append(" public int size(Object obj) { return 2; }\n"); |
6126 |
buf.append(" public int size(Object obj) { return 2; }\n"); |
|
Lines 6155-6160
Link Here
|
| 6155 |
edit.apply(doc); |
6155 |
edit.apply(doc); |
| 6156 |
assertTrue("Incorrect Formatting", doc.get().equals(formattedString)); |
6156 |
assertTrue("Incorrect Formatting", doc.get().equals(formattedString)); |
| 6157 |
} |
6157 |
} |
|
|
6158 |
public void testBug419723a_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 E {\n"); |
| 6164 |
buf.append(" public void foo() {\n"); |
| 6165 |
buf.append(" int i [][];\n"); |
| 6166 |
buf.append(" }\n"); |
| 6167 |
buf.append("}\n"); |
| 6168 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| 6169 |
|
| 6170 |
CompilationUnit astRoot= createAST(cu); |
| 6171 |
AST ast= astRoot.getAST(); |
| 6172 |
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); |
| 6173 |
|
| 6174 |
// Get while statement block |
| 6175 |
TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); |
| 6176 |
MethodDeclaration methodDecl= typeDecl.getMethods()[0]; |
| 6177 |
Block block= methodDecl.getBody(); |
| 6178 |
List statements= block.statements(); |
| 6179 |
|
| 6180 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(0); |
| 6181 |
List fragments = statement.fragments(); |
| 6182 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
| 6183 |
|
| 6184 |
{ |
| 6185 |
// Add new dimension with and without annotations |
| 6186 |
|
| 6187 |
ListRewrite listRewrite= rewrite.getListRewrite(fragment, VariableDeclarationFragment.EXTRA_DIMENSIONS2_PROPERTY); |
| 6188 |
Dimension dim = ast.newDimension(); |
| 6189 |
listRewrite.insertFirst(dim, null); |
| 6190 |
|
| 6191 |
} |
| 6192 |
// Get new code |
| 6193 |
String preview= evaluateRewrite(cu, rewrite); |
| 6194 |
|
| 6195 |
buf= new StringBuffer(); |
| 6196 |
buf.append("package test1;\n"); |
| 6197 |
buf.append("import java.lang.annotation.ElementType;\n"); |
| 6198 |
buf.append("public class E {\n"); |
| 6199 |
buf.append(" public void foo() {\n"); |
| 6200 |
buf.append(" int i [][][];\n"); |
| 6201 |
buf.append(" }\n"); |
| 6202 |
buf.append("}\n"); |
| 6203 |
assertEqualString(preview, buf.toString()); |
| 6204 |
} |
| 6158 |
|
6205 |
|
| 6159 |
} |
6206 |
} |
| 6160 |
|
6207 |
|