private static void replaceWithStringBuilder(PsiJavaCodeReferenceElement newClassReference, PsiVariable variable) {
      final PsiTypeElement typeElement = variable.getTypeElement();
      if (typeElement == null) {
        return;
      }
      if (!typeElement.isInferredType()) {
        final PsiJavaCodeReferenceElement oldReferenceElement = typeElement.getInnermostComponentReferenceElement();
        if (oldReferenceElement == null) {
          return;
        }
        else {
          oldReferenceElement.replace(newClassReference);
        }
      }
      final PsiExpression newExpression = getNewStringBuffer(variable.getInitializer());
      if (!(newExpression instanceof PsiNewExpression)) {
        return;
      }
      // no need to handle anonymous classes because StringBuffer is final
      final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)newExpression).getClassReference();
      if (classReference == null) {
        return;
      }
      classReference.replace(newClassReference);
    }
private static void replaceWithStringBuilder(PsiJavaCodeReferenceElement newClassReference, PsiVariable variable)