int (@NotNull PsiFile file, @NotNull TodoPattern pattern) { VirtualFile virtualFile = file.getVirtualFile(); int count = 0; if (virtualFile != null) { count = TodoCacheManager.getInstance(myProject).getTodoCount(virtualFile, pattern.getIndexPattern()); if (count != -1) return count; } TodoItem[] items = findTodoItems(file); for (TodoItem item : items) { if (item.getPattern().equals(pattern)) count++; } return count; }