mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[^romka] IDEA-96146 Cannot enter 'final' keyword in try-with-resources
(cherry-picked from acd831e)
This commit is contained in:
@@ -38,7 +38,6 @@ import com.intellij.psi.jsp.JspElementType;
|
||||
import com.intellij.psi.templateLanguages.OuterLanguageElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -484,7 +483,9 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
}
|
||||
}
|
||||
|
||||
if (isInsideParameterList(position) && !psiElement().afterLeaf(PsiKeyword.FINAL).accepts(position) && !AFTER_DOT.accepts(position)) {
|
||||
if ((isInsideParameterList(position) || isAtResourceVariableStart(position)) &&
|
||||
!psiElement().afterLeaf(PsiKeyword.FINAL).accepts(position) &&
|
||||
!AFTER_DOT.accepts(position)) {
|
||||
result.addElement(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.FINAL), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
}
|
||||
|
||||
@@ -632,6 +633,10 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAtResourceVariableStart(PsiElement position) {
|
||||
return psiElement().insideStarting(psiElement(PsiTypeElement.class).withParent(PsiResourceList.class)).accepts(position);
|
||||
}
|
||||
|
||||
private static void addBreakContinue(CompletionResultSet result, PsiElement position) {
|
||||
PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Util {
|
||||
void foo() {
|
||||
try (<caret>)
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ 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 testFinalInTryWithResources() throws Exception { doTest(1, "final", "float", "class"); }
|
||||
public void testClassInMethod() throws Exception { doTest(2, "class", "char"); }
|
||||
public void testIntInClassArray() throws Throwable { doTest(2, "int", "char", "final"); }
|
||||
public void testIntInClassArray2() throws Throwable { doTest(2, "int", "char", "final"); }
|
||||
|
||||
Reference in New Issue
Block a user