@Override
  public boolean satisfiedBy(PsiElement element) {
    if (!(element instanceof PsiJavaCodeReferenceElement referenceElement)) {
      return false;
    }
    if (!referenceElement.isQualified()) {
      return false;
    }
    final PsiElement parent = referenceElement.getParent();
    if (parent instanceof PsiMethodCallExpression || parent instanceof PsiAssignmentExpression || parent instanceof PsiVariable) {
      return false;
    }
    if (PsiTreeUtil.getParentOfType(element, PsiImportStatementBase.class, PsiPackageStatement.class, JavaCodeFragment.class) != null) {
      return false;
    }
    final CodeStyleSettings codeStyleSettings = CodeStyle.getSettings(element.getContainingFile());
    if (isInsideCommentInPackageInfo(referenceElement)) {
      return false;
    }
    final PsiFile file = element.getContainingFile();
    if ("module-info.java".equals(file.getName())) {
      return false;
    }
    final PsiElement qualifier = referenceElement.getQualifier();
    if (!(qualifier instanceof PsiJavaCodeReferenceElement qualifierReferenceElement)) {
      return false;
    }
    final PsiElement resolved = qualifierReferenceElement.resolve();
    if (!(resolved instanceof PsiPackage)) {
      if (!(resolved instanceof PsiClass)) {
        return false;
      }
      if (!codeStyleSettings.getCustomSettings(JavaCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) {
        return false;
      }
    }
    final PsiElement target = referenceElement.resolve();
    if (!(target instanceof PsiClass aClass)) {
      return false;
    }
    final String fqName = aClass.getQualifiedName();
    return fqName != null && ImportUtils.nameCanBeImported(fqName, element);
  }
@Override
  public boolean satisfiedBy(PsiElement element)