public static String checkFile(final PsiFile file) {
        final String[] error = new String[1];
        file.accept(new PsiRecursiveElementVisitor() {
            @Override
            public void visitErrorElement(@NotNull PsiErrorElement element) {
                error[0] = element.getErrorDescription();
            }
        });
        if (error[0] != null) return error[0];

        final Annotator annotator = LanguageAnnotators.INSTANCE.forLanguage(file.getLanguage());
        file.accept(new PsiRecursiveElementVisitor() {
            @Override
            public void visitElement(@NotNull PsiElement element) {
              AnnotationSessionImpl.computeWithSession(file, false, annotator, annotationHolder -> {
                ((AnnotationHolderImpl)annotationHolder).runAnnotatorWithContext(element);
                for (Annotation annotation : (List<Annotation>)annotationHolder) {
                  if (annotation.getSeverity() == HighlightSeverity.ERROR) {
                    error[0] = annotation.getMessage();
                    break;
                  }
                }
                return null;
              });
              super.visitElement(element);
            }
        });
        return error[0];
    }
public static String checkFile(final PsiFile file)