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 38506 Details for
Bug 136580
[ast rewrite] Comma is missing between update expressions in the ForStatement
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
suggested fix
patch-136580.txt (text/plain), 4.90 KB, created by
Martin Aeschlimann
on 2006-04-13 08:45:03 EDT
(
hide
)
Description:
suggested fix
Filename:
MIME Type:
Creator:
Martin Aeschlimann
Created:
2006-04-13 08:45:03 EDT
Size:
4.90 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java,v >retrieving revision 1.21 >diff -u -r1.21 ASTRewritingStatementsTest.java >--- src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java 29 Mar 2006 04:03:08 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java 13 Apr 2006 12:36:00 -0000 >@@ -1195,6 +1195,80 @@ > > } > >+ public void testForStatement2() throws Exception { >+ 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(" public void foo() {\n"); >+ buf.append(" for (;;) {\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ CompilationUnit astRoot= createAST(cu); >+ ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); >+ AST ast= astRoot.getAST(); >+ >+ TypeDeclaration type= findTypeDeclaration(astRoot, "E"); >+ MethodDeclaration methodDecl= findMethodDeclaration(type, "foo"); >+ Block block= methodDecl.getBody(); >+ assertTrue("Parse errors", (block.getFlags() & ASTNode.MALFORMED) == 0); >+ >+ List statements= block.statements(); >+ assertTrue("Number of statements not 1", statements.size() == 1); >+ >+ { // replace for statement >+ ForStatement forStatement= (ForStatement) statements.get(0); >+ >+ ForStatement newForStatement= ast.newForStatement(); >+ List initializers= newForStatement.initializers(); >+ >+ Assignment init1= ast.newAssignment(); >+ init1.setLeftHandSide(ast.newSimpleName("x")); >+ init1.setRightHandSide(ast.newNumberLiteral("1")); >+ initializers.add(init1); >+ >+ Assignment init2= ast.newAssignment(); >+ init2.setLeftHandSide(ast.newSimpleName("y")); >+ init2.setRightHandSide(ast.newNumberLiteral("10")); >+ initializers.add(init2); >+ >+ InfixExpression expression= ast.newInfixExpression(); >+ expression.setOperator(InfixExpression.Operator.LESS); >+ expression.setRightOperand(ast.newSimpleName("y")); >+ expression.setLeftOperand(ast.newSimpleName("x")); >+ newForStatement.setExpression(expression); >+ >+ List updaters= newForStatement.updaters(); >+ PrefixExpression upd1= ast.newPrefixExpression(); >+ upd1.setOperator(PrefixExpression.Operator.INCREMENT); >+ upd1.setOperand(ast.newSimpleName("x")); >+ updaters.add(upd1); >+ >+ PrefixExpression upd2= ast.newPrefixExpression(); >+ upd2.setOperator(PrefixExpression.Operator.DECREMENT); >+ upd2.setOperand(ast.newSimpleName("y")); >+ updaters.add(upd2); >+ >+ newForStatement.setBody(ast.newBlock()); >+ rewrite.replace(forStatement, newForStatement, null); >+ } >+ >+ String preview= evaluateRewrite(cu, rewrite); >+ >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" for (x = 1, y = 10; x < y; ++x, --y) {\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ > > public void testIfStatement() throws Exception { > IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null); >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java,v >retrieving revision 1.14 >diff -u -r1.14 ASTRewriteFlattener.java >--- dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java 29 Mar 2006 02:56:28 -0000 1.14 >+++ dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java 13 Apr 2006 12:36:02 -0000 >@@ -455,14 +455,14 @@ > */ > public boolean visit(ForStatement node) { > this.result.append("for ("); //$NON-NLS-1$ >- visitList(node, ForStatement.INITIALIZERS_PROPERTY, null); >+ visitList(node, ForStatement.INITIALIZERS_PROPERTY, String.valueOf(',')); > this.result.append(';'); > ASTNode expression= getChildNode(node, ForStatement.EXPRESSION_PROPERTY); > if (expression != null) { > expression.accept(this); > } > this.result.append(';'); >- visitList(node, ForStatement.UPDATERS_PROPERTY, null); >+ visitList(node, ForStatement.UPDATERS_PROPERTY, String.valueOf(',')); > this.result.append(')'); > getChildNode(node, ForStatement.BODY_PROPERTY).accept(this); > 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 136580
: 38506