Exemplo n.º 1
0
 /** Visit bindings via the cache. */
 public static void acceptViaCache(
     IPDOMCPPClassType ct, IPDOMVisitor visitor, boolean includeNestedInAnonymous)
     throws CoreException {
   final long record = ct.getRecord();
   CharArrayObjectMap<List<PDOMBinding>> map = getBindingMap(ct);
   for (List<PDOMBinding> list : map.values()) {
     for (PDOMBinding node : list) {
       if (includeNestedInAnonymous || node.getParentNodeRec() == record) {
         if (visitor.visit(node)) {
           node.accept(visitor);
         }
         visitor.leave(node);
       }
     }
   }
 }
Exemplo n.º 2
0
  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;
  }