[java][switch completion] IDEA-270439 Code completion for pattern matching in switch

Reuse the SealedUtils#findSameFileInheritorsClasses method in order to eliminate the duplicating code and reduce the searching scope. Enable "return" when there is a lambda in a switch label

GitOrigin-RevId: 6e6dbcb8d9b1b16828fcdd29c1e59b2f47a71bb5
This commit is contained in:
Nikita Eshkeev
2021-08-06 20:53:50 +03:00
committed by intellij-monorepo-bot
parent c0b2f613a4
commit 5ecc0aec9c
8 changed files with 111 additions and 40 deletions

View File

@@ -0,0 +1,26 @@
class Main {
private static interface Empty {
void f();
}
private Empty f(Object o) {
return switch (o) {
default -> () -> {
retu<caret>
};
};
}
private Empty g(Object o1, Object o2) {
return switch (o1) {
default -> () -> {
switch (o2) {
case null -> { retu<caret> }
case default -> { retu<caret> }
}
};
};
}
}

View File

@@ -0,0 +1,26 @@
class Main {
private static interface Empty {
void f();
}
private Empty f(Object o) {
return switch (o) {
default -> () -> {
return;<caret>
};
};
}
private Empty g(Object o1, Object o2) {
return switch (o1) {
default -> () -> {
switch (o2) {
case null -> { return;<caret> }
case default -> { return;<caret> }
}
};
};
}
}

View File

@@ -5,8 +5,8 @@ class Main {
<caret>
}
}
}
sealed interface Sealed permits Variant1, Variant2 { }
final class Variant1 implements Sealed { }
final class Variant2 implements Sealed { }
private static sealed interface Sealed permits Variant1, Variant2 { }
private static final class Variant1 implements Sealed { }
private static final class Variant2 implements Sealed { }
}

View File

@@ -5,8 +5,8 @@ class Main {
<caret>
}
}
}
sealed interface Sealed permits Variant1, Variant2 { }
final class Variant1 implements Sealed { }
final class Variant2 implements Sealed { }
private static sealed interface Sealed permits Variant1, Variant2 { }
private static final class Variant1 implements Sealed { }
private static final class Variant2 implements Sealed { }
}