Java Code Examples for com.intellij.psi.search.GlobalSearchScope#uniteWith()

The following examples show how to use com.intellij.psi.search.GlobalSearchScope#uniteWith() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: consulo   File: TestConsoleProperties.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
protected GlobalSearchScope initScope() {
  RunProfile configuration = getConfiguration();
  if (!(configuration instanceof ModuleRunProfile)) {
    return GlobalSearchScope.allScope(myProject);
  }

  Module[] modules = ((ModuleRunProfile)configuration).getModules();
  if (modules.length == 0) {
    return GlobalSearchScope.allScope(myProject);
  }

  GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
  for (Module each : modules) {
    scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(each, true));
  }
  return scope;
}
 
Example 2
Source Project: consulo   File: SearchScopeProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public static GlobalSearchScope createSearchScope(@Nonnull Project project, @Nullable RunProfile runProfile) {
  Module[] modules = null;
  if (runProfile instanceof SearchScopeProvidingRunProfile) {
    modules = ((SearchScopeProvidingRunProfile)runProfile).getModules();
  }
  if (modules == null || modules.length == 0) {
    return GlobalSearchScope.allScope(project);
  }
  else {
    GlobalSearchScope scope = GlobalSearchScope.moduleRuntimeScope(modules[0], true);
    for (int idx = 1; idx < modules.length; idx++) {
      Module module = modules[idx];
      scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(module, true));
    }
    return scope;
  }
}
 
Example 3
public static GlobalSearchScope getElementGlobalSearchScope(BashPsiElement element, Project project) {
    PsiFile psiFile = BashPsiUtils.findFileContext(element);
    GlobalSearchScope currentFileScope = GlobalSearchScope.fileScope(psiFile);

    Set<PsiFile> includedFiles = FileInclusionManager.findIncludedFiles(psiFile, true, true);
    Collection<VirtualFile> files = Collections2.transform(includedFiles, psiToVirtualFile());

    return currentFileScope.uniteWith(GlobalSearchScope.filesScope(project, files));
}
 
Example 4
Source Project: consulo   File: SourceScope.java    License: Apache License 2.0 5 votes vote down vote up
private static GlobalSearchScope evaluateScopesAndUnite(final Module[] modules, final ScopeForModuleEvaluator evaluator) {
  GlobalSearchScope scope = evaluator.evaluate(modules[0]);
  for (int i = 1; i < modules.length; i++) {
    final Module module = modules[i];
    final GlobalSearchScope otherscope = evaluator.evaluate(module);
    scope = scope.uniteWith(otherscope);
  }
  return scope;
}