private static PsiTypeLookupItem doCreateItem(final PsiType type,
                                                PsiElement context,
                                                int bracketsCount,
                                                boolean diamond,
                                                InsertHandler<PsiTypeLookupItem> importFixer) {
    if (type instanceof PsiClassType classType) {
      PsiClassType.ClassResolveResult classResolveResult = classType.resolveGenerics();
      final PsiClass psiClass = classResolveResult.getElement();

      if (psiClass != null) {
        String name = psiClass.getName();
        if (name != null) {
          Project project = psiClass.getProject();
          DumbService service = DumbService.getInstance(project);
          PsiResolveHelper helper = JavaPsiFacade.getInstance(project).getResolveHelper();
          PsiClass resolved = service.computeWithAlternativeResolveEnabled(() -> helper.resolveReferencedClass(name, context));
          String[] allStrings;
          if (!psiClass.getManager().areElementsEquivalent(resolved, psiClass)) {
            // inner class name should be shown qualified if it's not accessible by single name
            allStrings = ArrayUtilRt.toStringArray(JavaCompletionUtil.getAllLookupStrings(psiClass));
          } else {
            allStrings = new String[]{name};
          }
          String lookupString = allStrings[allStrings.length - 1];

          PsiTypeLookupItem item = new PsiTypeLookupItem(psiClass, lookupString, diamond, bracketsCount, importFixer,
                                                         classResolveResult.getSubstitutor());
          item.addLookupStrings(allStrings);
          return item;
        }
      }

    }
    return new PsiTypeLookupItem(type, type.getPresentableText(), false, bracketsCount, importFixer, PsiSubstitutor.EMPTY);
  }
private static PsiTypeLookupItem doCreateItem(final PsiType type,
                                                PsiElement context,
                                                int bracketsCount,
                                                boolean diamond,
                                                InsertHandler<PsiTypeLookupItem> importFixer)