Class TranslationUnitDeclaration

java.lang.Object
de.fraunhofer.aisec.cpg.graph.Node
de.fraunhofer.aisec.cpg.graph.declarations.Declaration
de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration
All Implemented Interfaces:
DeclarationHolder, Persistable, StatementHolder, IVisitable<de.fraunhofer.aisec.cpg.graph.Node>

public class TranslationUnitDeclaration
extends Declaration
implements DeclarationHolder, StatementHolder
The top most declaration, representing a translation unit, for example a file.
  • Nested Class Summary

    Nested classes/interfaces inherited from class de.fraunhofer.aisec.cpg.graph.Node

    de.fraunhofer.aisec.cpg.graph.Node.Companion
  • Field Summary

    Fields inherited from class de.fraunhofer.aisec.cpg.graph.Node

    Companion, EMPTY_NAME, TO_STRING_STYLE
  • Constructor Summary

    Constructors
    Constructor Description
    TranslationUnitDeclaration()  
  • Method Summary

    Modifier and Type Method Description
    void addDeclaration​(@NonNull Declaration declaration)
    Adds the specified declaration to this declaration holder.
    boolean equals​(java.lang.Object o)  
    <T extends Declaration>
    @Nullable T
    getDeclarationAs​(int i, java.lang.Class<T> clazz)
    Returns the i-th declaration as a specific class, if it can be cast
    @NonNull java.util.List<Declaration> getDeclarations()  
    <T extends Declaration>
    @NonNull java.util.Set<T>
    getDeclarationsByName​(@NonNull java.lang.String name, @NonNull java.lang.Class<T> clazz)
    Returns a non-null, possibly empty Set of the declaration of a specified type and clazz.
    @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>> getDeclarationsPropertyEdge()  
    @Nullable IncludeDeclaration getIncludeByName​(@NonNull java.lang.String name)  
    @NonNull java.util.List<IncludeDeclaration> getIncludes()  
    @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<IncludeDeclaration>> getIncludesPropertyEdge()  
    @NonNull java.util.List<Declaration> getNamespaces()  
    @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>> getNamespacesPropertyEdge()  
    @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Statement>> getStatementEdges()
    Getter to be implemented by implementing classes to gain read access to the classes member.
    int hashCode()  
    void setStatementEdges​(@NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Statement>> statements)  
    java.lang.String toString()  

    Methods inherited from class de.fraunhofer.aisec.cpg.graph.Node

    addAnnotations, addNextDFG, addNextEOG, addPrevDFG, addPrevEOG, addTypedef, clearNextEOG, disconnectFromGraph, getAnnotations, getArgumentIndex, getAstChildren, getCode, getComment, getFile, getId, getLocation, getName, getNextDFG, getNextEOG, getNextEOGEdges, getPrevDFG, getPrevEOG, getPrevEOGEdges, getTypedefs, isImplicit, isInferred, removeNextDFG, removePrevDFG, removePrevEOGEntry, setAnnotations, setArgumentIndex, setCode, setComment, setFile, setId, setImplicit, setInferred, setLocation, setName, setNextDFG, setNextEOG, setNextEOGEdges, setPrevDFG, setPrevEOG, setPrevEOGEdges, setTypedefs

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface de.fraunhofer.aisec.cpg.graph.DeclarationHolder

    addIfNotContains, addIfNotContains, addIfNotContains

    Methods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable

    accept

    Methods inherited from interface de.fraunhofer.aisec.cpg.graph.StatementHolder

    addStatement, getStatements, getStatementsPropertyEdge, setStatements
  • Constructor Details

    • TranslationUnitDeclaration

      public TranslationUnitDeclaration()
  • Method Details

    • getDeclarationAs

      public <T extends Declaration> @Nullable T getDeclarationAs​(int i, java.lang.Class<T> clazz)
      Returns the i-th declaration as a specific class, if it can be cast
      Type Parameters:
      T - the type of the class
      Parameters:
      i - the index
      clazz - the class
      Returns:
      the declaration or null, if it the declaration can not be cast to the class
    • getDeclarationsByName

      public <T extends Declaration> @NonNull java.util.Set<T> getDeclarationsByName​(@NonNull java.lang.String name, @NonNull java.lang.Class<T> clazz)
      Returns a non-null, possibly empty Set of the declaration of a specified type and clazz.

      The set may contain more than one element if a declaration exists in the TranslationUnitDeclaration itself and in an included header file.

      Type Parameters:
      T - the type of the declaration
      Parameters:
      name - the name to search for
      clazz - the declaration class, such as FunctionDeclaration.
      Returns:
      a Set containing the declarations, if any.
    • getIncludeByName

      public @Nullable IncludeDeclaration getIncludeByName​(@NonNull java.lang.String name)
    • getDeclarations

      @NotNull public @NonNull java.util.List<Declaration> getDeclarations()
      Specified by:
      getDeclarations in interface DeclarationHolder
    • getDeclarationsPropertyEdge

      public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>> getDeclarationsPropertyEdge()
    • getIncludes

      public @NonNull java.util.List<IncludeDeclaration> getIncludes()
    • getIncludesPropertyEdge

      public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<IncludeDeclaration>> getIncludesPropertyEdge()
    • getNamespaces

      public @NonNull java.util.List<Declaration> getNamespaces()
    • getNamespacesPropertyEdge

      public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>> getNamespacesPropertyEdge()
    • addDeclaration

      public void addDeclaration​(@NonNull Declaration declaration)
      Description copied from interface: DeclarationHolder
      Adds the specified declaration to this declaration holder. Ideally, the declaration holder should use the DeclarationHolder.addIfNotContains(Collection, Declaration) method to consistently add declarations.
      Specified by:
      addDeclaration in interface DeclarationHolder
      Parameters:
      declaration - the declaration
    • getStatementEdges

      public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Statement>> getStatementEdges()
      Description copied from interface: StatementHolder
      Getter to be implemented by implementing classes to gain read access to the classes member.
      Specified by:
      getStatementEdges in interface StatementHolder
      Returns:
      List of property Edge statements
    • setStatementEdges

      public void setStatementEdges​(@NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Statement>> statements)
      Specified by:
      setStatementEdges in interface StatementHolder
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class de.fraunhofer.aisec.cpg.graph.Node
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class de.fraunhofer.aisec.cpg.graph.Node
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class de.fraunhofer.aisec.cpg.graph.Node