Example #1
0
 public long getCacheMisses() {
   long result = 0;
   for (IIndexFragment fragment : fFragments) {
     result += fragment.getCacheMisses();
   }
   return result;
 }
Example #2
0
 public long getLastWriteAccess() {
   long result = 0;
   for (IIndexFragment fragment : fFragments) {
     result = Math.max(result, fragment.getLastWriteAccess());
   }
   return result;
 }
Example #3
0
 public synchronized void releaseReadLock() {
   if (--fReadLock == 0) {
     for (IIndexFragment fragment : fFragments) {
       fragment.releaseReadLock();
     }
   }
 }
Example #4
0
 public boolean hasWaitingReaders() {
   for (IIndexFragment fragment : fFragments) {
     if (fragment.hasWaitingReaders()) {
       return true;
     }
   }
   return false;
 }
Example #5
0
 public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
   List<IIndexFragmentBinding> result = new ArrayList<IIndexFragmentBinding>();
   for (IIndexFragment fragment : fFragments) {
     IIndexFragmentBinding adapted = fragment.adaptBinding(binding);
     if (adapted != null) {
       result.add(adapted);
     }
   }
   return result.toArray(new IIndexFragmentBinding[result.size()]);
 }
Example #6
0
 public IIndexFile[] getAllFiles() throws CoreException {
   HashMap<IIndexFileLocation, IIndexFile> result = new HashMap<IIndexFileLocation, IIndexFile>();
   for (IIndexFragment fragment : fFragments) {
     for (IIndexFragmentFile file : fragment.getAllFiles()) {
       if (file.hasContent()) {
         result.put(file.getLocation(), file);
       }
     }
   }
   return result.values().toArray(new IIndexFile[result.size()]);
 }
Example #7
0
 protected void clearResultCache() {
   for (IIndexFragment frag : fFragments) {
     frag.clearResultCache();
   }
 }
Example #8
0
 public void resetCacheCounters() {
   for (IIndexFragment fragment : fFragments) {
     fragment.resetCacheCounters();
   }
 }
Example #9
0
  public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
    LinkedList<IIndexFragmentName> result = new LinkedList<IIndexFragmentName>();
    if (binding instanceof ICPPUsingDeclaration) {
      IBinding[] bindings = ((ICPPUsingDeclaration) binding).getDelegates();
      if (bindings == null || bindings.length == 0) {
        return new IIndexName[0];
      }
      if (bindings.length > 1) {
        ArrayList<IIndexName> multi = new ArrayList<IIndexName>();
        for (IBinding b : bindings) {
          multi.addAll(Arrays.asList(findNames(b, flags)));
        }
        return multi.toArray(new IIndexName[multi.size()]);
      }
      binding = bindings[0];
    }

    // Maps a file location to -1 if the file belongs to an earlier index fragment,
    // or to the index of the last checked index fragment plus one, if the file doesn't belong
    // to any of the index fragments up to the last checked one.
    HashMap<IIndexFileLocation, Integer> fileCheckCache =
        new HashMap<IIndexFileLocation, Integer>();
    for (int i = 0; i < fPrimaryFragmentCount; i++) {
      IIndexFragment fragment = fFragments[i];
      final IIndexFragmentName[] names = fragment.findNames(binding, flags);
      for (IIndexFragmentName name : names) {
        IIndexFileLocation location = name.getFile().getLocation();
        Integer checkState = fileCheckCache.get(location);
        int checkOffset = checkState == null ? 0 : checkState.intValue();
        if (checkOffset >= 0) {
          for (; checkOffset < i; checkOffset++) {
            IIndexFragment fragment2 = fFragments[checkOffset];
            if (fragment2.getFiles(location).length != 0) {
              checkOffset = -1;
              break;
            }
          }
          fileCheckCache.put(location, Integer.valueOf(checkOffset));
        }
        if (checkOffset == i) {
          result.add(name);
        }
      }
    }
    //		// bug 192352, files can reside in multiple fragments, remove duplicates
    //		if (fragCount > 1 || (flags & IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES) != 0) {
    //			HashMap<String, IIndexFile> fileMap= new HashMap<String, IIndexFile>();
    //			for (Iterator<IIndexFragmentName> iterator = result.iterator(); iterator.hasNext();) {
    //				final IIndexFragmentName name = iterator.next();
    //				final IIndexFile file= name.getFile();
    //				final String fileKey= name.getFile().getLocation().getURI().toString();
    //				final IIndexFile otherFile= fileMap.get(fileKey);
    //				if (otherFile == null) {
    //					fileMap.put(fileKey, file);
    //				} else if (!otherFile.equals(file)) { // same file in another fragment
    //					iterator.remove();
    //				}
    //			}
    //		}
    return result.toArray(new IIndexName[result.size()]);
  }