boolean (@NotNull String fqName, @NotNull PsiElement context) { final PsiFile containingFile = context.getContainingFile(); if (!(containingFile instanceof PsiJavaFile file)) { return false; } PsiClass containingClass = PsiTreeUtil.getParentOfType(context, PsiClass.class); while (containingClass != null) { final String shortName = ClassUtil.extractClassName(fqName); final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper(); if (resolveHelper.resolveAccessibleReferencedVariable(shortName, context) != null) { return false; } final PsiClass[] innerClasses = containingClass.getAllInnerClasses(); for (PsiClass innerClass : innerClasses) { if (innerClass.hasModifierProperty(PsiModifier.PRIVATE) && !containingClass.equals(innerClass.getContainingClass())) { // private inner class from super class continue; } if (innerClass.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && !ClassUtils.inSamePackage(innerClass, containingClass)) { // package local inner class from super class in a different package continue; } if (shortName.equals(innerClass.getName())) { return fqName.equals(innerClass.getQualifiedName()); } } if (shortName.equals(containingClass.getName())) { return fqName.equals(containingClass.getQualifiedName()); } containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class); } if (hasExactImportConflict(fqName, file)) { return false; } if (hasOnDemandImportConflict(fqName, file, true)) { return false; } if (containsConflictingReference(file, fqName)) { return false; } if (containsConflictingClassName(fqName, file)) { return false; } return !containsConflictingTypeParameter(fqName, context); }