Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalyan Prasad Tatavarthi2021-03-05 08:00:28 +0000
committerKalyan Prasad Tatavarthi2021-03-05 08:00:28 +0000
commit0acd3b8242feaa730f370a5920076f8e90a6f6ac (patch)
tree1a557aff6ea2bc22e09b623db12e5f0b87b70755
parenta4a15452a3bb9c155f98d871d2bd576062e4be20 (diff)
downloadeclipse.jdt.ui-0acd3b8242feaa730f370a5920076f8e90a6f6ac.tar.gz
eclipse.jdt.ui-0acd3b8242feaa730f370a5920076f8e90a6f6ac.tar.xz
eclipse.jdt.ui-0acd3b8242feaa730f370a5920076f8e90a6f6ac.zip
Change-Id: Ibfdfe27dcc35cd92ad3d65d769b7deb006480e4e Signed-off-by: Kalyan Prasad Tatavarthi <kalyan_prasad@in.ibm.com>
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
index 0b2ad144c4..3ba914edd2 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -323,7 +323,7 @@ public class UnresolvedElementsSubProcessor {
addNewFieldProposals(cu, astRoot, binding, declaringTypeBinding, simpleName, isWriteAccess, proposals);
// new parameters and local variables
- if (binding == null) {
+ if (binding == null && !isParentSwitchCase(simpleName)) {
addNewVariableProposals(cu, node, simpleName, proposals);
}
}
@@ -380,7 +380,7 @@ public class UnresolvedElementsSubProcessor {
return;
}
- boolean mustBeConst= ASTResolving.isInsideModifiers(simpleName);
+ boolean mustBeConst= (ASTResolving.isInsideModifiers(simpleName) || isParentSwitchCase(simpleName)) ;
addNewFieldForType(targetCU, binding, senderDeclBinding, simpleName, isWriteAccess, mustBeConst, proposals);
@@ -395,6 +395,13 @@ public class UnresolvedElementsSubProcessor {
}
}
+ private static boolean isParentSwitchCase(SimpleName simpleName) {
+ if (simpleName != null) {
+ return (simpleName.getParent() instanceof SwitchCase);
+ }
+ return false;
+ }
+
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding, ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst, Collection<ICommandAccess> proposals) {
String name= simpleName.getIdentifier();
String nameLabel= BasicElementLabels.getJavaElementName(name);

Back to the top