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) {
}
}
}
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();
}
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);
}
}
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);
}
}
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;
}
Aggregations