external annotator is allowed to decide if it should handle file with error +review CR-IC

This commit is contained in:
Dmitry Semeniouta
2013-09-12 16:56:55 +04:00
parent d2de078405
commit 88a2716e2a
2 changed files with 14 additions and 4 deletions
@@ -34,12 +34,21 @@ public abstract class ExternalAnnotator<InitialInfoType, AnnotationResultType> {
public InitialInfoType collectionInformation(@NotNull PsiFile file) {
return null;
}
/**
* @deprecated use {@link com.intellij.lang.annotation.ExternalAnnotator#collectInformation(PsiFile, Editor, boolean)}
*/
@Nullable
@Deprecated()
public InitialInfoType collectInformation(@NotNull PsiFile file, @NotNull Editor editor) {
return collectionInformation(file);
}
@Nullable
public InitialInfoType collectInformation(@NotNull PsiFile file, @NotNull Editor editor, boolean hasErrors) {
return hasErrors ? null : collectionInformation(file);
}
// Lengthy annotation goes here
@Nullable
public AnnotationResultType doAnnotate(InitialInfoType collectedInfo) {
@@ -94,12 +94,13 @@ public class ExternalToolPass extends TextEditorHighlightingPass {
if (!externalAnnotators.isEmpty()) {
DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
boolean errorFound = daemonCodeAnalyzer.getFileStatusMap().wasErrorFound(myDocument);
if (errorFound) return;
for(ExternalAnnotator externalAnnotator: externalAnnotators) {
externalAnnotator.annotate(psiRoot, myAnnotationHolder);
if (!errorFound) {
externalAnnotator.annotate(psiRoot, myAnnotationHolder);
}
final Object collectedInfo = externalAnnotator.collectInformation(psiRoot, myEditor);
final Object collectedInfo = externalAnnotator.collectInformation(psiRoot, myEditor, errorFound);
if (collectedInfo != null) {
myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo));
}