mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-41929 Ctrl + Shift + Enter doesn't work for "for (; ;)"
This commit is contained in:
+2
-1
@@ -248,7 +248,8 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
|
||||
final PsiElement[] children = atCaret.getChildren();
|
||||
for (PsiElement child : children) {
|
||||
if (atCaret instanceof PsiStatement && child instanceof PsiStatement) continue;
|
||||
if (atCaret instanceof PsiStatement && child instanceof PsiStatement &&
|
||||
!(atCaret instanceof PsiForStatement && child == ((PsiForStatement)atCaret).getInitialization())) continue;
|
||||
collectAllElements(child, res, recurse);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -42,12 +42,15 @@ public class MissingForBodyFixer implements Fixer {
|
||||
if (body != null && startLine(doc, body) == startLine(doc, forStatement)) return;
|
||||
|
||||
PsiElement eltToInsertAfter = forStatement.getRParenth();
|
||||
String text = "{}";
|
||||
String braces = "{\n}";
|
||||
String text = braces;
|
||||
if (eltToInsertAfter == null) {
|
||||
eltToInsertAfter = forStatement;
|
||||
text = "){}";
|
||||
text = ")" + text;
|
||||
}
|
||||
doc.insertString(eltToInsertAfter.getTextRange().getEndOffset(), text);
|
||||
int offset = eltToInsertAfter.getTextRange().getEndOffset();
|
||||
doc.insertString(offset, text);
|
||||
editor.getCaretModel().moveToOffset(offset + text.length() - braces.length());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
{
|
||||
for (;;<caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
{
|
||||
for (;;) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
|
||||
public void testFor() throws Exception { doTest(); }
|
||||
|
||||
public void testEmptyFor() { doTest(); }
|
||||
|
||||
public void testForEach() throws Exception { doTest(); }
|
||||
|
||||
public void testForBlock() throws Exception { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user