use of com.intellij.psi.impl.cache.impl.OccurrenceConsumer in project intellij-community by JetBrains.
the class PlainTextTodoIndexer method map.
@Override
@NotNull
public Map<TodoIndexEntry, Integer> map(@NotNull final FileContent inputData) {
// matching strings is faster than HeapCharBuffer
String chars = inputData.getContentAsText().toString();
final IndexPattern[] indexPatterns = IndexPatternUtil.getIndexPatterns();
if (indexPatterns.length <= 0) {
return Collections.emptyMap();
}
OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
for (IndexPattern indexPattern : indexPatterns) {
Pattern pattern = indexPattern.getOptimizedIndexingPattern();
if (pattern != null) {
Matcher matcher = pattern.matcher(chars);
while (matcher.find()) {
if (matcher.start() != matcher.end()) {
occurrenceConsumer.incTodoOccurrence(indexPattern);
}
}
}
}
Map<TodoIndexEntry, Integer> map = new HashMap<>();
for (IndexPattern indexPattern : indexPatterns) {
final int count = occurrenceConsumer.getOccurrenceCount(indexPattern);
if (count > 0) {
map.put(new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), count);
}
}
return map;
}
Aggregations