Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java32
1 files changed, 12 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
index a7c9580bec8..20ea85f4204 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Institute for Software - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@@ -90,30 +91,24 @@ public class StatementWriter extends NodeWriter {
newLine = false;
} else if (statement instanceof IASTExpressionStatement) {
writeExpressionStatement((IASTExpressionStatement) statement);
- //usually newLine
} else if (statement instanceof IASTDeclarationStatement) {
writeDeclarationStatement((IASTDeclarationStatement) statement);
newLine = false;
} else if (statement instanceof IASTNullStatement) {
writeNullStatement((IASTNullStatement)statement);
-// usually newLine
} else if (statement instanceof IASTReturnStatement) {
writeReturnStatement((IASTReturnStatement)statement);
-// usually newLine
} else if (statement instanceof IASTGotoStatement) {
writeGotoStatement((IASTGotoStatement) statement);
-// usually newLine
} else if (statement instanceof IASTLabelStatement) {
writeLabelStatement((IASTLabelStatement) statement);
newLine = false;
} else if (statement instanceof IASTCaseStatement) {
writeCaseStatement((IASTCaseStatement) statement);
-// usually newLine
} else if (statement instanceof IASTDefaultStatement) {
writeDefaultStatement((IASTDefaultStatement)statement);
} else if (statement instanceof IASTContinueStatement) {
writeContinueStatement((IASTContinueStatement)statement);
-// usually newLine
} else if (statement instanceof IASTCompoundStatement) {
writeCompoundStatement((IASTCompoundStatement) statement);
if (compoundNoNewLine) {
@@ -122,7 +117,6 @@ public class StatementWriter extends NodeWriter {
}
} else if (statement instanceof IASTBreakStatement) {
writeBreakStatement((IASTBreakStatement) statement);
-// usually newLine
} else if (statement instanceof IASTSwitchStatement) {
writeSwitchStatement((IASTSwitchStatement) statement);
newLine = false;
@@ -160,7 +154,7 @@ public class StatementWriter extends NodeWriter {
nextCompoundNoNewLine();
scribe.print(DO);
- writeBodyStatement(doStatement.getBody(), true);
+ writeBodyStatement(doStatement.getBody(), false);
scribe.print(DO_WHILE);
doStatement.getCondition().accept(visitor);
scribe.print(')');
@@ -191,7 +185,7 @@ public class StatementWriter extends NodeWriter {
scribe.print(')');
scribe.newLines();
nextCompoundNoNewLine();
- writeBodyStatement(forStatement.getBody(), false);
+ writeBodyStatement(forStatement.getBody(), true);
}
private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) {
@@ -203,7 +197,7 @@ public class StatementWriter extends NodeWriter {
scribe.print(')');
scribe.newLines();
nextCompoundNoNewLine();
- writeBodyStatement(forStatment.getBody(), false);
+ writeBodyStatement(forStatment.getBody(), true);
}
private void writeIfStatement(IASTIfStatement ifStatement) {
@@ -225,7 +219,7 @@ public class StatementWriter extends NodeWriter {
scribe.newLines();
nextCompoundNoNewLine();
IASTStatement elseClause = ifStatement.getElseClause();
- writeBodyStatement(ifStatement.getThenClause(), elseClause != null);
+ writeBodyStatement(ifStatement.getThenClause(), elseClause == null);
if (elseClause != null) {
scribe.print(ELSE);
@@ -297,7 +291,7 @@ public class StatementWriter extends NodeWriter {
scribe.newLines();
}
scribe.print(')');
- writeBodyStatement(catchStatement.getCatchBody(), true);
+ writeBodyStatement(catchStatement.getCatchBody(), false);
}
private void writeTryBlockStatement(ICPPASTTryBlockStatement tryStatement) {
@@ -324,7 +318,7 @@ public class StatementWriter extends NodeWriter {
scribe.print(')');
scribe.newLines();
nextCompoundNoNewLine();
- writeBodyStatement(whileStatment.getBody(), false);
+ writeBodyStatement(whileStatment.getBody(), true);
}
private void writeCaseStatement(IASTCaseStatement caseStatement) {
@@ -358,7 +352,7 @@ public class StatementWriter extends NodeWriter {
scribe.print(')');
scribe.newLines();
nextCompoundNoNewLine();
- writeBodyStatement(switchStatement.getBody(), false);
+ writeBodyStatement(switchStatement.getBody(), true);
switchIsNew = false;
}
@@ -396,12 +390,10 @@ public class StatementWriter extends NodeWriter {
return compoundStatement.getStatements();
}
- // TODO(sprigogin): Rename second parameter
- protected void writeBodyStatement(IASTStatement statement, boolean isDoStatement) {
+ protected void writeBodyStatement(IASTStatement statement, boolean newLineForCompound) {
if (statement instanceof IASTCompoundStatement) {
- //TODO hsr existiert noch eine methode
- statement.accept(visitor);
- if (!isDoStatement) {
+ writeCompoundStatement((IASTCompoundStatement) statement);
+ if (newLineForCompound) {
scribe.newLine();
}
compoundNoNewLine = false;
@@ -417,7 +409,7 @@ public class StatementWriter extends NodeWriter {
}
/**
- * Write no new Line after the next Compound-Statement
+ * Write no new Line after the next compound statement
*/
protected void nextCompoundNoNewLine() {
compoundNoNewLine = true;

Back to the top