Search in sources :

Example 1 with PsiTodoSearchHelper

use of com.intellij.psi.search.PsiTodoSearchHelper in project intellij-community by JetBrains.

the class GeneralHighlightingPass method highlightTodos.

static void highlightTodos(@NotNull PsiFile file, @NotNull CharSequence text, int startOffset, int endOffset, @NotNull ProgressIndicator progress, @NotNull ProperTextRange priorityRange, @NotNull Collection<HighlightInfo> insideResult, @NotNull Collection<HighlightInfo> outsideResult) {
    PsiTodoSearchHelper helper = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject());
    if (helper == null || !shouldHighlightTodos(helper, file))
        return;
    TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset);
    if (todoItems.length == 0)
        return;
    for (TodoItem todoItem : todoItems) {
        progress.checkCanceled();
        TextRange range = todoItem.getTextRange();
        TextAttributes attributes = todoItem.getPattern().getAttributes().getTextAttributes();
        HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.TODO).range(range);
        builder.textAttributes(attributes);
        String description = text.subSequence(range.getStartOffset(), range.getEndOffset()).toString();
        builder.description(description);
        builder.unescapedToolTip(StringUtil.shortenPathWithEllipsis(description, 1024));
        HighlightInfo info = builder.createUnconditionally();
        (priorityRange.containsRange(info.getStartOffset(), info.getEndOffset()) ? insideResult : outsideResult).add(info);
    }
}
Also used : PsiTodoSearchHelper(com.intellij.psi.search.PsiTodoSearchHelper) TodoItem(com.intellij.psi.search.TodoItem) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Aggregations

TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 PsiTodoSearchHelper (com.intellij.psi.search.PsiTodoSearchHelper)1 TodoItem (com.intellij.psi.search.TodoItem)1