mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IDEA-120738 Complete current statement creates broken code
This commit is contained in:
@@ -17,7 +17,6 @@ package com.intellij.codeInsight.editorActions.smartEnter;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -57,10 +56,9 @@ public class MissingMethodBodyFixer implements Fixer {
|
||||
}
|
||||
return;
|
||||
}
|
||||
int endOffset = method.getTextRange().getEndOffset();
|
||||
if (StringUtil.endsWithChar(method.getText(), ';')) {
|
||||
doc.deleteString(endOffset - 1, endOffset);
|
||||
endOffset--;
|
||||
int endOffset = method.getThrowsList().getTextRange().getEndOffset();
|
||||
if (endOffset < doc.getTextLength() && doc.getCharsSequence().charAt(endOffset) == ';') {
|
||||
doc.deleteString(endOffset, endOffset + 1);
|
||||
}
|
||||
doc.insertString(endOffset, "{\n}");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
public class Test {
|
||||
|
||||
private String s()<caret>
|
||||
|
||||
/* a comment */ String foo;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class Test {
|
||||
|
||||
private String s() {
|
||||
<caret>
|
||||
}
|
||||
|
||||
/* a comment */ String foo;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
public class Test {
|
||||
|
||||
private String s()<caret>
|
||||
|
||||
/* a comment */ String foo() {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class Test {
|
||||
|
||||
private String s() {
|
||||
<caret>
|
||||
}
|
||||
|
||||
/* a comment */ String foo() {}
|
||||
}
|
||||
@@ -147,6 +147,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
|
||||
public void testFieldBeforeAnnotation() throws Exception { doTest(); }
|
||||
public void testMethodBeforeAnnotation() throws Exception { doTest(); }
|
||||
public void testMethodBeforeCommentField() throws Exception { doTest(); }
|
||||
public void testMethodBeforeCommentMethod() throws Exception { doTest(); }
|
||||
|
||||
public void testParenthesized() throws Exception { doTest(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user