use of com.intellij.lang.annotation.AnnotationSession in project intellij-community by JetBrains.
the class MyPsiUtil method checkFile.
public static String checkFile(final PsiFile file) {
final String[] error = new String[1];
file.accept(new PsiRecursiveElementVisitor() {
public void visitErrorElement(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() {
public void visitElement(PsiElement element) {
annotator.annotate(element, new AnnotationHolderImpl(new AnnotationSession(file)) {
public Annotation createErrorAnnotation(@NotNull ASTNode astNode, String string) {
error[0] = string;
return super.createErrorAnnotation(astNode, string);
}
public Annotation createErrorAnnotation(@NotNull PsiElement element, String string) {
error[0] = string;
return super.createErrorAnnotation(element, string);
}
public Annotation createErrorAnnotation(@NotNull TextRange textRange, String string) {
error[0] = string;
return super.createErrorAnnotation(textRange, string);
}
});
super.visitElement(element);
}
});
return error[0];
}
Aggregations