Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2019-01-29 10:18:43 +0000
committerJay Arthanareeswaran2019-01-29 10:19:12 +0000
commitc7ec8a255fd31106dd76f769daecdf116a3095c0 (patch)
treedbbc462e6fa739cb626c9f6579dd9ba9c630aff4 /org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler
parent60010dfa88a963a8b16209676ac7277e5606027e (diff)
downloadeclipse.jdt.core-c7ec8a255fd31106dd76f769daecdf116a3095c0.tar.gz
eclipse.jdt.core-c7ec8a255fd31106dd76f769daecdf116a3095c0.tar.xz
eclipse.jdt.core-c7ec8a255fd31106dd76f769daecdf116a3095c0.zip
Bug 542560 - [12][completion] Code completion Support for Switch
Expressions Change-Id: Id0101c52abbeb80bb04e32daaacbb532f9192102 Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java2
2 files changed, 5 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
index 88e75f2a52..0b9830cb55 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
@@ -54,6 +54,7 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
private int nullStatus = FlowInfo.UNKNOWN;
public List<Expression> resultExpressions;
+ public boolean resolveAll;
/* package */ List<Integer> resultExpressionNullStatus;
private static Map<TypeBinding, TypeBinding[]> type_map;
@@ -389,6 +390,10 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
this.finalValueResultExpressionTypes[i] = this.originalValueResultExpressionTypes[i] =
resultExpr.resolveTypeExpecting(upperScope, this.expectedType);
}
+ // This is a kludge and only way completion can tell this node to resolve all
+ // resultExpressions. Ideal solution is to remove all other expressions except
+ // the one that contain the completion node.
+ if (this.resolveAll) continue;
if (resultExpr.resolvedType == null || !resultExpr.resolvedType.isValidBinding())
return this.resolvedType = null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 18ff40132c..02200bb2cc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -9527,10 +9527,8 @@ protected void consumeSwitchExpression() {
SwitchExpression s = (SwitchExpression) this.astStack[this.astPtr--];
if (!this.parsingJava12Plus) {
-// problemReporter().switchExpressionsNotBelow12(s);
problemReporter().previewFeatureNotSupported(s.sourceStart, s.sourceEnd, "Switch Expression", CompilerOptions.VERSION_12); //$NON-NLS-1$
} else if (!this.options.enablePreviewFeatures) {
- //problemReporter().switchExpressionIsPreview(s);
problemReporter().previewFeatureNotEnabled(s.sourceStart, s.sourceEnd, "Switch Expression"); //$NON-NLS-1$
} else {
if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) {

Back to the top