mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-273958 - fixed declaration scope for patterns in the scopes that differ from switch
GitOrigin-RevId: 8c8a835678a6c1de640e34277914b61e1542a1ab
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5c9c5e192c
commit
cf1b781ca9
+2
-1
@@ -113,7 +113,8 @@ public class PsiPatternVariableImpl extends CompositePsiElement implements PsiPa
|
||||
}
|
||||
return nextParent.getParent();
|
||||
}
|
||||
if (nextParent instanceof PsiPattern || nextParent instanceof PsiCaseLabelElementList) {
|
||||
if (nextParent instanceof PsiPattern || nextParent instanceof PsiCaseLabelElementList ||
|
||||
(parent instanceof PsiPattern && nextParent instanceof PsiInstanceOfExpression)) {
|
||||
continue;
|
||||
}
|
||||
return parent;
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Main {
|
||||
void test(Object o) {
|
||||
if (o instanceof ((String <caret>s) && s.length() > 1)) {
|
||||
}
|
||||
s = "fsfsdfsd";
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Main {
|
||||
void test(Object o) {
|
||||
if (!(o instanceof ((String <caret>s) && s.length() > 1))) {
|
||||
s = "fsfsdfsd"; // unresolved
|
||||
}
|
||||
else {
|
||||
s = "fsfsdfsd";
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Main {
|
||||
void test(Object o) {
|
||||
boolean b = o instanceof ((String <caret>s) && s.length() > 1);
|
||||
s = "fsfsdfsd"; // unresolved
|
||||
}
|
||||
}
|
||||
+20
-4
@@ -70,10 +70,20 @@ public class LightPatternsForSwitchHighlightingTest extends LightJavaCodeInsight
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIdentifierHighlighterForPatternVariable() {
|
||||
PsiFile file = myFixture.configureByFile(getTestName(false) + ".java");
|
||||
PsiElement element = myFixture.getElementAtCaret();
|
||||
assertSize(3, IdentifierHighlighterPass.getUsages(element, file, true));
|
||||
public void testHighlighterForPatternVariableInSwitch() {
|
||||
testIdentifierHighlighter(3);
|
||||
}
|
||||
|
||||
public void testHighlighterForPatternVariableInIf() {
|
||||
testIdentifierHighlighter(2);
|
||||
}
|
||||
|
||||
public void testHighlighterForPatternVariableInIfElse() {
|
||||
testIdentifierHighlighter(4);
|
||||
}
|
||||
|
||||
public void testHighlighterForPatternVariableInLocalVariable() {
|
||||
testIdentifierHighlighter(2);
|
||||
}
|
||||
|
||||
public void testGuardWithInstanceOfPatternMatching() {
|
||||
@@ -92,4 +102,10 @@ public class LightPatternsForSwitchHighlightingTest extends LightJavaCodeInsight
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
private void testIdentifierHighlighter(int expectedUsages) {
|
||||
PsiFile file = myFixture.configureByFile(getTestName(false) + ".java");
|
||||
PsiElement element = myFixture.getElementAtCaret();
|
||||
assertSize(expectedUsages, IdentifierHighlighterPass.getUsages(element, file, true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user