Exemple #1
0
 public static PDOMFile recreateFile(PDOM pdom, final long record) throws CoreException {
   final Database db = pdom.getDB();
   final int linkageID = db.get3ByteUnsignedInt(record + LINKAGE_ID);
   PDOMLinkage linkage = pdom.getLinkage(linkageID);
   if (linkage == null)
     throw new CoreException(createStatus("Invalid linkage ID in database")); // $NON-NLS-1$
   return new PDOMFile(linkage, record);
 }
 public static void updateCache(IPDOMCPPClassType ct, PDOMNode member) throws CoreException {
   if (member instanceof PDOMBinding) {
     final Long key = ct.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
     final PDOM pdom = ct.getPDOM();
     @SuppressWarnings("unchecked")
     Reference<CharArrayObjectMap<List<PDOMBinding>>> cached =
         (Reference<CharArrayObjectMap<List<PDOMBinding>>>) pdom.getCachedResult(key);
     CharArrayObjectMap<List<PDOMBinding>> map = cached == null ? null : cached.get();
     if (map != null) {
       new PopulateMap(map).visit(member);
     }
   }
 }
  public static CharArrayObjectMap<List<PDOMBinding>> getBindingMap(IPDOMCPPClassType ct)
      throws CoreException {
    final Long key = ct.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
    final PDOM pdom = ct.getPDOM();
    @SuppressWarnings("unchecked")
    Reference<CharArrayObjectMap<List<PDOMBinding>>> cached =
        (Reference<CharArrayObjectMap<List<PDOMBinding>>>) pdom.getCachedResult(key);
    CharArrayObjectMap<List<PDOMBinding>> map = cached == null ? null : cached.get();

    if (map == null) {
      // There is no cache, build it:
      map = new CharArrayObjectMap<>(8);
      IPDOMVisitor visitor = new PopulateMap(map);
      visitor.visit(ct);
      ct.acceptUncached(visitor);
      pdom.putCachedResult(key, new SoftReference<>(map));
    }
    return map;
  }
Exemple #4
0
 public static IIndexFragmentFile[] findFiles(
     PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
     throws CoreException {
   String internalRepresentation = strategy.toInternalFormat(location);
   if (internalRepresentation != null) {
     Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1, null);
     btree.accept(finder);
     long[] records = finder.getRecords();
     PDOMFile[] result = new PDOMFile[records.length];
     for (int i = 0; i < result.length; i++) {
       result[i] = recreateFile(pdom, records[i]);
     }
     return result;
   }
   return IIndexFragmentFile.EMPTY_ARRAY;
 }