mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-113028 Complete statement doesn't complete class declaration
This commit is contained in:
+1
@@ -69,6 +69,7 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
fixers.add(new MissingForeachBodyFixer());
|
||||
fixers.add(new ParameterListFixer());
|
||||
fixers.add(new MissingMethodBodyFixer());
|
||||
fixers.add(new MissingClassBodyFixer());
|
||||
fixers.add(new MissingReturnExpressionFixer());
|
||||
fixers.add(new MissingThrowExpressionFixer());
|
||||
fixers.add(new ParenthesizedFixer());
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.intellij.codeInsight.editorActions.smartEnter;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class MissingClassBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiClass)) return;
|
||||
PsiClass psiClass = (PsiClass) psiElement;
|
||||
|
||||
if (psiClass.getLBrace() == null) {
|
||||
editor.getDocument().insertString(psiClass.getTextRange().getEndOffset(), " {\n}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public class Test<caret>
|
||||
@@ -0,0 +1,3 @@
|
||||
public class Test {
|
||||
<caret>
|
||||
}
|
||||
@@ -106,6 +106,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
|
||||
public void testMethod() throws Exception { doTest(); }
|
||||
|
||||
public void testClass() throws Exception { doTest(); }
|
||||
|
||||
public void testCompleteElseIf() throws Exception { doTest(); }
|
||||
|
||||
public void testCompleteStringLiteral() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user