@Override public void doCollectInformation(@NotNull ProgressIndicator progress) { myDocumentChanged = false; final FileViewProvider viewProvider = myFile.getViewProvider(); final Set<Language> relevantLanguages = viewProvider.getLanguages(); for (Language language : relevantLanguages) { PsiFile psiRoot = viewProvider.getPsi(language); if (!HighlightLevelUtil.shouldInspect(psiRoot)) continue; final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot); if (!externalAnnotators.isEmpty()) { boolean errorFound = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap().wasErrorFound(myDocument); if (errorFound) return; for(ExternalAnnotator externalAnnotator: externalAnnotators) { externalAnnotator.annotate(psiRoot, myAnnotationHolder); final Object collectedInfo = externalAnnotator.collectInformation(psiRoot, myEditor); if (collectedInfo != null) { myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo)); } } } } }
@RequiredReadAction @Override public void doCollectInformation(@Nonnull ProgressIndicator progress) { myDocumentChanged = false; final FileViewProvider viewProvider = myFile.getViewProvider(); final Set<Language> relevantLanguages = viewProvider.getLanguages(); for (Language language : relevantLanguages) { PsiFile psiRoot = viewProvider.getPsi(language); if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot)) continue; final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot); if (!externalAnnotators.isEmpty()) { DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); boolean errorFound = daemonCodeAnalyzer.getFileStatusMap().wasErrorFound(myDocument); for(ExternalAnnotator externalAnnotator: externalAnnotators) { final Object collectedInfo = externalAnnotator.collectInformation(psiRoot, myEditor, errorFound); if (collectedInfo != null) { myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo)); } } } } }
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; }
private static boolean externalAnnotatorsDefined(@NotNull PsiFile file) { for (Language language : file.getViewProvider().getLanguages()) { final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, file); if (!externalAnnotators.isEmpty()) { return true; } } return false; }
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) { annotator.annotate(xmlFile, holder); } 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; }
private static boolean externalAnnotatorsDefined(PsiFile file) { for (Language language : file.getViewProvider().getLanguages()) { final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, file); if (!externalAnnotators.isEmpty()) { return true; } } return false; }
private static boolean externalAnnotatorsDefined(@Nonnull PsiFile file) { for (Language language : file.getViewProvider().getLanguages()) { final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, file); if (!externalAnnotators.isEmpty()) { return true; } } return false; }