Community
Participate
Working Groups
Build Identifier: Build id: M20110909-1335 I build an AST with the API. If I use PackageDeclaration.annotations().add... and CompilationUnit.rewrite() I get invalid source code because of the missing space. In ASTRewriteFlattener.visit(PackageDeclaration node) is this line wrong: visitList(node, PackageDeclaration.ANNOTATIONS_PROPERTY, String.valueOf(' ')); correct: public boolean visit(PackageDeclaration node) { if (node.getAST().apiLevel() >= AST.JLS3) { ASTNode javadoc = getChildNode(node, PackageDeclaration.JAVADOC_PROPERTY); if (javadoc != null) { javadoc.accept(this); } visitList(node, PackageDeclaration.ANNOTATIONS_PROPERTY, String.valueOf(' '), Util.EMPTY_STRING, String.valueOf(' ')); } this.result.append("package "); //$NON-NLS-1$ getChildNode(node, PackageDeclaration.NAME_PROPERTY).accept(this); this.result.append(';'); return false; } Reproducible: Always Steps to Reproduce: 1. Build AST with API via CU.recordModifications() 2. Add annotation to PackageDeclaration 3. CU.rewriteAST() to document -> result invalid
Thanks for the code correction. Can you please provide a test case that reproduces a problem? Thanks!
Created attachment 205296 [details] Testcase there should be a space between annotation and package
Created attachment 205297 [details] Testcase 2 (better to see with parameter less annotation)
This bug is still present in the most recent version (jdk8 beta), now since 3.6? Please at least try to fix this for the JDK 8 release...this fix is like 20 chars.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.