use of de.fraunhofer.aisec.cpg.processing.IVisitor in project cpg by Fraunhofer-AISEC.
the class SubgraphWalker method activateTypes.
public static void activateTypes(Node node) {
AtomicInteger num = new AtomicInteger();
Map<HasType, Set<Type>> typeCache = TypeManager.getInstance().getTypeCache();
node.accept(Strategy::AST_FORWARD, new IVisitor<>() {
@Override
public void visit(Node n) {
if (n instanceof HasType) {
HasType typeNode = (HasType) n;
typeCache.getOrDefault(typeNode, Collections.emptySet()).forEach(t -> {
t = TypeManager.getInstance().resolvePossibleTypedef(t);
((HasType) n).setType(t);
});
typeCache.remove((HasType) n);
num.getAndIncrement();
}
}
});
LOGGER.debug("Activated {} nodes for {}", num, node.getName());
// For some nodes it may happen that they are not reachable via AST, but we still need to set
// their type to the requested value
typeCache.forEach((n, types) -> types.forEach(t -> {
t = TypeManager.getInstance().resolvePossibleTypedef(t);
n.setType(t);
}));
}
Aggregations