public static PsiElement replaceStatementAndShortenClassNames(@NotNull PsiStatement statement,
                                                                @NotNull @NonNls String newStatementText,
                                                                @Nullable CommentTracker tracker) {
    final Project project = statement.getProject();
    final CodeStyleManager styleManager = CodeStyleManager.getInstance(project);
    final JavaCodeStyleManager javaStyleManager = JavaCodeStyleManager.getInstance(project);

    PsiStatement newStatement;
    if (tracker != null) {
      newStatement = (PsiStatement)tracker.replaceAndRestoreComments(statement, newStatementText);
    }
    else {
      final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
      newStatement = (PsiStatement)statement.replace(factory.createStatementFromText(newStatementText, statement));
    }
    return styleManager.reformat(javaStyleManager.shortenClassReferences(newStatement));
  }
public static PsiElement replaceStatementAndShortenClassNames(@NotNull PsiStatement statement,
                                                                @NotNull @NonNls String newStatementText,
                                                                @Nullable CommentTracker tracker)