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 124661 Details for
Bug 246627
[ast rewrite] Wrong indentation for statement inserted before SwitchCase
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug262517_001.txt (text/plain), 4.64 KB, created by
David Audel
on 2009-02-04 07:01:29 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2009-02-04 07:01:29 EST
Size:
4.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java,v >retrieving revision 1.23 >diff -u -r1.23 ASTRewritingTypeDeclTest.java >--- src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java 3 Dec 2008 14:36:39 -0000 1.23 >+++ src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java 30 Jan 2009 10:42:43 -0000 >@@ -16,10 +16,12 @@ > > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.JavaCore; > > import org.eclipse.jdt.core.dom.*; > import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; > import org.eclipse.jdt.core.dom.rewrite.ListRewrite; >+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; > > public class ASTRewritingTypeDeclTest extends ASTRewritingTest { > >@@ -873,6 +875,55 @@ > assertEqualString(preview, buf.toString()); > > } >+ >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=262517 >+ public void testSingleMemberAnnotation1() throws Exception { >+ String previousValue = null; >+ try { >+ previousValue = this.project1.getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, false); >+ >+ this.project1.setOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, JavaCore.INSERT); >+ >+ IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST3(cu); >+ ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); >+ AST ast= astRoot.getAST(); >+ >+ { >+ TypeDeclaration type= findTypeDeclaration(astRoot, "E"); >+ >+ SingleMemberAnnotation newAnnot= ast.newSingleMemberAnnotation(); >+ >+ newAnnot.setTypeName(ast.newName("SuppressWarnings")); >+ >+ StringLiteral newStringLiteral= ast.newStringLiteral(); >+ newStringLiteral.setLiteralValue("deprecation"); >+ newAnnot.setValue(newStringLiteral); >+ >+ ListRewrite modifiers= rewrite.getListRewrite(type, TypeDeclaration.MODIFIERS2_PROPERTY); >+ modifiers.insertFirst(newAnnot, null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("@SuppressWarnings (\"deprecation\")\n"); >+ buf.append("public class E {\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } finally { >+ if (previousValue != null) { >+ this.project1.setOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, previousValue); >+ } >+ } >+ } > > public void testSingleVariableDeclaration() throws Exception { > IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java,v >retrieving revision 1.24 >diff -u -r1.24 ASTRewriteFormatter.java >--- dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java 27 Jun 2008 16:04:10 -0000 1.24 >+++ dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java 30 Jan 2009 10:42:45 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.ToolFactory; > import org.eclipse.jdt.core.dom.ASTNode; >+import org.eclipse.jdt.core.dom.Annotation; > import org.eclipse.jdt.core.dom.Block; > import org.eclipse.jdt.core.dom.BodyDeclaration; > import org.eclipse.jdt.core.dom.Expression; >@@ -264,7 +265,12 @@ > code= CodeFormatter.K_STATEMENTS; > } > } else if (node instanceof Expression && node.getNodeType() != ASTNode.VARIABLE_DECLARATION_EXPRESSION) { >- code= CodeFormatter.K_EXPRESSION; >+ if (node instanceof Annotation) { >+ suffix= "\nclass A {}"; //$NON-NLS-1$ >+ code= CodeFormatter.K_COMPILATION_UNIT; >+ } else { >+ code= CodeFormatter.K_EXPRESSION; >+ } > } else if (node instanceof BodyDeclaration) { > code= CodeFormatter.K_CLASS_BODY_DECLARATIONS; > } else {
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 246627
:
124661
|
124662
|
124665