mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-158249 Complete Current Statement of for loop: code is not reformatted
This commit is contained in:
+10
@@ -338,6 +338,16 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
reformat(elt);
|
||||
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = old;
|
||||
editor.getCaretModel().moveToOffset(caretOffset - 1);
|
||||
|
||||
reformatBlockParentIfNeeded(editor, file);
|
||||
}
|
||||
}
|
||||
|
||||
private void reformatBlockParentIfNeeded(@NotNull Editor editor, @NotNull PsiFile file) {
|
||||
commit(editor);
|
||||
PsiCodeBlock block = PsiTreeUtil.findElementOfClassAtOffset(file, editor.getCaretModel().getOffset(), PsiCodeBlock.class, false);
|
||||
if (block != null && psiElement().withParents(PsiBlockStatement.class, PsiForStatement.class).accepts(block)) {
|
||||
reformat(block.getParent().getParent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
{
|
||||
for (;;) {
|
||||
for (; ; ) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void test() {
|
||||
for (int j=1; j<10; j++) <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class Foo {
|
||||
void test() {
|
||||
for (int j = 1; j < 10; j++) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testSpaceAfterSemicolon() { mySettings.getCommonSettings(JavaLanguage.INSTANCE).SPACE_AFTER_SEMICOLON = true; doTest(); }
|
||||
public void testNoSpaceAfterSemicolon() { myJavaSettings.SPACE_AFTER_SEMICOLON = false; doTest(); }
|
||||
public void testForUpdateGeneration() { doTest(); }
|
||||
public void testReformatForHeader() { doTest(); }
|
||||
public void testValidCodeBlock() { doTest(); }
|
||||
public void testValidCodeBlockWithEmptyLineAfterIt() { doTest(); }
|
||||
public void testFromJavadocParameterDescriptionEndToNextParameter() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user