Java 类com.intellij.psi.search.SearchRequestCollector 实例源码

项目:intellij-ce-playground    文件:SimpleAccessorReferenceSearcher.java   
static void addPropertyAccessUsages(PsiMethod method, SearchScope scope, SearchRequestCollector collector) {
  final String propertyName = PropertyUtil.getPropertyName(method);
  if (StringUtil.isNotEmpty(propertyName)) {
    SearchScope additional = GlobalSearchScope.EMPTY_SCOPE;
    for (CustomPropertyScopeProvider provider : Extensions.getExtensions(CustomPropertyScopeProvider.EP_NAME)) {
      additional = additional.union(provider.getScope(method.getProject()));
    }
    final SearchScope propScope = scope.intersectWith(method.getUseScope()).intersectWith(additional);
    collector.searchWord(propertyName, propScope, UsageSearchContext.IN_FOREIGN_LANGUAGES, true, method);
  }
}
项目:tools-idea    文件:SimpleAccessorReferenceSearcher.java   
static void addPropertyAccessUsages(PsiMethod method, SearchScope scope, SearchRequestCollector collector) {
  final String propertyName = PropertyUtil.getPropertyName(method);
  if (StringUtil.isNotEmpty(propertyName)) {
    SearchScope additional = GlobalSearchScope.EMPTY_SCOPE;
    for (CustomPropertyScopeProvider provider : Extensions.getExtensions(CustomPropertyScopeProvider.EP_NAME)) {
      additional = additional.union(provider.getScope(method.getProject()));
    }
    assert propertyName != null;
    final SearchScope propScope = scope.intersectWith(method.getUseScope()).intersectWith(additional);
    collector.searchWord(propertyName, propScope, UsageSearchContext.IN_FOREIGN_LANGUAGES, true, method);
  }
}
项目:consulo-java    文件:SimpleAccessorReferenceSearcher.java   
static void addPropertyAccessUsages(PsiMethod method, SearchScope scope, SearchRequestCollector collector) {
  final String propertyName = PropertyUtil.getPropertyName(method);
  if (StringUtil.isNotEmpty(propertyName)) {
    SearchScope additional = GlobalSearchScope.EMPTY_SCOPE;
    for (CustomPropertyScopeProvider provider : Extensions.getExtensions(CustomPropertyScopeProvider.EP_NAME)) {
      additional = additional.union(provider.getScope(method.getProject()));
    }
    assert propertyName != null;
    final SearchScope propScope = scope.intersectWith(method.getUseScope()).intersectWith(additional);
    collector.searchWord(propertyName, propScope, UsageSearchContext.IN_FOREIGN_LANGUAGES, true, method);
  }
}
项目:consulo-java    文件:MethodReferencesSearch.java   
public SearchParameters(@NotNull PsiMethod method,
        @NotNull SearchScope scope,
        boolean strictSignatureSearch,
        @Nullable SearchRequestCollector optimizer)
{
    myMethod = method;
    myScope = scope;
    myStrictSignatureSearch = strictSignatureSearch;
    isSharedOptimizer = optimizer != null;
    myOptimizer = optimizer != null ? optimizer : new SearchRequestCollector(new SearchSession());
    myProject = PsiUtilCore.getProjectInReadAction(method);
}
项目:consulo-java    文件:MethodReferencesSearch.java   
public static void searchOptimized(final PsiMethod method,
        SearchScope scope,
        final boolean strictSignatureSearch,
        SearchRequestCollector collector,
        final boolean inReadAction,
        PairProcessor<PsiReference, SearchRequestCollector> processor)
{
    final SearchRequestCollector nested = new SearchRequestCollector(collector.getSearchSession());
    collector.searchQuery(new QuerySearchRequest(search(new SearchParameters(method, scope, strictSignatureSearch,
            nested)), nested, inReadAction, processor));
}
项目:consulo-java    文件:MethodReferencesSearch.java   
public static Query<PsiReference> search(final SearchParameters parameters)
{
    final Query<PsiReference> result = INSTANCE.createQuery(parameters);
    if(parameters.isSharedOptimizer)
    {
        return uniqueResults(result);
    }

    final SearchRequestCollector requests = parameters.getOptimizer();

    Project project = PsiUtilCore.getProjectInReadAction(parameters.getMethod());
    return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(project, requests)));
}
项目:intellij-ce-playground    文件:GroovyConstructorUsagesSearcher.java   
static void processConstructorUsages(final PsiMethod constructor,
                                     final SearchScope searchScope,
                                     final Processor<PsiReference> consumer,
                                     final SearchRequestCollector collector,
                                     final boolean includeOverloads) {
  if (!constructor.isConstructor()) return;

  final PsiClass clazz = constructor.getContainingClass();
  if (clazz == null) return;

  SearchScope onlyGroovy = GroovyScopeUtil.restrictScopeToGroovyFiles(searchScope, GroovyScopeUtil.getEffectiveScope(constructor));
  Set<PsiClass> processed = collector.getSearchSession().getUserData(LITERALLY_CONSTRUCTED_CLASSES);
  if (processed == null) {
    collector.getSearchSession().putUserData(LITERALLY_CONSTRUCTED_CLASSES, processed = ContainerUtil.newConcurrentSet());
  }
  if (!processed.add(clazz)) return;

  if (clazz.isEnum() && clazz instanceof GroovyPsiElement) {
    for (PsiField field : clazz.getFields()) {
      if (field instanceof GrEnumConstant) {
        final PsiReference ref = field.getReference();
        if (ref != null && ref.isReferenceTo(constructor)) {
          if (!consumer.process(ref)) return;
        }
      }
    }
  }

  final LiteralConstructorSearcher literalProcessor = new LiteralConstructorSearcher(constructor, consumer, includeOverloads);

  final Processor<GrNewExpression> newExpressionProcessor = new Processor<GrNewExpression>() {
    @Override
    public boolean process(GrNewExpression grNewExpression) {
      final PsiMethod resolvedConstructor = grNewExpression.resolveMethod();
      if (includeOverloads || constructor.getManager().areElementsEquivalent(resolvedConstructor, constructor)) {
        return consumer.process(grNewExpression.getReferenceElement());
      }
      return true;
    }
  };

  processGroovyClassUsages(clazz, searchScope, collector, newExpressionProcessor, literalProcessor);

  //this()
  if (clazz instanceof GrTypeDefinition) {
    if (!processConstructors(constructor, consumer, clazz, true)) {
      return;
    }
  }
  //super()
  DirectClassInheritorsSearch.search(clazz, onlyGroovy).forEach(new ReadActionProcessor<PsiClass>() {
    @Override
    public boolean processInReadAction(PsiClass inheritor) {
      if (inheritor instanceof GrTypeDefinition) {
        if (!processConstructors(constructor, consumer, inheritor, false)) return false;
      }
      return true;
    }
  });
}
项目:consulo-java    文件:MethodReferencesSearch.java   
public SearchRequestCollector getOptimizer()
{
    return myOptimizer;
}