Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2019-03-12 07:13:00 +0000
committerNoopur Gupta2019-03-12 07:13:00 +0000
commitd741b9adc96120ec61af55023608728c3adcba21 (patch)
tree47ac0e00bde38f567152f9096e9c73390407e8ce
parent92047b095ca3e89222f3d87c85a42b8a9b213701 (diff)
downloadeclipse.jdt.ui-d741b9adc96120ec61af55023608728c3adcba21.tar.gz
eclipse.jdt.ui-d741b9adc96120ec61af55023608728c3adcba21.tar.xz
eclipse.jdt.ui-d741b9adc96120ec61af55023608728c3adcba21.zip
Bug 539080: [12] Switch AST to JLS12Y20190313-0215
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java42
1 files changed, 15 insertions, 27 deletions
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
index 475d4cee6b..ab3b214b0d 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
@@ -1541,37 +1541,25 @@ public class ASTFlattener extends GenericVisitor {
@Override
public boolean visit(SwitchCase node) {
if (node.getAST().apiLevel() >= JLS12) {
- if (!node.expressions().isEmpty()) {
+ if (node.isDefault()) {
+ this.fBuffer.append("default");//$NON-NLS-1$
+ this.fBuffer.append(node.isSwitchLabeledRule() ? "->" : ":");//$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ this.fBuffer.append("case ");//$NON-NLS-1$
for (Iterator<Expression> it= node.expressions().iterator(); it.hasNext();) {
- Expression caseExpr= it.next();
- if (node.isDefault()) {
- if (node.isSwitchLabeledRule()) {
- this.fBuffer.append("default ->");//$NON-NLS-1$
- } else {
- this.fBuffer.append("default :");//$NON-NLS-1$
- }
- } else {
- this.fBuffer.append("case ");//$NON-NLS-1$
- caseExpr.accept(this);
- if (it.hasNext()) {
- this.fBuffer.append(", ");//$NON-NLS-1$
- } else {
- if (node.isSwitchLabeledRule()) {
- this.fBuffer.append("->");//$NON-NLS-1$
- } else {
- this.fBuffer.append(":");//$NON-NLS-1$
- }
- }
- }
+ Expression t= it.next();
+ t.accept(this);
+ this.fBuffer.append(it.hasNext() ? ", " : //$NON-NLS-1$
+ node.isSwitchLabeledRule() ? "->" : ":");//$NON-NLS-1$ //$NON-NLS-2$
}
}
} else {
if (node.isDefault()) {
- this.fBuffer.append("default :");//$NON-NLS-1$
+ this.fBuffer.append("default :\n");//$NON-NLS-1$
} else {
this.fBuffer.append("case ");//$NON-NLS-1$
node.getExpression().accept(this);
- this.fBuffer.append(":");//$NON-NLS-1$
+ this.fBuffer.append(":\n");//$NON-NLS-1$
}
}
return false;
@@ -1579,17 +1567,17 @@ public class ASTFlattener extends GenericVisitor {
@Override
public boolean visit(SwitchStatement node) {
- visitSwitch(node);
+ visitSwitchNode(node);
return false;
}
@Override
public boolean visit(SwitchExpression node) {
- visitSwitch(node);
+ visitSwitchNode(node);
return false;
}
- private void visitSwitch(ASTNode node) {
+ private void visitSwitchNode(ASTNode node) {
this.fBuffer.append("switch (");//$NON-NLS-1$
if (node instanceof SwitchExpression) {
((SwitchExpression) node).getExpression().accept(this);
@@ -1597,7 +1585,7 @@ public class ASTFlattener extends GenericVisitor {
((SwitchStatement) node).getExpression().accept(this);
}
this.fBuffer.append(") ");//$NON-NLS-1$
- this.fBuffer.append("{");//$NON-NLS-1$
+ this.fBuffer.append("{\n");//$NON-NLS-1$
if (node instanceof SwitchExpression) {
for (Iterator<Statement> it= ((SwitchExpression) node).statements().iterator(); it.hasNext();) {
Statement s= it.next();

Back to the top