mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
IDEA-75812 IDEA doesn't suggest keyword 'break' in switch structure
This commit is contained in:
@@ -131,7 +131,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
if (JavaCompletionData.AFTER_TRY_BLOCK.isAcceptable(position, position) ||
|
||||
JavaCompletionData.START_SWITCH.isAcceptable(position, position) ||
|
||||
JavaCompletionData.START_SWITCH.accepts(position) ||
|
||||
JavaCompletionData.INSTANCEOF_PLACE.isAcceptable(position, position) ||
|
||||
JavaCompletionData.isAfterPrimitiveOrArrayType(position)) {
|
||||
return null;
|
||||
|
||||
@@ -108,27 +108,13 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
START_OF_CODE_FRAGMENT
|
||||
);
|
||||
|
||||
static final AndFilter START_SWITCH = new AndFilter(END_OF_BLOCK, new LeftNeighbour(
|
||||
new AndFilter(new TextFilter("{"), new ParentElementFilter(new ClassFilter(PsiSwitchStatement.class), 2))));
|
||||
static final OrFilter INSIDE_SWITCH = new OrFilter(START_SWITCH,
|
||||
new AndFilter(
|
||||
END_OF_BLOCK,
|
||||
new NotFilter(START_SWITCH),
|
||||
new OrFilter(
|
||||
new ParentElementFilter(new ClassFilter(PsiSwitchLabelStatement.class)),
|
||||
new LeftNeighbour(new OrFilter(
|
||||
new ParentElementFilter(new ClassFilter(PsiSwitchStatement.class), 2),
|
||||
new AndFilter(new TextFilter(";", ":"), new ParentElementFilter(
|
||||
new ClassFilter(PsiSwitchStatement.class), 3)),
|
||||
new AndFilter(new TextFilter("}"), new ParentElementFilter(
|
||||
new ClassFilter(PsiSwitchStatement.class), 4))
|
||||
)))));
|
||||
static final ElementPattern<PsiElement> START_SWITCH = psiElement().afterLeaf(psiElement().withText("{").withParents(PsiCodeBlock.class, PsiSwitchStatement.class));
|
||||
|
||||
private static final ElementPattern<Object> SUPER_OR_THIS_PATTERN =
|
||||
private static final ElementPattern<PsiElement> SUPER_OR_THIS_PATTERN =
|
||||
and(JavaSmartCompletionContributor.INSIDE_EXPRESSION,
|
||||
not(psiElement().afterLeaf(PsiKeyword.CASE)),
|
||||
not(psiElement().afterLeaf(psiElement().withText(".").afterLeaf(PsiKeyword.THIS, PsiKeyword.SUPER))),
|
||||
not(new FilterPattern(START_SWITCH)));
|
||||
not(START_SWITCH));
|
||||
|
||||
|
||||
public static final AndFilter CLASS_START = new AndFilter(
|
||||
@@ -472,10 +458,10 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
}
|
||||
|
||||
if (isStatementPosition(position)) {
|
||||
if (INSIDE_SWITCH.isAcceptable(position, position)) {
|
||||
if (PsiTreeUtil.getParentOfType(position, PsiSwitchStatement.class, false, PsiMember.class) != null) {
|
||||
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.CASE), TailType.SPACE));
|
||||
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.DEFAULT), TailType.CASE_COLON));
|
||||
if (!psiElement().afterLeaf(psiElement().withText(":").withParent(PsiSwitchLabelStatement.class)).accepts(position)) {
|
||||
if (START_SWITCH.accepts(position)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
public class ConstConfig {
|
||||
{
|
||||
switch (x) {
|
||||
case 1:
|
||||
println(1);
|
||||
brea<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class ConstConfig {
|
||||
{
|
||||
switch (x) {
|
||||
case 1:
|
||||
println(1);
|
||||
break;<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -639,6 +639,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testFieldNegation() throws Throwable { doTest('!');}
|
||||
public void testDefaultInSwitch() throws Throwable { doTest()}
|
||||
public void testBreakInSwitch() throws Throwable { doTest() }
|
||||
|
||||
public void testSuperInConstructor() throws Throwable {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user