Search in sources :

Example 1 with TodoPattern

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

the class TodoFilter method readExternal.

private void readExternal(@NotNull Element element, @NotNull List<TodoPattern> patterns) {
    myName = element.getAttributeValue(ATTRIBUTE_NAME);
    if (myName == null) {
        throw new IllegalArgumentException();
    }
    myTodoPatterns.clear();
    for (Element child : element.getChildren(ELEMENT_PATTERN)) {
        try {
            int index = Integer.parseInt(child.getAttributeValue(ATTRIBUTE_INDEX));
            if (index < 0 || index > patterns.size() - 1) {
                continue;
            }
            TodoPattern pattern = patterns.get(index);
            if (myTodoPatterns.contains(pattern)) {
                continue;
            }
            myTodoPatterns.add(pattern);
        } catch (NumberFormatException ignored) {
        }
    }
}
Also used : Element(org.jdom.Element) TodoPattern(com.intellij.psi.search.TodoPattern)

Example 2 with TodoPattern

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

the class TodoConfigurable method reset.

@Override
public void reset() {
    // Patterns
    myPatterns.clear();
    TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
    TodoPattern[] patterns = getTodoPatternsToDisplay(todoConfiguration);
    for (TodoPattern pattern : patterns) {
        myPatterns.add(pattern.clone());
    }
    myPatternsModel.fireTableDataChanged();
    // Filters
    myFilters.clear();
    TodoFilter[] filters = todoConfiguration.getTodoFilters();
    for (TodoFilter filter : filters) {
        myFilters.add(filter.clone());
    }
    myFiltersModel.fireTableDataChanged();
}
Also used : TodoFilter(com.intellij.ide.todo.TodoFilter) TodoPattern(com.intellij.psi.search.TodoPattern) TodoConfiguration(com.intellij.ide.todo.TodoConfiguration)

Example 3 with TodoPattern

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

the class IdCacheTest method testUpdateOnTodoChange.

public void testUpdateOnTodoChange() throws Exception {
    TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true);
    TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
    TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[] { pattern });
    try {
        final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
        checkResult(new String[] { "2.java" }, convert(todocache.getFilesWithTodoItems()));
        assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
        assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
        assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
    } finally {
        TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
    }
}
Also used : TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) TodoPattern(com.intellij.psi.search.TodoPattern)

Example 4 with TodoPattern

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

the class TodoFilter method writeExternal.

/**
   * @param element  in which all data will be stored
   * @param patterns all available patterns
   */
public void writeExternal(Element element, TodoPattern[] patterns) {
    element.setAttribute(ATTRIBUTE_NAME, myName);
    for (TodoPattern pattern : myTodoPatterns) {
        int index = ArrayUtilRt.find(patterns, pattern);
        LOG.assertTrue(index != -1);
        Element child = new Element(ELEMENT_PATTERN);
        child.setAttribute(ATTRIBUTE_INDEX, Integer.toString(index));
        element.addContent(child);
    }
}
Also used : Element(org.jdom.Element) TodoPattern(com.intellij.psi.search.TodoPattern)

Example 5 with TodoPattern

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

the class TodoTreeStructure method getTodoItemCount.

/**
   * @return number of {@code TodoItem}s located in the file.
   */
public final int getTodoItemCount(PsiFile psiFile) {
    int count = 0;
    if (psiFile != null) {
        if (myTodoFilter != null) {
            for (Iterator i = myTodoFilter.iterator(); i.hasNext(); ) {
                TodoPattern pattern = (TodoPattern) i.next();
                count += getSearchHelper().getTodoItemsCount(psiFile, pattern);
            }
        } else {
            count = getSearchHelper().getTodoItemsCount(psiFile);
        }
    }
    return count;
}
Also used : Iterator(java.util.Iterator) TodoPattern(com.intellij.psi.search.TodoPattern)

Aggregations

TodoPattern (com.intellij.psi.search.TodoPattern)9 TodoFilter (com.intellij.ide.todo.TodoFilter)3 TodoConfiguration (com.intellij.ide.todo.TodoConfiguration)2 Element (org.jdom.Element)2 TodoCacheManager (com.intellij.psi.impl.cache.TodoCacheManager)1 JBTable (com.intellij.ui.table.JBTable)1 MouseEvent (java.awt.event.MouseEvent)1 Iterator (java.util.Iterator)1 TableColumn (javax.swing.table.TableColumn)1 Nullable (org.jetbrains.annotations.Nullable)1