mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-refactoring] IDEA-338428 Inline pattern variable doesn't work when it's located in nested condition
GitOrigin-RevId: 158e71c18441ffd56eebabe107899b95ac4ac15d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
08632d3227
commit
fc4f8118d2
@@ -306,6 +306,9 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
PsiElement codeBlock = null;
|
||||
if (variable instanceof PsiParameter) {
|
||||
PsiElement declarationScope = ((PsiParameter)variable).getDeclarationScope();
|
||||
if (variable instanceof PsiPatternVariable) {
|
||||
return declarationScope;
|
||||
}
|
||||
if (declarationScope instanceof PsiCatchSection) {
|
||||
codeBlock = ((PsiCatchSection)declarationScope).getCatchBlock();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void test(Object obj) {
|
||||
if (Math.random() > 0.5 || (obj instanceof String <caret>s && s.isEmpty())) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void test(Object obj) {
|
||||
if (Math.random() > 0.5 || (obj instanceof String && ((String) obj).isEmpty())) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -22,6 +22,7 @@ public class InlinePatternVariableTest extends LightJavaCodeInsightTestCase {
|
||||
public void testSimple() { doTest(); }
|
||||
public void testSimpleAtRef() { doTest(); }
|
||||
public void testTernary() { doTest(); }
|
||||
public void testInNestedCondition() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
|
||||
Reference in New Issue
Block a user