diff options
| author | Kalyan Prasad Tatavarthi | 2021-03-05 08:00:28 +0000 |
|---|---|---|
| committer | Kalyan Prasad Tatavarthi | 2021-03-05 08:00:28 +0000 |
| commit | 0acd3b8242feaa730f370a5920076f8e90a6f6ac (patch) | |
| tree | 1a557aff6ea2bc22e09b623db12e5f0b87b70755 | |
| parent | a4a15452a3bb9c155f98d871d2bd576062e4be20 (diff) | |
| download | eclipse.jdt.ui-0acd3b8242feaa730f370a5920076f8e90a6f6ac.tar.gz eclipse.jdt.ui-0acd3b8242feaa730f370a5920076f8e90a6f6ac.tar.xz eclipse.jdt.ui-0acd3b8242feaa730f370a5920076f8e90a6f6ac.zip | |
Bug 571661 - [switch] AIOOBE on invoking create local variable quick fixY20210315-1000Y20210314-1000Y20210313-1000Y20210312-2250Y20210312-1250Y20210312-1000Y20210311-1000Y20210310-1000Y20210309-1000Y20210307-1000Y20210306-1000Y20210305-1000
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.java | 13 |
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); |
