Class Handler<S,​T,​L extends LanguageFrontend>

java.lang.Object
de.fraunhofer.aisec.cpg.frontends.Handler<S,​T,​L>
Type Parameters:
S - the result node or a collection of nodes
T - the raw ast node specific to the parser
L - the language frontend
Direct Known Subclasses:
DeclarationHandler, ExpressionHandler, StatementAnalyzer

public abstract class Handler<S,​T,​L extends LanguageFrontend>
extends java.lang.Object
A Handler is an abstract base class for a class that translates AST nodes from a raw ast type, usually supplied by a language parser into our generic CPG nodes.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected L lang  
    protected static org.slf4j.Logger log  
    protected java.util.HashMap<java.lang.Class<? extends T>,​de.fraunhofer.aisec.cpg.frontends.HandlerInterface<S,​T>> map  
  • Constructor Summary

    Constructors
    Constructor Description
    Handler​(java.util.function.Supplier<S> configConstructor, L lang)  
  • Method Summary

    Modifier and Type Method Description
    S handle​(T ctx)
    Searches for a handler matching the most specific superclass of Handler.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • map

      protected final java.util.HashMap<java.lang.Class<? extends T>,​de.fraunhofer.aisec.cpg.frontends.HandlerInterface<S,​T>> map
    • lang

      @NotNull protected L extends LanguageFrontend lang
  • Constructor Details

    • Handler

      public Handler​(java.util.function.Supplier<S> configConstructor, @NotNull L lang)
  • Method Details

    • handle

      public S handle​(T ctx)
      Searches for a handler matching the most specific superclass of Handler. The created map should thus contain a handler for every semantically different AST node and can reuse handler code as long as the handled AST nodes have a common ancestor.
      Parameters:
      ctx - The AST node, whose handler is matched with respect to the AST node class.
      Returns:
      most specific handler.