mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[java][switch resolve] IDEA-273929 Good code red - cannot resolve symbol in switch statement group
Check if the being resolved element is in the list of case label elements first and only if it's not, go deeper into case label elements' resolvers. GitOrigin-RevId: 63280ccb3bbf95660c5f74f35dc5de4cf34752b6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c56aa21ed
commit
5fe869da3b
@@ -5,6 +5,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -91,8 +92,11 @@ public class PsiCaseLabelElementListImpl extends CompositePsiElement implements
|
||||
@NotNull PsiElement place) {
|
||||
// Do not resolve elements from the list of elements of the case rule
|
||||
if (lastParent != null) return true;
|
||||
for (PsiCaseLabelElement label : getElements()) {
|
||||
if (place == label) return true;
|
||||
|
||||
final PsiCaseLabelElement[] elements = getElements();
|
||||
if (ContainerUtil.exists(elements, e -> e == place)) return true;
|
||||
|
||||
for (PsiCaseLabelElement label : elements) {
|
||||
boolean shouldKeepGoing = label.processDeclarations(processor, state, null, place);
|
||||
if (!shouldKeepGoing) return false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class Main {
|
||||
|
||||
void f(Object obj) {
|
||||
switch (obj) {
|
||||
case i<caret>, Integer i:
|
||||
case Integer i, i<caret>:
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user