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 237222 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
Fix-for-Bug-417923-18dom-ast-white-space-requirement.patch (text/plain), 13.51 KB, created by
Manoj N Palat
on 2013-11-06 01:33:48 EST
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Manoj N Palat
Created:
2013-11-06 01:33:48 EST
Size:
13.51 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 d2d7d5e..50038d1 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 f8015cc..e330e54 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 >@@ -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..763bf44 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"); >@@ -6120,7 +6120,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"); >@@ -6155,6 +6155,53 @@ > edit.apply(doc); > assertTrue("Incorrect Formatting", doc.get().equals(formattedString)); > } >+ public void testBug419723a_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 E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int i [][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ AST ast= astRoot.getAST(); >+ ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); >+ >+ // Get while statement block >+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0); >+ MethodDeclaration methodDecl= typeDecl.getMethods()[0]; >+ Block block= methodDecl.getBody(); >+ List statements= block.statements(); >+ >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) statements.get(0); >+ List fragments = statement.fragments(); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ >+ { >+ // Add new dimension with and without annotations >+ >+ ListRewrite listRewrite= rewrite.getListRewrite(fragment, VariableDeclarationFragment.EXTRA_DIMENSIONS2_PROPERTY); >+ Dimension dim = ast.newDimension(); >+ listRewrite.insertFirst(dim, null); >+ >+ } >+ // Get new code >+ 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 E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" int i [][][];\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } > > } > >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 9eb0fc1..a261dca 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) { >@@ -2254,7 +2254,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$ >+ rewriteNodeList(node, ArrayType.DIMENSIONS_PROPERTY, pos, Util.EMPTY_STRING, ""); //$NON-NLS-1$ > } > 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