private Collection<AbstractTreeNode> createGeneralList() { ArrayList<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(); PsiFile psiFile = getValue(); final TodoItem[] items = findAllTodos(psiFile, myBuilder.getTodoTreeStructure().getSearchHelper()); final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(psiFile); if (document != null) { for (final TodoItem todoItem : items) { if (todoItem.getTextRange().getEndOffset() < document.getTextLength() + 1) { final SmartTodoItemPointer pointer = new SmartTodoItemPointer(todoItem, document); TodoFilter todoFilter = getToDoFilter(); if (todoFilter != null) { if (todoFilter.contains(todoItem.getPattern())) { children.add(new TodoItemNode(getProject(), pointer, myBuilder)); } } else { children.add(new TodoItemNode(getProject(), pointer, myBuilder)); } } } } Collections.sort(children, SmartTodoItemPointerComparator.ourInstance); return children; }
protected void updateImpl(PresentationData data) { super.updateImpl(data); String newName; if (myBuilder.getTodoTreeStructure().isPackagesShown()) { newName = getValue().getName(); } else { newName = mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl(); } int nameEndOffset = newName.length(); int todoItemCount; try { todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue()); } catch (IndexNotReadyException e) { return; } if (mySingleFileMode) { if (todoItemCount == 0) { newName = IdeBundle.message("node.todo.no.items.found", newName); } else { newName = IdeBundle.message("node.todo.found.items", newName, todoItemCount); } } else { newName = IdeBundle.message("node.todo.items", newName, todoItemCount); } myHighlightedRegions.clear(); TextAttributes textAttributes = new TextAttributes(); textAttributes.setForegroundColor(myColor); myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes)); EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme(); myHighlightedRegions.add( new HighlightedRegion( nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES))); }
private TodoFilter getToDoFilter() { return myBuilder.getTodoTreeStructure().getTodoFilter(); }