Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2019-07-08 02:23:11 -0400
committerSarika Sinha2019-07-08 02:23:21 -0400
commite4fe6ea66ca018ddb36a728587b87392d8f5c0b8 (patch)
tree3a88177958e8cb4e0a04acd875d9cff38ec05ee1
parent7404b0f200034ff780553aca9ce3c785a56994aa (diff)
downloadeclipse.jdt.core-e4fe6ea66ca018ddb36a728587b87392d8f5c0b8.tar.gz
eclipse.jdt.core-e4fe6ea66ca018ddb36a728587b87392d8f5c0b8.tar.xz
eclipse.jdt.core-e4fe6ea66ca018ddb36a728587b87392d8f5c0b8.zip
Revert "Bug 548956 - Rewrite should work based on previewEnabled flag of AST"I20190709-0610I20190708-1800I20190708-1035I20190708-0800
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java9
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java10
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java8
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java6
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java8
5 files changed, 11 insertions, 30 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java
index acfcedc4cc..bd6a6e6a0f 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingStatementsTest.java
@@ -104,15 +104,6 @@ public class ASTRewritingStatementsTest extends ASTRewritingTest {
return createSuite(ASTRewritingStatementsTest.class);
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- if (this.apiLevel >= AST.JLS12 ) {
- this.project1.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- this.project1.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- }
- }
-
/** @deprecated using deprecated code */
private void internalSetExtraDimensions(VariableDeclarationFragment node, int dimensions) {
if (this.apiLevel < AST.JLS8) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java
index e604f7453e..f10badf274 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingSwitchExpressionsTest.java
@@ -17,7 +17,6 @@ import java.util.List;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Block;
@@ -54,15 +53,6 @@ public class ASTRewritingSwitchExpressionsTest extends ASTRewritingTest {
return createSuite(ASTRewritingSwitchExpressionsTest.class);
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- if (this.apiLevel >= AST.JLS12 ) {
- this.project1.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
- this.project1.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- }
- }
-
@SuppressWarnings("rawtypes")
public void testSwitchExpressions_since_12() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
index 998c0675a5..028519f632 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
@@ -460,18 +460,18 @@ public class NaiveASTFlattener extends ASTVisitor {
@Override
public boolean visit(BreakStatement node) {
- if (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled() && node.isImplicit() && node.getExpression() == null) {
+ if (node.getAST().apiLevel() >= JLS12 && node.isImplicit() && node.getExpression() == null) {
return false;
}
printIndent();
- if (node.getAST().apiLevel() < JLS12 || (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled() && !node.isImplicit())) {
+ if (node.getAST().apiLevel() < JLS12 || (node.getAST().apiLevel() >= JLS12 && !node.isImplicit())) {
this.buffer.append("break"); //$NON-NLS-1$
}
if (node.getLabel() != null) {
this.buffer.append(" ");//$NON-NLS-1$
node.getLabel().accept(this);
}
- if (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12) {
if (node.getExpression() != null) {
this.buffer.append(" ");//$NON-NLS-1$
node.getExpression().accept(this);
@@ -1506,7 +1506,7 @@ public class NaiveASTFlattener extends ASTVisitor {
@Override
public boolean visit(SwitchCase node) {
- if (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12) {
if (node.isDefault()) {
this.buffer.append("default");//$NON-NLS-1$
this.buffer.append(node.isSwitchLabeledRule() ? " ->" : ":");//$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
index 424f7d8285..9dd5439f1d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
@@ -2576,7 +2576,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
try {
int offset= getScanner().getTokenEndOffset(TerminalTokens.TokenNamebreak, node.getStartPosition());
rewriteNode(node, BreakStatement.LABEL_PROPERTY, offset, ASTRewriteFormatter.SPACE); // space between break and label
- if (node.getAST().apiLevel() >= JLS12_INTERNAL && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12_INTERNAL) {
rewriteNode(node, BreakStatement.EXPRESSION_PROPERTY, offset, ASTRewriteFormatter.SPACE); // space between break and label
}
} catch (CoreException e) {
@@ -3519,7 +3519,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
}
// dont allow switching from case to default or back. New statements should be created.
- if (node.getAST().apiLevel() >= JLS12_INTERNAL && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12_INTERNAL) {
int pos = node.expressions().size() == 0 ? node.getStartPosition() :
rewriteNodeList(node, SwitchCase.EXPRESSIONS2_PROPERTY, node.getStartPosition(), Util.EMPTY_STRING, ", "); //$NON-NLS-1$
if (isChanged(node, SwitchCase.SWITCH_LABELED_RULE_PROPERTY)) {
@@ -3743,7 +3743,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
insertIndent++;
}
ParagraphListRewriter listRewriter;
- if (node.getAST().apiLevel() >= JLS12_INTERNAL && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12_INTERNAL) {
listRewriter= new SwitchListLabeledRuleRewriter(insertIndent);
} else {
listRewriter= new SwitchListRewriter(insertIndent);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
index 952fceec4a..e8590da9a2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
@@ -362,11 +362,11 @@ public class ASTRewriteFlattener extends ASTVisitor {
@Override
public boolean visit(BreakStatement node) {
- if (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled() && node.isImplicit() && node.getExpression() == null) {
+ if (node.getAST().apiLevel() >= JLS12 && node.isImplicit() && node.getExpression() == null) {
return false;
}
- if (node.getAST().apiLevel() < JLS12 || (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled() && !node.isImplicit())) {
+ if (node.getAST().apiLevel() < JLS12 || (node.getAST().apiLevel() >= JLS12 && !node.isImplicit())) {
this.result.append("break"); //$NON-NLS-1$
}
ASTNode label= getChildNode(node, BreakStatement.LABEL_PROPERTY);
@@ -374,7 +374,7 @@ public class ASTRewriteFlattener extends ASTVisitor {
this.result.append(' ');
label.accept(this);
}
- if (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12) {
ASTNode expression = getChildNode(node, BreakStatement.EXPRESSION_PROPERTY);
if (expression != null ) {
this.result.append(' ');
@@ -983,7 +983,7 @@ public class ASTRewriteFlattener extends ASTVisitor {
@Override
public boolean visit(SwitchCase node) {
- if (node.getAST().apiLevel() >= JLS12 && node.getAST().isPreviewEnabled()) {
+ if (node.getAST().apiLevel() >= JLS12) {
if (node.isDefault()) {
this.result.append("default");//$NON-NLS-1$
this.result.append(getBooleanAttribute(node, SwitchCase.SWITCH_LABELED_RULE_PROPERTY) ? " ->" : ":");//$NON-NLS-1$ //$NON-NLS-2$

Back to the top