private static List<ProblemDescriptor> runInspectionOnFile(
     @NotNull PsiFile file, @NotNull LocalInspectionTool inspectionTool) {
   InspectionManager inspectionManager = InspectionManager.getInstance(file.getProject());
   GlobalInspectionContext context = inspectionManager.createNewGlobalContext(false);
   return InspectionEngine.runInspectionOnFile(
       file, new LocalInspectionToolWrapper(inspectionTool), context);
 }
  private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(
      @NotNull XmlFile xmlFile) {
    final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));

    final List<ExternalAnnotator> annotators =
        ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
    for (ExternalAnnotator<?, ?> annotator : annotators) {
      processAnnotator(xmlFile, holder, annotator);
    }

    if (!holder.hasAnnotations()) return Collections.emptyMap();

    Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap =
        new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
    for (final Annotation annotation : holder) {
      final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
      if (info.getSeverity() == HighlightSeverity.INFORMATION) continue;

      final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
      final PsiElement endElement =
          info.startOffset == info.endOffset
              ? startElement
              : xmlFile.findElementAt(info.endOffset - 1);
      if (startElement == null || endElement == null) continue;

      final ProblemDescriptor descriptor =
          myInspectionManager.createProblemDescriptor(
              startElement,
              endElement,
              info.getDescription(),
              ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
              false);
      final HighlightDisplayLevel level =
          info.getSeverity() == HighlightSeverity.ERROR
              ? HighlightDisplayLevel.ERROR
              : HighlightDisplayLevel.WARNING;
      problemsMap.put(descriptor, level);
    }
    return problemsMap;
  }