GrStatement (@Nullable GrStatementOwner declarationOwner, @NotNull ExtractInfoHelper helper) { GrStatement realStatement; if (declarationOwner != null && !isSingleExpression(helper.getStatements()) && helper.getStringPartInfo() == null) { // Replace set of statements final GrStatement[] newStatement = createResultStatement(helper); // add call statement final GrStatement[] statements = helper.getStatements(); LOG.assertTrue(statements.length > 0); realStatement = null; for (GrStatement statement : newStatement) { realStatement = declarationOwner.addStatementBefore(statement, statements[0]); JavaCodeStyleManager.getInstance(realStatement.getProject()).shortenClassReferences(realStatement); } LOG.assertTrue(realStatement != null); // remove old statements removeOldStatements(declarationOwner, helper); PsiImplUtil.removeNewLineAfter(realStatement); } else { GrExpression oldExpr; if (helper.getStringPartInfo() != null) { oldExpr = helper.getStringPartInfo().replaceLiteralWithConcatenation("xyz"); } else { oldExpr = (GrExpression)helper.getStatements()[0]; } // Expression call replace GrExpression methodCall = createMethodCall(helper); realStatement = oldExpr.replaceWithExpression(methodCall, true); JavaCodeStyleManager.getInstance(realStatement.getProject()).shortenClassReferences(realStatement); } return realStatement; }