mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-128971 Java auto-completion does not offer "final" keyword for exception variable in "catch" clause
This commit is contained in:
@@ -484,7 +484,7 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
}
|
||||
}
|
||||
|
||||
if ((isInsideParameterList(position) || isAtResourceVariableStart(position)) &&
|
||||
if ((isInsideParameterList(position) || isAtResourceVariableStart(position) || isAtCatchVariableStart(position)) &&
|
||||
!psiElement().afterLeaf(PsiKeyword.FINAL).accepts(position) &&
|
||||
!AFTER_DOT.accepts(position)) {
|
||||
result.addElement(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.FINAL), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
@@ -673,6 +673,10 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
return psiElement().insideStarting(psiElement(PsiTypeElement.class).withParent(PsiResourceList.class)).accepts(position);
|
||||
}
|
||||
|
||||
private static boolean isAtCatchVariableStart(PsiElement position) {
|
||||
return psiElement().insideStarting(psiElement(PsiTypeElement.class).withParent(PsiCatchSection.class)).accepts(position);
|
||||
}
|
||||
|
||||
private static void addBreakContinue(CompletionResultSet result, PsiElement position) {
|
||||
PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
public class StructuredConfigKey {
|
||||
{
|
||||
try {
|
||||
|
||||
} catch (<caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class StructuredConfigKey {
|
||||
{
|
||||
try {
|
||||
|
||||
} catch (<caret>)
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -106,7 +106,9 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
public void testReturnInTernary() throws Exception { doTest(1, "return"); }
|
||||
public void testFinalAfterParameterAnno() throws Exception { doTest(2, "final", "float", "class"); }
|
||||
public void testFinalAfterParameterAnno2() throws Exception { doTest(2, "final", "float", "class"); }
|
||||
public void testFinalAfterCase() throws Exception { doTest(3, "final", "float", "class"); }
|
||||
public void testFinalAfterCase() { doTest(3, "final", "float", "class"); }
|
||||
public void testFinalInCatch() { doTest(1, "final"); }
|
||||
public void testFinalInIncompleteCatch() { doTest(1, "final"); }
|
||||
public void testFinalInTryWithResources() throws Exception { doTest(1, "final", "float", "class"); }
|
||||
public void testNoFinalAfterTryBody() throws Exception { doTest(1, "final", "finally"); }
|
||||
public void testClassInMethod() throws Exception { doTest(2, "class", "char"); }
|
||||
|
||||
+1
-1
@@ -638,7 +638,7 @@ interface TxANotAnno {}
|
||||
}
|
||||
|
||||
public void testPreferThrownExceptionsInCatch() {
|
||||
checkPreferredItems 0, 'FileNotFoundException', 'File'
|
||||
checkPreferredItems 0, 'final', 'FileNotFoundException', 'File'
|
||||
}
|
||||
|
||||
public void testHonorFirstLetterCase() {
|
||||
|
||||
Reference in New Issue
Block a user