Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2019-07-31 10:30:30 +0000
committerNoopur Gupta2019-08-07 09:50:57 +0000
commit2dd58e630eefa755033abef13e0afbc6ed5d6d06 (patch)
tree8c55370219cbe225f023d351faf94052091cc04a
parent5e085d58a2dda60306fb19ff73c050157a00c7b9 (diff)
downloadeclipse.jdt.ui-2dd58e630eefa755033abef13e0afbc6ed5d6d06.tar.gz
eclipse.jdt.ui-2dd58e630eefa755033abef13e0afbc6ed5d6d06.tar.xz
eclipse.jdt.ui-2dd58e630eefa755033abef13e0afbc6ed5d6d06.zip
Bug 549622: Impact of PreviewEnabled check in DOM on JDT UI
-rw-r--r--.project11
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java4
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/Checks.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java8
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java14
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java8
8 files changed, 36 insertions, 18 deletions
diff --git a/.project b/.project
new file mode 100644
index 0000000000..3170ca898a
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>eclipse.jdt.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java
index a6a56e64c1..a7e97f955f 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/ImportReferencesCollector.java
@@ -305,8 +305,8 @@ public class ImportReferencesCollector extends GenericVisitor {
@Override
public boolean visit(BreakStatement node) {
- int apiLevel= node.getAST().apiLevel();
- if (apiLevel >= AST.JLS12) {
+ AST ast= node.getAST();
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
evalQualifyingExpression(node.getExpression(), null);
}
return false;
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java
index 459e0837b0..6c94e0c09b 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java
@@ -296,7 +296,8 @@ public class ASTResolving {
break;
case ASTNode.SWITCH_CASE:
SwitchCase switchCase= (SwitchCase) parent;
- if (node.equals(switchCase.getExpression()) || (switchCase.getAST().apiLevel() >= AST.JLS12 && switchCase.expressions().contains(node))) {
+ AST ast= switchCase.getAST();
+ if (node.equals(switchCase.getExpression()) || (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled() && switchCase.expressions().contains(node))) {
ASTNode caseParent= switchCase.getParent();
if (caseParent instanceof SwitchStatement) {
return ((SwitchStatement) caseParent).getExpression().resolveTypeBinding();
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java
index ae5f4acbe0..5208c1c15a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java
@@ -724,7 +724,8 @@ public class ScopeAnalyzer {
public boolean visit(SwitchCase node) {
// switch on enum allows to use enum constants without qualification
if (hasFlag(VARIABLES, fFlags) && !node.isDefault()) {
- if (node.getAST().apiLevel() >= AST.JLS12) {
+ AST ast= node.getAST();
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
List<Expression> expressions= node.expressions();
for (Expression expression : expressions) {
visitExpression(node, expression);
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/Checks.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/Checks.java
index 7fa4f9178e..079e585c7e 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/Checks.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/Checks.java
@@ -387,7 +387,8 @@ public class Checks {
public static boolean isEnumCase(ASTNode node) {
if (node instanceof SwitchCase) {
final SwitchCase caze= (SwitchCase) node;
- if (node.getAST().apiLevel() >= AST.JLS12) {
+ AST ast= node.getAST();
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
List<Expression> expressions= caze.expressions();
boolean isEnumConst= true;
for (Expression expression : expressions) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
index 41cea3cf77..7283c0e978 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
@@ -2454,7 +2454,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
Statement statement= iter.next();
if (statement instanceof SwitchCase) {
SwitchCase switchCase= (SwitchCase) statement;
- if (ast.apiLevel() >= AST.JLS12 && switchCase.expressions().size() > 1) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled() && switchCase.expressions().size() > 1) {
return false;
}
// special case: pass through
@@ -2556,7 +2556,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
private static Expression createSwitchCaseCondition(AST ast, ASTRewrite rewrite, ImportRewrite importRewrite, ImportRewriteContext importRewriteContext, Name switchExpression,
SwitchCase switchCase, boolean isStringsInSwitch, boolean preserveNPE) {
Expression expression= null;
- if (ast.apiLevel() >= AST.JLS12) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
if (switchCase.expressions().size() == 1) {
expression= (Expression) switchCase.expressions().get(0);
}
@@ -2895,7 +2895,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
SwitchCase[] switchCaseStatements= new SwitchCase[len];
if (caseExpressions.size() == 0) {
switchCaseStatements[0]= ast.newSwitchCase();
- if (ast.apiLevel() < AST.JLS12) {
+ if (!ast.isPreviewEnabled()) {
switchCaseStatements[0].setExpression(null);
}
} else {
@@ -2903,7 +2903,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
ASTNode astNode= caseExpressions.get(i);
switchCaseStatements[i]= ast.newSwitchCase();
Expression copyTarget= (Expression) rewrite.createCopyTarget(astNode);
- if (ast.apiLevel() >= AST.JLS12) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
switchCaseStatements[i].expressions().add(copyTarget);
} else {
switchCaseStatements[i].setExpression(copyTarget);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
index 9866981030..1d38763cff 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
@@ -1791,7 +1791,8 @@ public class LocalCorrectionsSubProcessor {
Statement curr= statements.get(i);
if (curr instanceof SwitchCase) {
SwitchCase switchCase= (SwitchCase) curr;
- if (switchCase.getAST().apiLevel() >= AST.JLS12) {
+ AST ast= switchCase.getAST();
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
List<Expression> expressions= switchCase.expressions();
if (expressions.size() == 0) {
hasDefault= true;
@@ -1834,7 +1835,8 @@ public class LocalCorrectionsSubProcessor {
Statement curr= statements.get(i);
if (curr instanceof SwitchCase) {
SwitchCase switchCase= (SwitchCase) curr;
- if (switchCase.getAST().apiLevel() >= AST.JLS12) {
+ AST ast= switchCase.getAST();
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
if (switchCase.expressions().size() == 0) {
defaultIndex= i;
break;
@@ -1866,7 +1868,7 @@ public class LocalCorrectionsSubProcessor {
SwitchCase newSwitchCase= ast.newSwitchCase();
String enumConstName= enumConstNames.get(i);
Name newName= ast.newName(enumConstName);
- if (ast.apiLevel() >= AST.JLS12) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
newSwitchCase.expressions().add(newName);
} else {
newSwitchCase.setExpression(newName);
@@ -1874,7 +1876,7 @@ public class LocalCorrectionsSubProcessor {
listRewrite.insertAt(newSwitchCase, defaultIndex, null);
defaultIndex++;
if (!hasDefault) {
- if (ast.apiLevel() >= AST.JLS12) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
if (statements.size() > 0) {
Statement firstStatement= statements.get(0);
SwitchCase switchCase= (SwitchCase) firstStatement;
@@ -1902,7 +1904,7 @@ public class LocalCorrectionsSubProcessor {
listRewrite.insertAt(newSwitchCase, defaultIndex, null);
defaultIndex++;
- if (ast.apiLevel() >= AST.JLS12) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
if (statements.size() > 0) {
Statement firstStatement= statements.get(0);
SwitchCase switchCase= (SwitchCase) firstStatement;
@@ -1998,7 +2000,7 @@ public class LocalCorrectionsSubProcessor {
SwitchCase newSwitchCase= ast.newSwitchCase();
listRewrite.insertLast(newSwitchCase, null);
- if (ast.apiLevel() >= AST.JLS12) {
+ if (ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled()) {
if (statements.size() > 0) {
Statement firstStatement= statements.get(0);
SwitchCase switchCase= (SwitchCase) firstStatement;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
index 715a0718f1..826c7d6a9a 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
@@ -4263,9 +4263,11 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
private boolean getSplitSwitchLabelProposal(IInvocationContext context, ASTNode coveringNode, Collection<ICommandAccess> proposals) {
AST ast= coveringNode.getAST();
- // Only continue if >= JLS12 and selected node, or its parent is a SwitchCase
- if (ast.apiLevel() < AST.JLS12 ||
- !(coveringNode instanceof SwitchCase || coveringNode.getParent() instanceof SwitchCase)) {
+ // Only continue if level is JLS12 with preview enabled and selected node, or its parent is a SwitchCase
+ if (!(ast.apiLevel() >= AST.JLS12 && ast.isPreviewEnabled())) {
+ return false;
+ }
+ if (!(coveringNode instanceof SwitchCase || coveringNode.getParent() instanceof SwitchCase)) {
return false;
}

Back to the top