in src/main/java/org/jetbrains/plugins/spotbugs/gui/editor/BugsLineMarkerProvider.java [69:114]
public LineMarkerInfo<?> getLineMarkerInfo(@NotNull final PsiElement psiElement) {
if (psiElement.getFirstChild() != null) {
return null;
}
final Project project = psiElement.getProject();
final WorkspaceSettings workspaceSettings = WorkspaceSettings.getInstance(project);
if (!workspaceSettings.annotationGutterIcon) {
return null;
}
if (!FindBugsState.get(project).isIdle()) {
return null;
}
final ProblemCacheService cacheService = psiElement.getProject().getService(ProblemCacheService.class);
if (cacheService == null) {
return null;
}
final PsiFile psiFile = IdeaUtilImpl.getPsiFile(psiElement);
final Map<PsiFile, List<ExtendedProblemDescriptor>> problemCache = cacheService.getProblems();
if (problemCache.containsKey(psiFile)) {
final List<ExtendedProblemDescriptor> matchingDescriptors = new ArrayList<ExtendedProblemDescriptor>();
final List<ExtendedProblemDescriptor> problemDescriptors = problemCache.get(psiFile);
if (problemDescriptors == null) {
return null;
}
final Iterable<ExtendedProblemDescriptor> descriptors = new ArrayList<ExtendedProblemDescriptor>(problemDescriptors);
for (final ExtendedProblemDescriptor problemDescriptor : descriptors) {
final PsiElement problemPsiElement = problemDescriptor.getPsiElement();
if (psiElement == firstLeafOrNull(problemPsiElement)) {
matchingDescriptors.add(problemDescriptor);
//if(psiElement instanceof PsiAnonymousClass) {
// final Editor[] editors = com.intellij.openapi.editor.EditorFactory.getInstance().getEditors(IdeaUtilImpl.getDocument(psiFile.getProject(), problemDescriptor));
// editors[0].getMarkupModel().addRangeHighlighter()
//}
}
}
if (!matchingDescriptors.isEmpty()) {
final GutterIconNavigationHandler<PsiElement> navHandler = new BugGutterIconNavigationHandler(psiElement, matchingDescriptors);
return new LineMarkerInfo<>(psiElement, psiElement.getTextRange(), GuiUtil.getTinyIcon(matchingDescriptors.get(0)), new TooltipProvider(matchingDescriptors), navHandler, GutterIconRenderer.Alignment.LEFT);
}
}
return null;
}