Search in sources :

Example 1 with IndexPatternProvider

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) IndexPatternProvider(com.intellij.psi.search.IndexPatternProvider)

Example 2 with IndexPatternProvider

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;
}
Also used : IndexPatternProvider(com.intellij.psi.search.IndexPatternProvider) IndexPattern(com.intellij.psi.search.IndexPattern) TIntArrayList(gnu.trove.TIntArrayList)

Example 3 with IndexPatternProvider

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;
}
Also used : IndexPattern(com.intellij.psi.search.IndexPattern) IndexPatternProvider(com.intellij.psi.search.IndexPatternProvider) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IndexPatternProvider (com.intellij.psi.search.IndexPatternProvider)3 IndexPattern (com.intellij.psi.search.IndexPattern)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 TodoCacheManager (com.intellij.psi.impl.cache.TodoCacheManager)1 TIntArrayList (gnu.trove.TIntArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1