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

项目:lua-for-idea    文件:LuaDocSymbolReferenceElementImpl.java   
@NotNull
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    final String refName = getName();
    if (refName == null)
        return LuaResolveResult.EMPTY_ARRAY;

    ResolveProcessor processor = new SymbolResolveProcessor(refName, this, incompleteCode);

    final LuaDocCommentOwner docOwner = LuaDocCommentUtil.findDocOwner(this);
    if (docOwner != null) {
        final LuaStatementElement statementElement =
                PsiTreeUtil.getParentOfType(docOwner, LuaStatementElement.class, false);
        if (statementElement != null)
            statementElement.processDeclarations(processor, ResolveState.initial(), this, this);
    }
    if (processor.hasCandidates()) {
        return processor.getCandidates();
    }

    LuaGlobalDeclarationIndex index = LuaGlobalDeclarationIndex.getInstance();
    Collection<LuaDeclarationExpression> names = index.get(refName, getProject(),
            new ProjectAndLibrariesScope(getProject()));
    for (LuaDeclarationExpression name : names) {
        name.processDeclarations(processor, ResolveState.initial(), this, this);
    }

    if (processor.hasCandidates()) {
        return processor.getCandidates();
    }

    return LuaResolveResult.EMPTY_ARRAY;
}
项目:lua-for-idea    文件:LuaPsiManager.java   
@Override
public Collection<LuaDeclarationExpression> call() throws Exception {
    DumbService.getInstance(project).waitForSmartMode();
    return ApplicationManager.getApplication()
                             .runReadAction(new Computable<Collection<LuaDeclarationExpression>>() {

                                 @Override
                                 public Collection<LuaDeclarationExpression> compute() {
                                     return ResolveUtil.getFilteredGlobals(project,
                                             new ProjectAndLibrariesScope(project));
                                 }
                             });
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLFindUsagesHandlerFactory.java   
/**
 * includes the GraphQL schema virtual file in the provided "Project and Libraries" scope
 * @see JSGraphQLProjectAndLibrariesScope
 */
private static void addGraphQLSchemaFileToProjectAndLibrariesScope(FindUsagesOptions options) {
    if(options.searchScope instanceof ProjectAndLibrariesScope) {
        final ProjectAndLibrariesScope projectAndLibrariesScope = (ProjectAndLibrariesScope) options.searchScope;
        options.searchScope = new JSGraphQLProjectAndLibrariesScope(projectAndLibrariesScope);
    }
}
项目:eddy    文件:EnvironmentProcessorTest.java   
private Map<PsiElement,Item> getGlobalEnvItems() {
  if (global_envitems_ready) {
    return global_envitems;
  } else {

    synchronized (global_envitems_lock) {

      if (global_envitems == null) {
        // get all classes from IntelliJ
        global_envitems = new HashMap<PsiElement, Item>();
      }

      logger.info("making global_envitems (" + global_envitems.size() + " items already there)");

      PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
      String[] classnames = cache.getAllClassNames();
      GlobalSearchScope scope = new ProjectAndLibrariesScope(project, true);

      // Add all classes.  TODO: This includes local classes, but probably shouldn't
      Map<PsiElement,Item> fake_globals = new HashMap<PsiElement,Item>();
      for (String name : classnames)
        for (PsiClass cls : cache.getClassesByName(name, scope))
          if (!isInaccessible(cls, true))
            addClass(fake_globals, global_envitems, cls, true, true);

      logger.info("making global_env with " + global_envitems.size() + " items.");

      // update global_env
      global_env = Tarski.environment(global_envitems.values());

      logger.info("global_env ready.");

      global_envitems_ready = true;

    }

    return global_envitems;
  }
}
项目:TheRPlugin    文件:TheRPsiUtils.java   
public static TheRCallExpression findCall(Project project, String functionName, Predicate<TheRCallExpression> predicate) {
  ProjectAndLibrariesScope scope = new ProjectAndLibrariesScope(project);
  Collection<TheRAssignmentStatement> possibleDefinitions =
    TheRAssignmentNameIndex.find(functionName, project, scope);
  TheRAssignmentStatement functionDefinition = null;
  for (TheRAssignmentStatement assignment : possibleDefinitions) {
    if (assignment.getAssignedValue() instanceof TheRFunctionExpression) {
      functionDefinition = assignment;
      break;
    }
  }
  if (functionDefinition == null) {
    return null;
  }
  for (PsiReference reference : ReferencesSearch.search(functionDefinition, scope)) {
    PsiElement referenceFrom = reference.getElement();
    PsiElement parent = referenceFrom.getParent();
    if (parent == null || !TheRCallExpression.class.isInstance(parent)) {
      continue;
    }
    TheRCallExpression call = (TheRCallExpression)parent;
    if (predicate.apply(call)) {
      return call;
    }
  }
  return null;
}
项目:consulo-lua    文件:LuaDocSymbolReferenceElementImpl.java   
@NotNull
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    final String refName = getName();
    if (refName == null)
        return LuaResolveResult.EMPTY_ARRAY;

    ResolveProcessor processor = new SymbolResolveProcessor(refName, this, incompleteCode);

    final LuaDocCommentOwner docOwner = LuaDocCommentUtil.findDocOwner(this);
    if (docOwner != null) {
        final LuaStatementElement statementElement =
                PsiTreeUtil.getParentOfType(docOwner, LuaStatementElement.class, false);
        if (statementElement != null)
            statementElement.processDeclarations(processor, ResolveState.initial(), this, this);
    }
    if (processor.hasCandidates()) {
        return processor.getCandidates();
    }

    LuaGlobalDeclarationIndex index = LuaGlobalDeclarationIndex.getInstance();
    Collection<LuaDeclarationExpression> names = index.get(refName, getProject(),
            new ProjectAndLibrariesScope(getProject()));
    for (LuaDeclarationExpression name : names) {
        name.processDeclarations(processor, ResolveState.initial(), this, this);
    }

    if (processor.hasCandidates()) {
        return processor.getCandidates();
    }

    return LuaResolveResult.EMPTY_ARRAY;
}
项目:consulo-lua    文件:LuaPsiManager.java   
@Override
public Collection<LuaDeclarationExpression> call() throws Exception {
    DumbService.getInstance(project).waitForSmartMode();
    return ApplicationManager.getApplication()
                             .runReadAction(new Computable<Collection<LuaDeclarationExpression>>() {

                                 @Override
                                 public Collection<LuaDeclarationExpression> compute() {
                                     return ResolveUtil.getFilteredGlobals(project,
                                             new ProjectAndLibrariesScope(project));
                                 }
                             });
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLProjectAndLibrariesScope.java   
@SuppressWarnings("ConstantConditions")
public JSGraphQLProjectAndLibrariesScope(ProjectAndLibrariesScope delegate) {
    super(delegate.getProject(), delegate.isSearchOutsideRootModel());
    this.delegate = delegate;
}