use of com.intellij.psi.search.IndexPattern in project intellij-community by JetBrains.
the class IndexTodoCacheManagerImpl method getFilesWithTodoItems.
@Override
@NotNull
public PsiFile[] getFilesWithTodoItems() {
if (myProject.isDefault()) {
return PsiFile.EMPTY_ARRAY;
}
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
final Set<PsiFile> allFiles = new HashSet<>();
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(TodoIndex.NAME, new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
ApplicationManager.getApplication().runReadAction(() -> {
for (VirtualFile file : files) {
if (projectFileIndex.isInContent(file)) {
final PsiFile psiFile = myPsiManager.findFile(file);
if (psiFile != null) {
allFiles.add(psiFile);
}
}
}
});
}
return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(allFiles);
}
use of com.intellij.psi.search.IndexPattern 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;
}
Aggregations