Search in sources :

Example 1 with PsiSwitchStatement

use of com.intellij.psi.PsiSwitchStatement in project intellij-community by JetBrains.

the class MissingSwitchBodyFixer method apply.

@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
    if (!(psiElement instanceof PsiSwitchStatement))
        return;
    PsiSwitchStatement switchStatement = (PsiSwitchStatement) psiElement;
    final Document doc = editor.getDocument();
    final PsiCodeBlock body = switchStatement.getBody();
    if (body != null)
        return;
    final PsiJavaToken rParenth = switchStatement.getRParenth();
    assert rParenth != null;
    doc.insertString(rParenth.getTextRange().getEndOffset(), "{}");
}
Also used : PsiCodeBlock(com.intellij.psi.PsiCodeBlock) PsiJavaToken(com.intellij.psi.PsiJavaToken) PsiSwitchStatement(com.intellij.psi.PsiSwitchStatement) Document(com.intellij.openapi.editor.Document)

Aggregations

Document (com.intellij.openapi.editor.Document)1 PsiCodeBlock (com.intellij.psi.PsiCodeBlock)1 PsiJavaToken (com.intellij.psi.PsiJavaToken)1 PsiSwitchStatement (com.intellij.psi.PsiSwitchStatement)1