mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-impl] IDEA-262315 Complete current statement doesn't work for switch expression
GitOrigin-RevId: c755b2eb3a30a8011ea665f13effc7224594818b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
12fc73a9d2
commit
0ee0388653
+7
-5
@@ -281,11 +281,13 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
if (atCaret instanceof PsiWhiteSpace) return null;
|
||||
if (atCaret instanceof PsiJavaToken && "}".equals(atCaret.getText())) {
|
||||
atCaret = atCaret.getParent();
|
||||
if (!(atCaret instanceof PsiAnonymousClass ||
|
||||
atCaret instanceof PsiArrayInitializerExpression ||
|
||||
psiElement(PsiCodeBlock.class).withParent(PsiLambdaExpression.class).accepts(atCaret))) {
|
||||
return null;
|
||||
}
|
||||
boolean expressionEndingWithBrace = atCaret instanceof PsiAnonymousClass ||
|
||||
atCaret instanceof PsiArrayInitializerExpression ||
|
||||
atCaret instanceof PsiCodeBlock && (
|
||||
atCaret.getParent() instanceof PsiLambdaExpression ||
|
||||
atCaret.getParent() instanceof PsiSwitchExpression
|
||||
);
|
||||
if (!expressionEndingWithBrace) return null;
|
||||
}
|
||||
|
||||
for (PsiElement each : SyntaxTraverser.psiApi().parents(atCaret).skip(1)) {
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class SemicolonAfterSwitchExpression {
|
||||
void test() {
|
||||
int x = switch(0) {
|
||||
case 0 -> 1;
|
||||
case 1 -> 2;
|
||||
default -> 3;
|
||||
}<caret>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class SemicolonAfterSwitchExpression {
|
||||
void test() {
|
||||
int x = switch (0) {
|
||||
case 0 -> 1;
|
||||
case 1 -> 2;
|
||||
default -> 3;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testRecordWithComponent() { doTest(); }
|
||||
public void testRecordWithComponentNoBody() { doTest(); }
|
||||
public void testVarargMethod() { doTest(); }
|
||||
public void testSemicolonAfterSwitchExpression() { doTest(); }
|
||||
|
||||
private void doTestBracesNextLineStyle() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
|
||||
Reference in New Issue
Block a user