mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java completion: prefer break/continue in likely positions inside loops (IDEA-156192)
This commit is contained in:
@@ -177,6 +177,11 @@ public class PreferByKindWeigher extends LookupElementWeigher {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
}
|
||||
if ((PsiKeyword.BREAK.equals(keyword) || PsiKeyword.CONTINUE.equals(keyword)) &&
|
||||
PsiTreeUtil.getParentOfType(myPosition, PsiLoopStatement.class) != null &&
|
||||
isLastStatement(PsiTreeUtil.getParentOfType(myPosition, PsiStatement.class))) {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import javax.swing.*;
|
||||
|
||||
class A extends JPanel {
|
||||
void f(int color) {
|
||||
for (int i=0;i<10;i++) {
|
||||
if (i%2==0) co<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -304,6 +304,10 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems 0, "return", "registerKeyboardAction"
|
||||
}
|
||||
|
||||
public void testPreferContinueInsideLoops() {
|
||||
checkPreferredItems 0, "continue", "color", "computeVisibleRect"
|
||||
}
|
||||
|
||||
public void testPreferModifiers() {
|
||||
checkPreferredItems(0, "private", "protected", "public");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user