@Override
  public ProblemDescriptor @Nullable [] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, final boolean isOnTheFly) {
    if (!JavaFxFileTypeFactory.isFxml(file)) return null;
    final XmlDocument document = ((XmlFile)file).getDocument();
    if (document == null) return null;
    final Set<String> usedNames = new HashSet<>();
    file.accept(new JavaFxImportsOptimizer.JavaFxUsedClassesVisitor() {
      @Override
      protected void appendClassName(String fqn) {
        usedNames.add(fqn);
        final String packageName = StringUtil.getPackageName(fqn);
        if (!StringUtil.isEmpty(packageName)) {
          usedNames.add(packageName);
        }
      }

      @Override
      protected void appendDemandedPackageName(@NotNull String packageName) {
        usedNames.add(packageName);
      }
    });

    final InspectionManager inspectionManager = InspectionManager.getInstance(file.getProject());

    final List<ProblemDescriptor> problems = new ArrayList<>();
    final Collection<XmlProcessingInstruction> instructions =
      PsiTreeUtil.findChildrenOfType(document.getProlog(), XmlProcessingInstruction.class);
    final Map<String, XmlProcessingInstruction> targetProcessingInstructions = new LinkedHashMap<>();
    for (XmlProcessingInstruction instruction : instructions) {
      final String target = JavaFxPsiUtil.getInstructionTarget("import", instruction);
      if (target != null) {
        targetProcessingInstructions.put(target, instruction);
      }
    }
    for (String target : targetProcessingInstructions.keySet()) {
      final XmlProcessingInstruction instruction = targetProcessingInstructions.get(target);
      if (target.endsWith(".*")) {
        if (!usedNames.contains(StringUtil.trimEnd(target, ".*"))) {
          problems.add(inspectionManager
                         .createProblemDescriptor(instruction, JavaFXBundle.message("inspection.javafx.unused.imports.problem"), new JavaFxOptimizeImportsFix(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
        }
      }
      else if (!usedNames.contains(target) || targetProcessingInstructions.containsKey(StringUtil.getPackageName(target) + ".*")) {
        problems.add(inspectionManager
                       .createProblemDescriptor(instruction, JavaFXBundle.message("inspection.javafx.unused.imports.problem"), new JavaFxOptimizeImportsFix(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
      }
    }
    return problems.isEmpty() ? null : problems.toArray(ProblemDescriptor.EMPTY_ARRAY);
  }
@Override
  public ProblemDescriptor @Nullable [] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, final boolean isOnTheFly)