public static @Nullable PsiQualifiedReferenceElement getClassReferenceToShorten(final @NotNull PsiClass refClass,
                                                                                  final boolean addImports,
                                                                                  final @NotNull PsiQualifiedReferenceElement reference) {
    PsiClass parentClass = refClass.getContainingClass();
    if (parentClass != null) {
      JavaPsiFacade facade = JavaPsiFacade.getInstance(parentClass.getProject());
      final PsiResolveHelper resolveHelper = facade.getResolveHelper();
      if (resolveHelper.isAccessible(refClass, reference, null) && isSafeToShortenReference(reference.getReferenceName(), reference, refClass)) {
        return reference;
      }

        if (!JavaCodeStyleSettings.getInstance(reference.getContainingFile()).isInsertInnerClassImportsFor(refClass.getName())) {
        final PsiElement qualifier = reference.getQualifier();
        if (qualifier instanceof PsiQualifiedReferenceElement) {
          return getClassReferenceToShorten(parentClass, addImports, (PsiQualifiedReferenceElement)qualifier);
        }
        return null;
      }
    }

    if (addImports && !((PsiImportHolder)reference.getContainingFile()).importClass(refClass)) return null;
    if (addImports) JavaModuleGraphUtil.addDependency(reference, refClass, null);
    if (!isSafeToShortenReference(reference, refClass)) return null;
    return reference;
  }
public static @Nullable PsiQualifiedReferenceElement getClassReferenceToShorten(final @NotNull PsiClass refClass,
                                                                                  final boolean addImports,
                                                                                  final @NotNull PsiQualifiedReferenceElement reference)