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

项目:intellij-ce-playground    文件:PlatformPackageUtil.java   
public static GlobalSearchScope adjustScope(PsiDirectory baseDir,
                                            GlobalSearchScope scope,
                                            boolean skipSourceDirsForBaseTestDirectory,
                                            boolean skipTestDirsForBaseSourceDirectory) {
  if (baseDir != null) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(baseDir.getProject()).getFileIndex();
    if (fileIndex.isInTestSourceContent(baseDir.getVirtualFile())) {
      if (skipSourceDirsForBaseTestDirectory) {
        return scope.intersectWith(GlobalSearchScopes.projectTestScope(baseDir.getProject()));
      }
    }
    else {
      if (skipTestDirsForBaseSourceDirectory) {
        return scope.intersectWith(GlobalSearchScopes.projectProductionScope(baseDir.getProject()));
      }
    }
  }
  return scope;
}
项目:tools-idea    文件:HierarchyTreeStructure.java   
protected SearchScope getSearchScope(final String scopeType, final PsiElement thisClass) {
  SearchScope searchScope = GlobalSearchScope.allScope(myProject);
  if (HierarchyBrowserBaseEx.SCOPE_CLASS.equals(scopeType)) {
    searchScope = new LocalSearchScope(thisClass);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_PROJECT.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectProductionScope(myProject);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_TEST.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectTestScope(myProject);
  } else {
    final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType);
    if (namedScope != null) {
      searchScope = GlobalSearchScopes.filterScope(myProject, namedScope);
    }
  }
  return searchScope;
}
项目:tools-idea    文件:PlatformPackageUtil.java   
public static GlobalSearchScope adjustScope(PsiDirectory baseDir,
                                            GlobalSearchScope scope,
                                            boolean skipSourceDirsForBaseTestDirectory,
                                            boolean skipTestDirsForBaseSourceDirectory) {
  if (baseDir != null) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(baseDir.getProject()).getFileIndex();
    if (fileIndex.isInTestSourceContent(baseDir.getVirtualFile())) {
      if (skipSourceDirsForBaseTestDirectory) {
        return scope.intersectWith(GlobalSearchScopes.projectTestScope(baseDir.getProject()));
      }
    }
    else {
      if (skipTestDirsForBaseSourceDirectory) {
        return scope.intersectWith(GlobalSearchScopes.projectProductionScope(baseDir.getProject()));
      }
    }
  }
  return scope;
}
项目:consulo    文件:HierarchyTreeStructure.java   
protected SearchScope getSearchScope(final String scopeType, final PsiElement thisClass) {
  SearchScope searchScope = GlobalSearchScope.allScope(myProject);
  if (HierarchyBrowserBaseEx.SCOPE_CLASS.equals(scopeType)) {
    searchScope = new LocalSearchScope(thisClass);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_PROJECT.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectProductionScope(myProject);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_TEST.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectTestScope(myProject);
  } else {
    final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType);
    if (namedScope != null) {
      searchScope = GlobalSearchScopes.filterScope(myProject, namedScope);
    }
  }
  return searchScope;
}
项目:MvnRunner    文件:PomNavigationContributor.java   
private Map<MavenId, PsiFile> getNotImportPoms(MavenProject mavenProject) {
    GlobalSearchScope pomScope = GlobalSearchScopes.directoryScope(project, mavenProject.getDirectoryFile(), true);
    PsiFile[] psiFiles = FilenameIndex.getFilesByName(project, "pom.xml", pomScope);
    Map<MavenId, PsiFile> poms = new LinkedHashMap<MavenId, PsiFile>(psiFiles.length);
    for (PsiFile psiFile : psiFiles) {
        if (projectsManager.findProject(psiFile.getVirtualFile()) == null) {
            MavenId mavenId = MavenDomUtil.describe(psiFile);
            poms.put(mavenId, psiFile);
        }
    }
    return poms;
}
项目:tools-idea    文件:TestDirectory.java   
@Override
public SourceScope getSourceScope() {
  final String dirName = myConfiguration.getPersistentData().getDirName();
  final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(dirName));
  final GlobalSearchScope globalSearchScope = file == null ? GlobalSearchScope.EMPTY_SCOPE : GlobalSearchScopes
      .directoryScope(myProject, file, true);
  return new SourceScope() {
    @Override
    public GlobalSearchScope getGlobalSearchScope() {
      return globalSearchScope;
    }

    @Override
    public Project getProject() {
      return myProject;
    }

    @Override
    public GlobalSearchScope getLibrariesScope() {
      final Module module = myConfiguration.getConfigurationModule().getModule();
      LOG.assertTrue(module != null);
      return GlobalSearchScope.moduleWithLibrariesScope(module);
    }

    @Override
    public Module[] getModulesToCompile() {
      final Collection<Module> validModules = myConfiguration.getValidModules();
      return validModules.toArray(new Module[validModules.size()]);
    }
  };
}
项目:tools-idea    文件:BackendCompilerWrapper.java   
private void buildOutputItemsList(final String outputDir, final Module module, VirtualFile from,
                                  final FileTypeManager typeManager,
                                  final VirtualFile sourceRoot,
                                  final String packagePrefix, final List<File> filesToRefresh, final Map<String, Collection<TranslatingCompiler.OutputItem>> results) throws CacheCorruptedException {
  final Ref<CacheCorruptedException> exRef = new Ref<CacheCorruptedException>(null);
  final ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex();
  final GlobalSearchScope srcRootScope = GlobalSearchScope.moduleScope(module).intersectWith(
      GlobalSearchScopes.directoryScope(myProject, sourceRoot, true));

  final ContentIterator contentIterator = new ContentIterator() {
    public boolean processFile(final VirtualFile child) {
      try {
        if (child.isValid()) {
          if (!child.isDirectory() && myCompiler.getCompilableFileTypes().contains(child.getFileType())) {
            updateOutputItemsList(outputDir, child, sourceRoot, packagePrefix, filesToRefresh, results, srcRootScope);
          }
        }
        return true;
      }
      catch (CacheCorruptedException e) {
        exRef.set(e);
        return false;
      }
    }
  };
  if (fileIndex.isInContent(from)) {
    // use file index for iteration to handle 'inner modules' and excludes properly
    fileIndex.iterateContentUnderDirectory(from, contentIterator);
  }
  else {
    // seems to be a root for generated sources
    VfsUtilCore.visitChildrenRecursively(from, new VirtualFileVisitor() {
      @Override
      public boolean visitFile(@NotNull VirtualFile file) {
        if (!file.isDirectory()) {
          contentIterator.processFile(file);
        }
        return true;
      }
    });
  }
  final CacheCorruptedException exc = exRef.get();
  if (exc != null) {
    throw exc;
  }
}
项目:consulo-java    文件:BackendCompilerWrapper.java   
private void buildOutputItemsList(final String outputDir,
        final Module module,
        VirtualFile from,
        final FileTypeManager typeManager,
        final VirtualFile sourceRoot,
        final String packagePrefix,
        final List<File> filesToRefresh,
        final Map<String, Collection<TranslatingCompiler.OutputItem>> results) throws CacheCorruptedException
{
    final Ref<CacheCorruptedException> exRef = new Ref<>(null);
    final ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex();
    final GlobalSearchScope srcRootScope = GlobalSearchScope.moduleScope(module).intersectWith(GlobalSearchScopes.directoryScope(myProject,
            sourceRoot, true));

    final Collection<FileType> registeredInputTypes = CompilerManager.getInstance(myProject).getRegisteredInputTypes(myTranslatingCompiler);

    final ContentIterator contentIterator = new ContentIterator()
    {
        @Override
        public boolean processFile(final VirtualFile child)
        {
            try
            {
                if(child.isValid())
                {
                    if(!child.isDirectory() && registeredInputTypes.contains(child.getFileType()))
                    {
                        updateOutputItemsList(outputDir, child, sourceRoot, packagePrefix, filesToRefresh, results, srcRootScope);
                    }
                }
                return true;
            }
            catch(CacheCorruptedException e)
            {
                exRef.set(e);
                return false;
            }
        }
    };
    if(fileIndex.isInContent(from))
    {
        // use file index for iteration to handle 'inner modules' and excludes properly
        fileIndex.iterateContentUnderDirectory(from, contentIterator);
    }
    else
    {
        // seems to be a root for generated sources
        VfsUtilCore.visitChildrenRecursively(from, new VirtualFileVisitor()
        {
            @Override
            public boolean visitFile(@NotNull VirtualFile file)
            {
                if(!file.isDirectory())
                {
                    contentIterator.processFile(file);
                }
                return true;
            }
        });
    }
    final CacheCorruptedException exc = exRef.get();
    if(exc != null)
    {
        throw exc;
    }
}