mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
suggest 'final' in for-in loop clause (IDEA-67249)
This commit is contained in:
@@ -526,9 +526,12 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
return;
|
||||
}
|
||||
|
||||
final PsiExpressionStatement expressionStatement = PsiTreeUtil.getParentOfType(position, PsiExpressionStatement.class);
|
||||
if (expressionStatement != null && expressionStatement.getTextRange().getStartOffset() == position.getTextRange().getStartOffset()) {
|
||||
if (!psiElement().withSuperParent(2, PsiSwitchStatement.class).accepts(expressionStatement)) {
|
||||
PsiStatement statement = PsiTreeUtil.getParentOfType(position, PsiExpressionStatement.class);
|
||||
if (statement == null) {
|
||||
statement = PsiTreeUtil.getParentOfType(position, PsiDeclarationStatement.class);
|
||||
}
|
||||
if (statement != null && statement.getTextRange().getStartOffset() == position.getTextRange().getStartOffset()) {
|
||||
if (!psiElement().withSuperParent(2, PsiSwitchStatement.class).accepts(statement)) {
|
||||
result.addElement(createKeyword(position, PsiKeyword.FINAL));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Foooo {
|
||||
|
||||
{
|
||||
for (fin<caret> Object o : new ArrayList())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -709,8 +709,12 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testFinalInForLoop() throws Throwable {
|
||||
configure()
|
||||
checkResultByFile(getTestName(false) + ".java")
|
||||
assertOrderedEquals myFixture.lookupElementStrings, 'final'
|
||||
assertStringItems 'final'
|
||||
}
|
||||
|
||||
public void testFinalInForLoop2() throws Throwable {
|
||||
configure()
|
||||
assertStringItems 'final', 'finalize'
|
||||
}
|
||||
|
||||
public void testPrimitiveTypesInForLoop() throws Throwable { doPrimitiveTypeTest() }
|
||||
|
||||
Reference in New Issue
Block a user