void (PsiStatement statement, PsiPatternVariable variable) { if (statement.getNextSibling() == null) { return; } String text = getDeclarationStatement(variable); if (text == null) { return; } PsiElement parent = statement.getParent(); if (parent == null) { return; } Project project = statement.getProject(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); PsiStatement declarationStatement = factory.createStatementFromText(text, statement.getNextSibling()); PsiElement newDeclarationStatement = parent.addAfter(declarationStatement, statement); CodeStyleManager.getInstance(project).reformat(newDeclarationStatement); }