use of com.intellij.psi.search.IndexPatternProvider in project intellij-community by JetBrains.
the class IndexPatternSearcher method execute.
@Override
public boolean execute(@NotNull final IndexPatternSearch.SearchParameters queryParameters, @NotNull final Processor<IndexPatternOccurrence> consumer) {
final PsiFile file = queryParameters.getFile();
VirtualFile virtualFile = file.getVirtualFile();
if (file instanceof PsiBinaryFile || file instanceof PsiCompiledElement || virtualFile == null) {
return true;
}
final TodoCacheManager cacheManager = TodoCacheManager.SERVICE.getInstance(file.getProject());
final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
int count = patternProvider != null ? cacheManager.getTodoCount(virtualFile, patternProvider) : cacheManager.getTodoCount(virtualFile, queryParameters.getPattern());
return count == 0 || executeImpl(queryParameters, consumer);
}
use of com.intellij.psi.search.IndexPatternProvider in project intellij-community by JetBrains.
the class IndexPatternSearcher method executeImpl.
protected static boolean executeImpl(IndexPatternSearch.SearchParameters queryParameters, Processor<IndexPatternOccurrence> consumer) {
final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
final PsiFile file = queryParameters.getFile();
TIntArrayList commentStarts = new TIntArrayList();
TIntArrayList commentEnds = new TIntArrayList();
final CharSequence chars = file.getViewProvider().getContents();
findCommentTokenRanges(file, chars, queryParameters.getRange(), commentStarts, commentEnds);
TIntArrayList occurrences = new TIntArrayList(1);
IndexPattern[] patterns = patternProvider != null ? patternProvider.getIndexPatterns() : null;
for (int i = 0; i < commentStarts.size(); i++) {
int commentStart = commentStarts.get(i);
int commentEnd = commentEnds.get(i);
occurrences.resetQuick();
if (patternProvider != null) {
for (int j = patterns.length - 1; j >= 0; --j) {
if (!collectPatternMatches(patterns[j], chars, commentStart, commentEnd, file, queryParameters.getRange(), consumer, occurrences)) {
return false;
}
}
} else {
if (!collectPatternMatches(queryParameters.getPattern(), chars, commentStart, commentEnd, file, queryParameters.getRange(), consumer, occurrences)) {
return false;
}
}
}
return true;
}
use of com.intellij.psi.search.IndexPatternProvider in project intellij-community by JetBrains.
the class IndexPatternUtil method getIndexPatterns.
@NotNull
public static IndexPattern[] getIndexPatterns() {
IndexPattern[] result = new IndexPattern[getIndexPatternCount()];
int destIndex = 0;
for (IndexPatternProvider provider : getIndexPatternProviders()) {
for (IndexPattern pattern : provider.getIndexPatterns()) {
result[destIndex++] = pattern;
}
}
return result;
}
Aggregations