Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 237568 Details for
Bug 417923
[1.8][dom ast] white space requirements for ArrayType NASTFlattener and ASTRFlattener
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed Patch
417923fix.patch (text/plain), 57.63 KB, created by
Manoj N Palat
on 2013-11-19 23:35:51 EST
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Manoj N Palat
Created:
2013-11-19 23:35:51 EST
Size:
57.63 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java >index 1b53555..beb13e5 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java >@@ -1657,14 +1657,14 @@ > Expression expression = fragment.getInitializer(); > assertTrue(expression instanceof LambdaExpression); > LambdaExpression lambdaExpression = (LambdaExpression)expression; >- assertEquals("(int [] ia) -> {\n return ia.clone();\n}\n", lambdaExpression.toString()); >+ assertEquals("(int[] ia) -> {\n return ia.clone();\n}\n", lambdaExpression.toString()); > IMethodBinding binding = lambdaExpression.resolveMethodBinding(); > assertEquals("private static java.lang.Object lambda$0(int[]) ", binding.toString()); > assertTrue(lambdaExpression.parameters().size() == 1); > VariableDeclaration variableDeclaration = (VariableDeclaration) lambdaExpression.parameters().get(0); > assertTrue(variableDeclaration instanceof SingleVariableDeclaration); > SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration)variableDeclaration; >- assertEquals("int [] ia", singleVariableDeclaration.toString()); >+ assertEquals("int[] ia", singleVariableDeclaration.toString()); > } > > /** >@@ -3342,7 +3342,7 @@ > assertEquals("Incorrect no of fragments", 1, fragments.size()); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); > assertEquals("Unexpected type", fragment.resolveBinding().getType().toString(), "String @Marker{ value = (String)\"Extended\"} [] @Marker{ value = (String)\"i0\"} @Marker2 [] [] @Marker{ value = (String)\"i1\"} []"); >- assertEquals("Unexpected type", field.getType().toString(), "String @Marker(\"i0\") @Marker2 [] [] @Marker(\"i1\") []"); >+ assertEquals("Unexpected type", "String @Marker(\"i0\") @Marker2 [][] @Marker(\"i1\") []", field.getType().toString()); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417669 > public void testBug417669() throws JavaModelException { >diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java >index c7efeb0..c5d4c75 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java >@@ -162,7 +162,7 @@ > "class Z<Q> {\n" + > " }\n" + > " }\n" + >- " Object o=(@Marker X<@Marker String>.@Marker Y<@Marker Integer>.@Marker Z<@Marker Object> @Marker [] [] @Marker [] [])null;\n" + >+ " Object o=(@Marker X<@Marker String>.@Marker Y<@Marker Integer>.@Marker Z<@Marker Object> @Marker [][] @Marker [][])null;\n" + > " @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {}\n" + > "}\n"; > assertASTNodeEquals(expectedOutput, node); >@@ -191,7 +191,7 @@ > "class Z<Q> {\n" + > " }\n" + > " }\n" + >- " Object o=(@Marker X<@Marker String>.@Marker Y<@Marker Integer>.@Marker Z<@Marker Object> [] @Marker [] [] @Marker [])null;\n" + >+ " Object o=(@Marker X<@Marker String>.@Marker Y<@Marker Integer>.@Marker Z<@Marker Object>[] @Marker [][] @Marker [])null;\n" + > " @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {}\n" + > "}\n"; > assertASTNodeEquals(expectedOutput, node); >@@ -204,7 +204,7 @@ > " class Z<Q> {\n" + > " }\n" + > " }\n" + >- " int [] [] [] [] o = (@One int [] @Two [] [] @Three []) null;\n" + >+ " int[][][][] o = (@One int[] @Two [][] @Three []) null;\n" + > > " @java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)\n" + > " @interface Marker {\n" + >@@ -220,7 +220,7 @@ > "class Z<Q> {\n" + > " }\n" + > " }\n" + >- " int [] [] [] [] o=(@One int [] @Two [] [] @Three [])null;\n" + >+ " int[][][][] o=(@One int[] @Two [][] @Three [])null;\n" + > " @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {}\n" + > "}\n"; > assertASTNodeEquals(expectedOutput, node); >@@ -233,7 +233,7 @@ > " class Z<Q> {\n" + > " }\n" + > " }\n" + >- " String [] [] [] [] o = (@One String [] @Two [] [] @Three []) null;\n" + >+ " String [][][][] o = (@One String[]@Two [][]@Three []) null;\n" + > > " @java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)\n" + > " @interface Marker {\n" + >@@ -249,7 +249,7 @@ > "class Z<Q> {\n" + > " }\n" + > " }\n" + >- " String [] [] [] [] o=(@One String [] @Two [] [] @Three [])null;\n" + >+ " String[][][][] o=(@One String[] @Two [][] @Three [])null;\n" + > " @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {}\n" + > "}\n"; > assertASTNodeEquals(expectedOutput, node); >@@ -262,7 +262,7 @@ > " class Z<Q> {\n" + > " }\n" + > " }\n" + >- " Object o = (@One X<String> [] @Two [] [] @Three []) null;\n" + >+ " Object o = (@One X<String> [] @Two [][]@Three []) null;\n" + > > " @java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)\n" + > " @interface Marker {\n" + >@@ -278,7 +278,7 @@ > "class Z<Q> {\n" + > " }\n" + > " }\n" + >- " Object o=(@One X<String> [] @Two [] [] @Three [])null;\n" + >+ " Object o=(@One X<String>[] @Two [][] @Three [])null;\n" + > " @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {}\n" + > "}\n"; > assertASTNodeEquals(expectedOutput, node); >diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java >index c92313a..a3f4a00 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java >@@ -3248,9 +3248,9 @@ > buf.append("package test1;\n"); > buf.append("import java.lang.annotation.ElementType;\n"); > buf.append("public abstract class E {\n"); >- buf.append(" public Object foo1()[] @Annot1 [] @Annot2 [] { return null; }\n"); >- buf.append(" public Object foo2()[] @Annot1 [] throws ArrayStoreException { return null; }\n"); >- buf.append(" public Object foo3() @Annot1 [] @Annot1 @Annot2 [] @Annot2 [] { return null; }\n"); >+ buf.append(" public Object foo1()[]@Annot1 []@Annot2 [] { return null; }\n"); >+ buf.append(" public Object foo2()[]@Annot1 [] throws ArrayStoreException { return null; }\n"); >+ buf.append(" public Object foo3() @Annot1 [] @Annot1 @Annot2 []@Annot2 [] { return null; }\n"); > buf.append(" public Object foo4()@Annot2 @Annot1 [] @Annot2 @Annot1 [] throws IllegalArgumentException { return null; }\n"); > buf.append(" public Object foo5() [] @Annot2 @Annot1 [] { return null; }\n"); > buf.append(" public Object foo6(int i) [] [] throws IllegalArgumentException { return null; }\n"); >diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java >index fe13150..8b82954 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java >@@ -6039,7 +6039,7 @@ > buf.append("import java.lang.annotation.ElementType;\n"); > buf.append("public class E {\n"); > buf.append(" public void foo() {\n"); >- buf.append(" int [] i [] @Annot1 @Annot2 [] @Annot1 @Annot3 [] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size()] @Annot2 @Annot1 [][]@Annot3 @Annot2 @Annot1 [];\n"); >+ buf.append(" int [] i []@Annot1 @Annot2 [] @Annot1 @Annot3 [] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size()] @Annot2 @Annot1 [][] @Annot3 @Annot2 @Annot1 [];\n"); > buf.append(" int [] j [][] = new int @Annot2 [2] @Annot2 [] @Annot1 [], k [][] = new int [2] [10] [size()];\n"); > buf.append(" }\n"); > buf.append(" public int size() { return 2; }\n"); >@@ -6059,7 +6059,7 @@ > buf.append("import java.lang.annotation.ElementType;\n"); > buf.append("public class E {\n"); > buf.append(" public void foo() {\n"); >- buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[][]{})] [];\n"); >+ buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2]@Annot2 @Annot3[size(new int[][]{})] [];\n"); > 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"); > buf.append(" }\n"); > buf.append(" public int size(Object obj) { return 2; }\n"); >@@ -6094,7 +6094,6 @@ > ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); > listRewrite.remove((ASTNode)dim.annotations().get(0), null); > listRewrite.remove((ASTNode)dim.annotations().get(1), null); >- rewrite.set(creation, ArrayCreation.TYPE_PROPERTY, arrayType, null); > } > { > statement = (VariableDeclarationStatement) statements.get(1); >@@ -6120,7 +6119,7 @@ > buf.append("import java.lang.annotation.ElementType;\n"); > buf.append("public class E {\n"); > buf.append(" public void foo() {\n"); >- buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2] [size(new int[][]{})] [];\n"); >+ buf.append(" int [] i [][] = new int @Annot1 @Annot2 [2][size(new int[][]{})] [];\n"); > buf.append(" int [] j [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [size(new int[]{})], k [][] = new int @Annot1 @Annot2 [2] @Annot2 @Annot3 [10];\n"); > buf.append(" }\n"); > buf.append(" public int size(Object obj) { return 2; }\n"); >@@ -6156,7 +6155,735 @@ > assertTrue("Incorrect Formatting", doc.get().equals(formattedString)); > } > >-} >+ public void testBug417923a_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int @Annot1[][][];\n"); >+ buf.append(" int [] j [][] = new int @Annot1 [][][];\n"); >+ buf.append(" int [] k [][] = new int @Annot1 [][][];\n"); >+ buf.append(" int [] l [][] = new int /* comment @ [] */@Annot1[][][];\n"); >+ buf.append(" int [] m [][] = new int /* comment @ [] */ @Annot1[][][];\n"); >+ buf.append(" int [] n [][] = new int /* comment @ [] */ @Annot1 [][][];\n"); >+ buf.append(" int [] o [][] = new int @Annot1/* comment @ [] */[][][];\n"); >+ buf.append(" int [] p [][] = new int @Annot1 /* comment @ [] */ [][][];\n"); >+ buf.append(" int [] q [][] = new int @Annot1 /* comment @ [] */[][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); > >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); > >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); > >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = ast.newArrayType(ast.newPrimitiveType(PrimitiveType.INT), 3); >+ rewrite.set(creation, ArrayCreation.TYPE_PROPERTY, arrayType, null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[][][];\n"); >+ buf.append(" int [] j [][] = new int[][][];\n"); >+ buf.append(" int [] k [][] = new int[][][];\n"); >+ buf.append(" int [] l [][] = new int[][][];\n"); >+ buf.append(" int [] m [][] = new int[][][];\n"); >+ buf.append(" int [] n [][] = new int[][][];\n"); >+ buf.append(" int [] o [][] = new int[][][];\n"); >+ buf.append(" int [] p [][] = new int[][][];\n"); >+ buf.append(" int [] q [][] = new int[][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ public void testBug417923b_since_8() throws Exception { >+ IPackageFragment pack1 = this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[] @Annot1[][];\n"); >+ buf.append(" int [] j [][] = new int[] @Annot1 [][];\n"); >+ buf.append(" int [] k [][] = new int[] @Annot1 [][];\n"); >+ buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1[][];\n"); >+ buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1[][];\n"); >+ buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); >+ buf.append(" int [] o [][] = new int[] @Annot1/* comment @ [] */[][];\n"); >+ buf.append(" int [] p [][] = new int[] @Annot1 /* comment @ [] */ [][];\n"); >+ buf.append(" int [] q [][] = new int[] @Annot1 /* comment @ [] */[][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = ast.newArrayType(ast.newPrimitiveType(PrimitiveType.INT), 3); >+ rewrite.set(creation, ArrayCreation.TYPE_PROPERTY, arrayType, null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[][][];\n"); >+ buf.append(" int [] j [][] = new int[][][];\n"); >+ buf.append(" int [] k [][] = new int[][][];\n"); >+ buf.append(" int [] l [][] = new int[][][];\n"); >+ buf.append(" int [] m [][] = new int[][][];\n"); >+ buf.append(" int [] n [][] = new int[][][];\n"); >+ buf.append(" int [] o [][] = new int[][][];\n"); >+ buf.append(" int [] p [][] = new int[][][];\n"); >+ buf.append(" int [] q [][] = new int[][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923c_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int @Annot1[][][];\n"); >+ buf.append(" int [] j [][] = new int @Annot1 [][][];\n"); >+ buf.append(" int [] k [][] = new int @Annot1 [][][];\n"); >+ buf.append(" int [] l [][] = new int /* comment @ [] */@Annot1[][][];\n"); >+ buf.append(" int [] m [][] = new int /* comment @ [] */ @Annot1[][][];\n"); >+ buf.append(" int [] n [][] = new int /* comment @ [] */ @Annot1 [][][];\n"); >+ buf.append(" int [] o [][] = new int @Annot1/* comment @ [] */[][][];\n"); >+ buf.append(" int [] p [][] = new int @Annot1 /* comment @ [] */ [][][];\n"); >+ buf.append(" int [] q [][] = new int @Annot1 /* comment @ [] */[][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = creation.getType(); >+ >+ Dimension dim = (Dimension) arrayType.dimensions().get(0); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ listRewrite.remove((ASTNode)dim.annotations().get(0), null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[][][];\n"); >+ buf.append(" int [] j [][] = new int[][][];\n"); >+ buf.append(" int [] k [][] = new int[][][];\n"); >+ buf.append(" int [] l [][] = new int [][][];\n"); >+ buf.append(" int [] m [][] = new int /* comment @ [] */[][][];\n"); >+ buf.append(" int [] n [][] = new int /* comment @ [] */[][][];\n"); >+ buf.append(" int [] o [][] = new int/* comment @ [] */[][][];\n"); >+ buf.append(" int [] p [][] = new int/* comment @ [] */ [][][];\n"); >+ buf.append(" int [] q [][] = new int/* comment @ [] */[][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923d_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[] @Annot1[][];\n"); >+ buf.append(" int [] j [][] = new int[] @Annot1 [][];\n"); >+ buf.append(" int [] k [][] = new int[] @Annot1 [][];\n"); >+ buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1[][];\n"); >+ buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1[][];\n"); >+ buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); >+ buf.append(" int [] o [][] = new int[] @Annot1/* comment @ [] */[][];\n"); >+ buf.append(" int [] p [][] = new int[] @Annot1 /* comment @ [] */ [][];\n"); >+ buf.append(" int [] q [][] = new int[] @Annot1 /* comment @ [] */[][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = creation.getType(); >+ >+ Dimension dim = (Dimension) arrayType.dimensions().get(1); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ listRewrite.remove((ASTNode)dim.annotations().get(0), null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[][][];\n"); >+ buf.append(" int [] j [][] = new int[][][];\n"); >+ buf.append(" int [] k [][] = new int[][][];\n"); >+ buf.append(" int [] l [][] = new int[] [][];\n"); >+ buf.append(" int [] m [][] = new int[] /* comment @ [] */[][];\n"); >+ buf.append(" int [] n [][] = new int[] /* comment @ [] */[][];\n"); >+ buf.append(" int [] o [][] = new int[]/* comment @ [] */[][];\n"); >+ buf.append(" int [] p [][] = new int[]/* comment @ [] */ [][];\n"); >+ buf.append(" int [] q [][] = new int[]/* comment @ [] */[][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923e_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i = new int[][][];\n"); >+ buf.append(" int[][][] j = new int [][][];\n"); >+ buf.append(" int[][][] k = new int [][][];\n"); >+ buf.append(" int[][][] l = new int/* comment */[][][];\n"); >+ buf.append(" int[][][] m = new int /* comment [] */ [][][];\n"); >+ buf.append(" int[][][] n = new int /* comment [] */ [][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 6; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = creation.getType(); >+ >+ Dimension dim = (Dimension) arrayType.dimensions().get(0); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); >+ markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); >+ listRewrite.insertAt(markerAnnotation, 0, null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i = new int @Annot1 [][][];\n"); >+ buf.append(" int[][][] j = new int @Annot1 [][][];\n"); >+ buf.append(" int[][][] k = new int @Annot1 [][][];\n"); >+ buf.append(" int[][][] l = new int @Annot1 /* comment */[][][];\n"); >+ buf.append(" int[][][] m = new int @Annot1 /* comment [] */ [][][];\n"); >+ buf.append(" int[][][] n = new int @Annot1 /* comment [] */ [][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923f_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i = new int[][][];\n"); >+ buf.append(" int[][][] j = new int[] [][];\n"); >+ buf.append(" int[][][] k = new int[] [][];\n"); >+ buf.append(" int[][][] l = new int[]/* comment */[][];\n"); >+ buf.append(" int[][][] m = new int[] /* comment [] */ [][];\n"); >+ buf.append(" int[][][] n = new int[] /* comment [] */ [][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 6; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = creation.getType(); >+ >+ Dimension dim = (Dimension) arrayType.dimensions().get(1); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); >+ markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); >+ listRewrite.insertAt(markerAnnotation, 0, null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i = new int[] @Annot1 [][];\n"); >+ buf.append(" int[][][] j = new int[] @Annot1 [][];\n"); >+ buf.append(" int[][][] k = new int[] @Annot1 [][];\n"); >+ buf.append(" int[][][] l = new int[] @Annot1 /* comment */[][];\n"); >+ buf.append(" int[][][] m = new int[] @Annot1 /* comment [] */ [][];\n"); >+ buf.append(" int[][][] n = new int[] @Annot1 /* comment [] */ [][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923g_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i;\n"); >+ buf.append(" int [][][] j;\n"); >+ buf.append(" int [][][] k;\n"); >+ buf.append(" int/* comment */[][][] l;\n"); >+ buf.append(" int /* comment [] */ [][][] m;\n"); >+ buf.append(" int /* comment [] */ [][][] n;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 6; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ ArrayType arrayType = (ArrayType) statement.getType(); >+ Dimension dim = (Dimension) arrayType.dimensions().get(0); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); >+ markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); >+ listRewrite.insertAt(markerAnnotation, 0, null); >+ } >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int @Annot1 [][][] i;\n"); >+ buf.append(" int @Annot1 [][][] j;\n"); >+ buf.append(" int @Annot1 [][][] k;\n"); >+ buf.append(" int @Annot1 /* comment */[][][] l;\n"); >+ buf.append(" int @Annot1 /* comment [] */ [][][] m;\n"); >+ buf.append(" int @Annot1 /* comment [] */ [][][] n;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ public void testBug417923h_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i;\n"); >+ buf.append(" int[] [][] j;\n"); >+ buf.append(" int[] [][] k;\n"); >+ buf.append(" int[]/* comment */[][] l;\n"); >+ buf.append(" int[] /* comment [] */ [][] m;\n"); >+ buf.append(" int[] /* comment [] */ [][] n;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 6; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ ArrayType arrayType = (ArrayType) statement.getType(); >+ Dimension dim = (Dimension) arrayType.dimensions().get(1); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ MarkerAnnotation markerAnnotation= ast.newMarkerAnnotation(); >+ markerAnnotation.setTypeName(ast.newSimpleName("Annot1")); >+ listRewrite.insertAt(markerAnnotation, 0, null); >+ } >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[] @Annot1 [][] i;\n"); >+ buf.append(" int[] @Annot1 [][] j;\n"); >+ buf.append(" int[] @Annot1 [][] k;\n"); >+ buf.append(" int[] @Annot1 /* comment */[][] l;\n"); >+ buf.append(" int[] @Annot1 /* comment [] */ [][] m;\n"); >+ buf.append(" int[] @Annot1 /* comment [] */ [][] n;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923i_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int @Annot1[][][] i;\n"); >+ buf.append(" int @Annot1 [][][] j;\n"); >+ buf.append(" int @Annot1 [][][] k;\n"); >+ buf.append(" int/* comment @ [] */@Annot1[][][] l;\n"); >+ buf.append(" int /* comment @ [] */ @Annot1[][][] m;\n"); >+ buf.append(" int /* comment @ [] */ @Annot1 [][][] n;\n"); >+ buf.append(" int @Annot1/* comment @ [] */[][][] o;\n"); >+ buf.append(" int @Annot1 /* comment @ [] */ [][][] p;\n"); >+ buf.append(" int @Annot1 /* comment @ [] */[][][] q;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ ArrayType arrayType = (ArrayType) statement.getType(); >+ Dimension dim = (Dimension) arrayType.dimensions().get(0); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ listRewrite.remove((ASTNode) dim.annotations().get(0), null); >+ } >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i;\n"); >+ buf.append(" int[][][] j;\n"); >+ buf.append(" int[][][] k;\n"); >+ buf.append(" int[][][] l;\n"); >+ buf.append(" int /* comment @ [] */[][][] m;\n"); >+ buf.append(" int /* comment @ [] */[][][] n;\n"); >+ buf.append(" int/* comment @ [] */[][][] o;\n"); >+ buf.append(" int/* comment @ [] */ [][][] p;\n"); >+ buf.append(" int/* comment @ [] */[][][] q;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923j_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[] @Annot1[][] i;\n"); >+ buf.append(" int[] @Annot1 [][] j;\n"); >+ buf.append(" int[] @Annot1 [][] k;\n"); >+ buf.append(" int[]/* comment @ [] */@Annot1[][] l;\n"); >+ buf.append(" int[] /* comment @ [] */ @Annot1[][] m;\n"); >+ buf.append(" int[] /* comment @ [] */ @Annot1 [][] n;\n"); >+ buf.append(" int[] @Annot1/* comment @ [] */[][] o;\n"); >+ buf.append(" int[] @Annot1 /* comment @ [] */ [][] p;\n"); >+ buf.append(" int[] @Annot1 /* comment @ [] */[][] q;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ ArrayType arrayType = (ArrayType) statement.getType(); >+ Dimension dim = (Dimension) arrayType.dimensions().get(1); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ listRewrite.remove((ASTNode) dim.annotations().get(0), null); >+ } >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[][][] i;\n"); >+ buf.append(" int[][][] j;\n"); >+ buf.append(" int[][][] k;\n"); >+ buf.append(" int[][][] l;\n"); >+ buf.append(" int[] /* comment @ [] */[][] m;\n"); >+ buf.append(" int[] /* comment @ [] */[][] n;\n"); >+ buf.append(" int[]/* comment @ [] */[][] o;\n"); >+ buf.append(" int[]/* comment @ [] */ [][] p;\n"); >+ buf.append(" int[]/* comment @ [] */[][] q;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923k_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[] @Annot1 @Annot2[][];\n"); >+ buf.append(" int [] j [][] = new int[] @Annot1 @Annot2[][];\n"); >+ buf.append(" int [] k [][] = new int[] @Annot1 @Annot2 [][];\n"); >+ buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1 @Annot2[][];\n"); >+ buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1 @Annot2 [][];\n"); >+ buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 @Annot2 [][];\n"); >+ buf.append(" int [] o [][] = new int[] @Annot1 @Annot2/* comment @ [] */[][];\n"); >+ buf.append(" int [] p [][] = new int[] @Annot1 @Annot2/* comment @ [] */ [][];\n"); >+ buf.append(" int [] q [][] = new int[] @Annot1 @Annot2/* comment @ [] */[][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ ArrayCreation creation = (ArrayCreation) fragment.getInitializer(); >+ ArrayType arrayType = creation.getType(); >+ >+ Dimension dim = (Dimension) arrayType.dimensions().get(1); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ listRewrite.remove((ASTNode)dim.annotations().get(1), null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int [] i [][] = new int[] @Annot1[][];\n"); >+ buf.append(" int [] j [][] = new int[] @Annot1[][];\n"); >+ buf.append(" int [] k [][] = new int[] @Annot1 [][];\n"); >+ buf.append(" int [] l [][] = new int[] /* comment @ [] */@Annot1[][];\n"); >+ buf.append(" int [] m [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); >+ buf.append(" int [] n [][] = new int[] /* comment @ [] */ @Annot1 [][];\n"); >+ buf.append(" int [] o [][] = new int[] @Annot1/* comment @ [] */[][];\n"); >+ buf.append(" int [] p [][] = new int[] @Annot1/* comment @ [] */ [][];\n"); >+ buf.append(" int [] q [][] = new int[] @Annot1/* comment @ [] */[][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testBug417923l_since_8() throws Exception { >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[] @Annot1 @Annot2[][] i;\n"); >+ buf.append(" int[] @Annot1 @Annot2 [][] j;\n"); >+ buf.append(" int[] @Annot1 @Annot2 [][] k;\n"); >+ buf.append(" int[]/* comment @ [] */@Annot1 @Annot2[][] l;\n"); >+ buf.append(" int[] /* comment @ [] */ @Annot1 @Annot2 [][] m;\n"); >+ buf.append(" int[] /* comment @ [] */ @Annot1 @Annot2 [][] n;\n"); >+ buf.append(" int[] @Annot1 @Annot2/* comment @ [] */[][] o;\n"); >+ buf.append(" int[] @Annot1 @Annot2/* comment @ [] */ [][] p;\n"); >+ buf.append(" int[] @Annot1 @Annot2/* comment @ [] */[][] q;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast = astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(ast); >+ >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ for (int i = 0; i < 9; ++i) { >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(i); >+ ArrayType arrayType = (ArrayType) statement.getType(); >+ Dimension dim = (Dimension) arrayType.dimensions().get(1); >+ ListRewrite listRewrite= rewrite.getListRewrite(dim, Dimension.ANNOTATIONS_PROPERTY); >+ listRewrite.remove((ASTNode) dim.annotations().get(1), null); >+ } >+ String preview= evaluateRewrite(cu, rewrite); >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("import java.lang.annotation.ElementType;\n"); >+ buf.append("public class X {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int[] @Annot1[][] i;\n"); >+ buf.append(" int[] @Annot1 [][] j;\n"); >+ buf.append(" int[] @Annot1 [][] k;\n"); >+ buf.append(" int[]/* comment @ [] */@Annot1[][] l;\n"); >+ buf.append(" int[] /* comment @ [] */ @Annot1 [][] m;\n"); >+ buf.append(" int[] /* comment @ [] */ @Annot1 [][] n;\n"); >+ buf.append(" int[] @Annot1/* comment @ [] */[][] o;\n"); >+ buf.append(" int[] @Annot1/* comment @ [] */ [][] p;\n"); >+ buf.append(" int[] @Annot1/* comment @ [] */[][] q;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >+ buf.append("@interface Annot1 {}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+} >\ No newline at end of file >diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java >index 9ca40c5..af51d8c 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java >@@ -1738,7 +1738,7 @@ > buf.append("import java.lang.annotation.ElementType;\n"); > buf.append("public class E {\n"); > buf.append(" public void foo() {\n"); >- buf.append(" int i, j, k = 0, x, y [] [] [], z @Annot1 [], zz @Annot2 @Annot2[] = {0, 1};\n"); >+ buf.append(" int i, j, k = 0, x, y[][][], z @Annot1 [], zz @Annot2 @Annot2[] = {0, 1};\n"); > buf.append(" }\n"); > buf.append("}\n"); > buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >@@ -1849,7 +1849,7 @@ > buf.append("import java.lang.annotation.ElementType;\n"); > buf.append("public class E {\n"); > buf.append(" public void foo() {\n"); >- buf.append(" int a @Annot1 @Annot2 [], j = 1, k @Annot1 @Annot2 [], x @Annot1 @Annot2 [] = null, y @Annot1[] @Annot2[], zz @Annot2 @Annot2[] = {0, 1};\n"); >+ buf.append(" int a @Annot1 @Annot2 [], j = 1, k @Annot1 @Annot2 [], x @Annot1 @Annot2 [] = null, y @Annot1 [] @Annot2 [], zz @Annot2 @Annot2[] = {0, 1};\n"); > buf.append(" }\n"); > buf.append("}\n"); > buf.append("@java.lang.annotation.Target(value= {ElementType.TYPE_USE})\n"); >diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java >index a09f0a4..c314666 100644 >--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java >+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java >@@ -620,8 +620,10 @@ > } > > public boolean visit(Dimension node) { >- this.buffer.append(" ");//$NON-NLS-1$ >- visitAnnotationsList(node.annotations()); >+ List annotations = node.annotations(); >+ if (annotations.size() > 0) >+ this.buffer.append(' '); >+ visitAnnotationsList(annotations); > this.buffer.append("[]"); //$NON-NLS-1$ > return false; > } >diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java >index 669e4c4..c73f8b3 100644 >--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java >+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java >@@ -1266,7 +1266,7 @@ > } > > protected int rewriteExtraDimensionsInfo(ASTNode node, int pos, ChildListPropertyDescriptor property) { >- return rewriteNodeList(node, property, pos, " ", " "); //$NON-NLS-1$ //$NON-NLS-2$ >+ return rewriteNodeList(node, property, pos, " ", ""); //$NON-NLS-1$ //$NON-NLS-2$ > } > > private int rewriteExtraDimensions(ASTNode parent, StructuralPropertyDescriptor property, int pos) { >@@ -1913,11 +1913,69 @@ > return offset; > } > >+ private ASTNode getPreviousNode(ASTNode node) { >+ ArrayType arrayType = (ArrayType) node.getParent(); >+ ASTNode prev = arrayType.getElementType(); >+ List l = (List) node.getParent().getStructuralProperty(node.getLocationInParent()); >+ int size = l.size(); >+ int i = 0; >+ for (; i < size; i++) { >+ ASTNode currNode = (ASTNode) l.get(i); >+ if (node.equals(currNode)) >+ break; >+ prev = currNode; >+ } >+ return i < size ? prev : null; >+ } >+ >+ private int getPreviousTokenEndOffset(ASTNode node, int token) { >+ int offset = -1; >+ ASTNode prev = getPreviousNode(node); >+ if (prev != null) { >+ offset = prev.getStartPosition() + prev.getLength(); >+ try { >+ offset = getScanner().getPreviousTokenEndOffset(token, offset); >+ } catch (CoreException e1) { >+ e1.printStackTrace(); >+ } >+ } >+ return offset; >+ } >+ > public boolean visit(Dimension node) { > if (!hasChildrenChanges(node)) { > return doVisitUnchangedChildren(node); > } >- rewriteNodeList(node, Dimension.ANNOTATIONS_PROPERTY, node.getStartPosition(), Util.EMPTY_STRING, " "); //$NON-NLS-1$ >+ >+ boolean keywordSpace = true; >+ ASTNode parent = node.getParent(); >+ if (parent.getNodeType() == ASTNode.ARRAY_TYPE) { >+ List oldAnnotations = (List) getOriginalValue(node, Dimension.ANNOTATIONS_PROPERTY); >+ List newAnnotations = (List) getNewValue(node, Dimension.ANNOTATIONS_PROPERTY); >+ int oldAnnotationSize = oldAnnotations.size(); >+ int newAnnotationSize = newAnnotations.size(); >+ if (oldAnnotationSize > 0 && newAnnotationSize == 0) { /* removed all annotations */ >+ int delStart = getPreviousTokenEndOffset(node, TerminalTokens.TokenNameAT); >+ int delEnd = ((ASTNode) oldAnnotations.get(0)).getStartPosition(); >+ if (delStart >= 0 && delEnd > delStart) { >+ doTextRemove(delStart, delEnd - delStart, null); /* remove spaces before the annotation */ >+ } >+ >+ ASTNode currNode = (ASTNode) oldAnnotations.get(oldAnnotationSize - 1); >+ delStart = currNode.getStartPosition() + currNode.getLength(); >+ try { >+ delEnd = getScanner().getNextStartOffset(delStart, false); >+ doTextRemove(delStart, delEnd - delStart, null); /* remove spaces after the annotation */ >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ } else if (oldAnnotationSize == 0 && newAnnotationSize > 0) { /* inserting first annotation */ >+ if (ScannerHelper.isWhitespace(this.content[node.getStartPosition() - 1])) { >+ keywordSpace = false; /* space exists already */ >+ } >+ } >+ } >+ rewriteNodeList(node, Dimension.ANNOTATIONS_PROPERTY, node.getStartPosition(), keywordSpace ? String.valueOf(' ') : Util.EMPTY_STRING, String.valueOf(' '), String.valueOf(' ')); > return false; > } > >@@ -2058,10 +2116,13 @@ > ArrayType arrayType= (ArrayType) getOriginalValue(node, ArrayCreation.TYPE_PROPERTY); > ArrayType replacingType= arrayType; > int nOldBrackets= getDimensions(arrayType); // number of total brackets >+ boolean astLevelGTE8 = node.getAST().apiLevel() >= AST.JLS8; >+ boolean typeReplaced = false; > > TextEditGroup editGroup= null; > RewriteEvent typeEvent= getEvent(node, ArrayCreation.TYPE_PROPERTY); > if (typeEvent != null && typeEvent.getChangeKind() == RewriteEvent.REPLACED) { // changed arraytype can have different dimension or type name >+ typeReplaced = true; > replacingType= (ArrayType) typeEvent.getNewValue(); > editGroup= getEditGroup(typeEvent); > Type newType= replacingType.getElementType(); >@@ -2080,16 +2141,17 @@ > RewriteEvent dimEvent= getEvent(node, ArrayCreation.DIMENSIONS_PROPERTY); > boolean hasDimensionChanges= (dimEvent != null && dimEvent.getChangeKind() != RewriteEvent.UNCHANGED); > RewriteEvent[] events= hasDimensionChanges ? dimEvent.getChildren() : null; >- boolean astLevelGTE8 = node.getAST().apiLevel() >= AST.JLS8; > ArrayType currentLevel = astLevelGTE8 ? null : (ArrayType) replacingType.getElementType().getParent(); > int replacingTypeDimensions = replacingType.getDimensions(); > int i=0, dimSize= (events == null) ? 0 : events.length; > Type elementType= arrayType.getElementType(); > int offset= elementType.getStartPosition() + elementType.getLength(); >+ editGroup = null; > while(currentLevel != null || astLevelGTE8) { > if (i < dimSize) { >- if (astLevelGTE8) rewriteAnnotationsOnDimension(replacingType, i, offset); >- offset= getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, offset); >+ if (astLevelGTE8) >+ rewriteAnnotationsOnDimension(arrayType, replacingType, i, offset, typeReplaced, editGroup); >+ offset= getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, offset); > if (hasDimensionChanges) { > RewriteEvent event= events[i]; > int changeKind= event.getChangeKind(); >@@ -2123,7 +2185,8 @@ > offset= retrieveRightBracketEndPosition(offset, 1, true); > } > } else if (i < nOldBrackets) { >- if (astLevelGTE8) rewriteAnnotationsOnDimension(replacingType, i, offset); >+ if (astLevelGTE8) >+ rewriteAnnotationsOnDimension(arrayType, replacingType, i, offset, typeReplaced, editGroup); > offset= retrieveRightBracketEndPosition(offset, 1, false); > } else { > insertAnnotationsOnDimension(replacingType, i, offset, editGroup, astLevelGTE8); >@@ -2162,18 +2225,39 @@ > List annotations = dim.annotations(); > if (annotations != null) { > int size = annotations.size(); >- for (int j = 0; j < size; j++) { >- Annotation annotation = (Annotation) annotations.get(j); >- doTextInsert(pos, annotation.toString() + " ", editGroup); //$NON-NLS-1$ >+ if (size > 0) { >+ doTextInsert(pos, " ", editGroup); //$NON-NLS-1$ >+ for (int j = 0; j < size; j++) { >+ Annotation annotation = (Annotation) annotations.get(j); >+ doTextInsert(pos, annotation.toString() + " ", editGroup); //$NON-NLS-1$ >+ } > } >- > } > } > } > >- private void rewriteAnnotationsOnDimension(ArrayType replacingType, int index, int pos) { >- Dimension dim = (Dimension) replacingType.dimensions().get(index); >- rewriteTypeAnnotations(dim, Dimension.ANNOTATIONS_PROPERTY, pos); >+ private void rewriteAnnotationsOnDimension(ArrayType oldArrayType, ArrayType replacingType, int index, int pos, boolean typeReplaced, TextEditGroup editGroup) throws CoreException { >+ if (typeReplaced) { >+ List dimensions = oldArrayType.dimensions(); >+ Dimension oldDim = index < dimensions.size() ? (Dimension) dimensions.get(index) : null; >+ if (oldDim != null) { >+ List oldAnnotations = oldDim.annotations(); >+ int size = oldAnnotations.size(); >+ if (size > 0) { >+ ASTNode prev = getPreviousNode(oldDim); >+ Annotation annotation = (Annotation) oldAnnotations.get(0); >+ int start = prev != null ? prev.getStartPosition() + prev.getLength() : annotation.getStartPosition(); >+ annotation = (Annotation) oldAnnotations.get(size - 1); >+ int end = annotation.getStartPosition() + annotation.getLength(); >+ end = getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, end) - 1; >+ doTextRemove(start, end - start, editGroup); >+ } >+ } >+ insertAnnotationsOnDimension(replacingType, index, pos, editGroup, true); >+ } else { >+ Dimension dim = (Dimension) replacingType.dimensions().get(index); >+ rewriteNodeList(dim, Dimension.ANNOTATIONS_PROPERTY, pos, String.valueOf(' '), String.valueOf(' '), String.valueOf(' ')); >+ } > } > > /** >@@ -2241,7 +2325,9 @@ > return false; > } > >- >+ private int rewriteArrayTypeDimensions(ArrayType node, int pos) { >+ return rewriteNodeList(node, ArrayType.DIMENSIONS_PROPERTY, pos, Util.EMPTY_STRING, ""); //$NON-NLS-1$ >+ } > > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(ArrayType) >@@ -2254,7 +2340,7 @@ > rewriteRequiredNode(node, INTERNAL_ARRAY_COMPONENT_TYPE_PROPERTY); > } else { > int pos = rewriteRequiredNode(node, ArrayType.ELEMENT_TYPE_PROPERTY); >- rewriteNodeList(node, ArrayType.DIMENSIONS_PROPERTY, pos, Util.EMPTY_STRING, " "); //$NON-NLS-1$ >+ rewriteArrayTypeDimensions(node, pos); > } > return false; > } >diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java >index 74f0b23..09fda33 100644 >--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java >+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java >@@ -305,7 +305,7 @@ > this.result.append("[]"); //$NON-NLS-1$ > } else { > getChildNode(node, ArrayType.ELEMENT_TYPE_PROPERTY).accept(this); >- visitList(node, ArrayType.DIMENSIONS_PROPERTY, String.valueOf(' '), Util.EMPTY_STRING, String.valueOf(' ')); >+ visitList(node, ArrayType.DIMENSIONS_PROPERTY, Util.EMPTY_STRING, Util.EMPTY_STRING, Util.EMPTY_STRING); > } > return false; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 417923
:
237222
|
237347
| 237568