support space between class and caret in IDEA-118194 complete statement works strange for inner classes / enums

This commit is contained in:
peter
2013-12-17 10:37:38 +01:00
parent fbf651190e
commit 6e55733cab
4 changed files with 19 additions and 1 deletions

View File

@@ -16,7 +16,9 @@ public class MissingClassBodyFixer implements Fixer {
PsiClass psiClass = (PsiClass) psiElement;
if (psiClass.getLBrace() == null) {
editor.getDocument().insertString(psiClass.getTextRange().getEndOffset(), " {\n}");
int offset = psiClass.getTextRange().getEndOffset();
editor.getDocument().insertString(offset, " {\n}");
editor.getCaretModel().moveToOffset(offset);
}
}
}

View File

@@ -0,0 +1,6 @@
public class Foo {
public static enum MyEnum <caret>
public void foo() {
}
}

View File

@@ -0,0 +1,8 @@
public class Foo {
public static enum MyEnum {
<caret>
}
public void foo() {
}
}

View File

@@ -109,6 +109,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
public void testClass() throws Exception { doTest(); }
public void testInnerEnumBeforeMethod() { doTest(); }
public void testInnerEnumBeforeMethodWithSpace() { doTest(); }
public void testCompleteElseIf() throws Exception { doTest(); }