コード例 #1
0
 @NotNull
 public SearchScope intersectWith(@NotNull LocalSearchScope localScope2) {
   PsiElement[] elements2 = localScope2.getScope();
   List<PsiElement> result = new ArrayList<PsiElement>(elements2.length);
   for (final PsiElement element2 : elements2) {
     if (PsiSearchScopeUtil.isInScope(this, element2)) {
       result.add(element2);
     }
   }
   return result.isEmpty()
       ? EMPTY_SCOPE
       : new LocalSearchScope(
           result.toArray(new PsiElement[result.size()]), null, localScope2.isIgnoreInjectedPsi());
 }
コード例 #2
0
 public SearchScope union(LocalSearchScope scope2) {
   if (equals(scope2)) return this;
   PsiElement[] elements1 = getScope();
   PsiElement[] elements2 = scope2.getScope();
   boolean[] united = new boolean[elements2.length];
   List<PsiElement> result = new ArrayList<PsiElement>();
   loop1:
   for (final PsiElement element1 : elements1) {
     for (int j = 0; j < elements2.length; j++) {
       final PsiElement element2 = elements2[j];
       final PsiElement unionElement = scopeElementsUnion(element1, element2);
       if (unionElement != null && unionElement.getContainingFile() != null) {
         result.add(unionElement);
         united[j] = true;
         break loop1;
       }
     }
     result.add(element1);
   }
   for (int i = 0; i < united.length; i++) {
     final boolean b = united[i];
     if (!b) {
       result.add(elements2[i]);
     }
   }
   return new LocalSearchScope(PsiUtilCore.toPsiElementArray(result));
 }
コード例 #3
0
 @NotNull
 private static Set<VirtualFile> getLocalScopeFiles(@NotNull LocalSearchScope scope) {
   Set<VirtualFile> files = new LinkedHashSet<VirtualFile>();
   for (PsiElement element : scope.getScope()) {
     PsiFile file = element.getContainingFile();
     if (file != null) {
       ContainerUtil.addIfNotNull(files, file.getVirtualFile());
     }
   }
   return files;
 }
コード例 #4
0
  @NotNull
  public GlobalSearchScope union(@NotNull final LocalSearchScope scope) {
    PsiElement[] localScopeElements = scope.getScope();
    if (localScopeElements.length == 0) {
      return this;
    }
    return new GlobalSearchScope(localScopeElements[0].getProject()) {
      @Override
      public boolean contains(@NotNull VirtualFile file) {
        return GlobalSearchScope.this.contains(file) || scope.isInScope(file);
      }

      @Override
      public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
        return GlobalSearchScope.this.contains(file1) && GlobalSearchScope.this.contains(file2)
            ? GlobalSearchScope.this.compare(file1, file2)
            : 0;
      }

      @Override
      public boolean isSearchInModuleContent(@NotNull Module aModule) {
        return GlobalSearchScope.this.isSearchInModuleContent(aModule);
      }

      @Override
      public boolean isSearchOutsideRootModel() {
        return GlobalSearchScope.this.isSearchOutsideRootModel();
      }

      @Override
      public boolean isSearchInLibraries() {
        return GlobalSearchScope.this.isSearchInLibraries();
      }

      @NonNls
      @Override
      public String toString() {
        return "UnionToLocal: (" + GlobalSearchScope.this + ", " + scope + ")";
      }
    };
  }