Java 类com.intellij.psi.search.searches.DefinitionsScopedSearch 实例源码

项目:intellij-ce-playground    文件:ImplementationSearcher.java   
@Nullable("For the case the search has been cancelled")
protected PsiElement[] searchDefinitions(final PsiElement element, final Editor editor) {
  final PsiElement[][] result = new PsiElement[1][];
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      try {
        result[0] = DefinitionsScopedSearch.search(element, getSearchScope(element, editor)).toArray(PsiElement.EMPTY_ARRAY);
      }
      catch (IndexNotReadyException e) {
        dumbModeNotification(element);
        result[0] = null;
      }
    }
  }, SEARCHING_FOR_IMPLEMENTATIONS, true, element.getProject())) {
    return null;
  }
  return result[0];
}
项目:consulo-csharp    文件:CSharpTypeImplementationSearcher.java   
@Override
public boolean execute(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull final Processor<PsiElement> consumer)
{
    final PsiElement element = queryParameters.getElement();
    if(element instanceof DotNetTypeDeclaration)
    {
        return TypeInheritorsSearch.search((DotNetTypeDeclaration) element, queryParameters.getScope(), queryParameters.isCheckDeep(), true,
                CSharpTransform.INSTANCE).forEach(new Processor<DotNetTypeDeclaration>()

        {
            @Override
            public boolean process(DotNetTypeDeclaration typeDeclaration)
            {
                return consumer.process(typeDeclaration);
            }
        });
    }
    return true;
}
项目:consulo-haxe    文件:HaxeInheritanceDefinitionsSearchExecutor.java   
public static List<HaxeClass> getItemsByQName(final HaxeClass haxeClass)
{
    final List<HaxeClass> result = new ArrayList<HaxeClass>();
    DefinitionsScopedSearch.search(haxeClass).forEach(new Processor<PsiElement>()
    {
        @Override
        public boolean process(PsiElement element)
        {
            if(element instanceof HaxeClass)
            {
                result.add((HaxeClass) element);
            }
            return true;
        }
    });
    return result;
}
项目:intellij-ce-playground    文件:MethodImplementationsSearch.java   
@Override
public boolean execute(@NotNull final DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull final Processor<PsiElement> consumer) {
  final PsiElement sourceElement = queryParameters.getElement();
  if (sourceElement instanceof PsiMethod) {
    return processImplementations((PsiMethod)sourceElement, consumer, queryParameters.getScope());
  }
  return true;
}
项目:intellij-ce-playground    文件:GotoImplementationAction.java   
@Override
public void update(final AnActionEvent event) {
  if (!DefinitionsScopedSearch.INSTANCE.hasAnyExecutors()) {
    event.getPresentation().setVisible(false);
  }
  else {
    super.update(event);
  }
}
项目:intellij-ce-playground    文件:GroovyImplementationSearch.java   
@Override
public boolean execute(@NotNull final DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull final Processor<PsiElement> consumer) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      final PsiElement source = queryParameters.getElement();
      if (!source.isValid()) return true;

      if (source instanceof GrAccessorMethod) {
        GrField property = ((GrAccessorMethod)source).getProperty();
        return consumer.process(property);
      }
      else {
        final SearchScope searchScope = queryParameters.getScope();
        if (source instanceof GrMethod) {
          GrReflectedMethod[] reflectedMethods = ((GrMethod)source).getReflectedMethods();
          for (GrReflectedMethod reflectedMethod : reflectedMethods) {
            if (!MethodImplementationsSearch.processImplementations(reflectedMethod, consumer, searchScope)) return false;
          }
        }

        else if (source instanceof GrField) {
          for (GrAccessorMethod method : GroovyPropertyUtils.getFieldAccessors((GrField)source)) {
            if (!MethodImplementationsSearch.processImplementations(method, consumer, searchScope)) return false;
          }
        }
      }
      return true;
    }
  });
}
项目:consulo-csharp    文件:CSharpMethodImplementationsSearcher.java   
@Override
public boolean execute(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull Processor<PsiElement> consumer)
{
    PsiElement element = queryParameters.getElement();
    if(element instanceof DotNetVirtualImplementOwner)
    {
        Collection<DotNetVirtualImplementOwner> members = ReadAction.compute(() -> OverrideUtil.collectOverridenMembers((DotNetVirtualImplementOwner) element));
        return ContainerUtil.process(members, consumer);
    }
    return true;
}
项目:consulo    文件:GotoImplementationAction.java   
@RequiredDispatchThread
@Override
public void update(final AnActionEvent event) {
  if (!DefinitionsScopedSearch.INSTANCE.hasAnyExecutors()) {
    event.getPresentation().setVisible(false);
  }
  else {
    super.update(event);
  }
}
项目:consulo    文件:PomDefinitionSearch.java   
@Override
public boolean execute(@Nonnull DefinitionsScopedSearch.SearchParameters parameters, @Nonnull Processor<PsiElement> consumer) {
  PsiElement element = parameters.getElement();
  if (element instanceof PomTargetPsiElement) {
    final PomTarget target = ((PomTargetPsiElement)element).getTarget();
    if (target instanceof PsiTarget) {
      if (!consumer.process(((PsiTarget)target).getNavigationElement())) return false;
    }
  }
  return true;
}
项目:consulo-javascript    文件:JSParameterInfoHandler.java   
@Override
public Object[] getParametersForLookup(final LookupElement item, final ParameterInfoContext context)
{
    if(!(item instanceof MutableLookupElement))
    {
        return null;
    }

    PsiElement element = item.getPsiElement();
    if(element instanceof JSFunction)
    {
        final JSFunction originalFunction = (JSFunction) element;
        final List<JSFunction> lookupItems = new ArrayList<JSFunction>();
        Set<String> availableSignatures = new HashSet<String>();

        for(PsiElement el : DefinitionsScopedSearch.search(originalFunction))
        {
            doAddSignature(lookupItems, availableSignatures, el);
        }

        if(lookupItems.size() == 0)
        {
            lookupItems.add(originalFunction);
        }

        return lookupItems.toArray(new Object[lookupItems.size()]);
    }

    return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
项目:consulo-java    文件:MethodImplementationsSearch.java   
@Override
public boolean execute(@NotNull final DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull final Processor<PsiElement> consumer)
{
    final PsiElement sourceElement = queryParameters.getElement();
    if(sourceElement instanceof PsiMethod)
    {
        return processImplementations((PsiMethod) sourceElement, consumer, queryParameters.getScope());
    }
    return true;
}
项目:intellij-ce-playground    文件:ClassImplementationsSearch.java   
@Override
public boolean execute(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull Processor<PsiElement> consumer) {
  final PsiElement sourceElement = queryParameters.getElement();
  return !(sourceElement instanceof PsiClass) || processImplementations((PsiClass)sourceElement, consumer, queryParameters.getScope());
}
项目:consulo-haxe    文件:HaxeInheritanceDefinitionsSearchExecutor.java   
@Override
public boolean execute(@NotNull final DefinitionsScopedSearch.SearchParameters parameters, @NotNull final Processor<PsiElement> consumer)
{
    final PsiElement queryParameters = parameters.getElement();
    return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>()
    {
        public Boolean compute()
        {
            final PsiElement queryParametersParent = queryParameters.getParent();
            HaxeNamedComponent haxeNamedComponent;
            if(queryParameters instanceof HaxeClass)
            {
                haxeNamedComponent = (HaxeClass) queryParameters;
            }
            else if(queryParametersParent instanceof HaxeNamedComponent && queryParameters instanceof HaxeComponentName)
            {
                haxeNamedComponent = (HaxeNamedComponent) queryParametersParent;
            }
            else
            {
                return true;
            }
            if(haxeNamedComponent instanceof HaxeClass)
            {
                processInheritors(((HaxeClass) haxeNamedComponent).getQualifiedName(), queryParameters, consumer);
            }
            else if(HaxeComponentType.typeOf(haxeNamedComponent) == HaxeComponentType.METHOD || HaxeComponentType.typeOf(haxeNamedComponent) == HaxeComponentType.FIELD)
            {
                final String nameToFind = haxeNamedComponent.getName();
                if(nameToFind == null)
                {
                    return true;
                }

                HaxeClass haxeClass = PsiTreeUtil.getParentOfType(haxeNamedComponent, HaxeClass.class);
                assert haxeClass != null;

                processInheritors(haxeClass.getQualifiedName(), queryParameters, new Processor<PsiElement>()
                {
                    @Override
                    public boolean process(PsiElement element)
                    {
                        for(HaxeNamedComponent subHaxeNamedComponent : HaxeResolveUtil.getNamedSubComponents((HaxeClass) element))
                        {
                            if(nameToFind.equals(subHaxeNamedComponent.getName()))
                            {
                                consumer.process(subHaxeNamedComponent);
                            }
                        }
                        return true;
                    }
                });
            }
            return true;
        }
    });
}
项目:consulo    文件:ImplementationSearcher.java   
protected Query<PsiElement> search(PsiElement element, Editor editor) {
  return DefinitionsScopedSearch.search(element, getSearchScope(element, editor), isSearchDeep());
}
项目:consulo-java    文件:ClassImplementationsSearch.java   
@Override
public boolean execute(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull Processor<PsiElement> consumer)
{
    final PsiElement sourceElement = queryParameters.getElement();
    return !(sourceElement instanceof PsiClass) || processImplementations((PsiClass) sourceElement, consumer, queryParameters.getScope());
}