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 voidaddDeclaration(@NonNull Declaration declaration)Adds the specified declaration to this declaration holder.booleanequals(java.lang.Object o)<T extends Declaration>
@Nullable TgetDeclarationAs(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 emptySetof the declaration of a specified type and clazz.@NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>>getDeclarationsPropertyEdge()@Nullable IncludeDeclarationgetIncludeByName(@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.inthashCode()voidsetStatementEdges(@NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Statement>> statements)java.lang.StringtoString()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, setTypedefsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface de.fraunhofer.aisec.cpg.graph.DeclarationHolder
addIfNotContains, addIfNotContains, addIfNotContainsMethods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable
acceptMethods inherited from interface de.fraunhofer.aisec.cpg.graph.StatementHolder
addStatement, getStatements, getStatementsPropertyEdge, setStatements
-
Constructor Details
-
TranslationUnitDeclaration
public TranslationUnitDeclaration()
-
-
Method Details
-
getDeclarationAs
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 indexclazz- 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 emptySetof the declaration of a specified type and clazz.The set may contain more than one element if a declaration exists in the
TranslationUnitDeclarationitself and in an included header file.- Type Parameters:
T- the type of the declaration- Parameters:
name- the name to search forclazz- the declaration class, such asFunctionDeclaration.- Returns:
- a
Setcontaining the declarations, if any.
-
getIncludeByName
-
getDeclarations
- Specified by:
getDeclarationsin interfaceDeclarationHolder
-
getDeclarationsPropertyEdge
public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>> getDeclarationsPropertyEdge() -
getIncludes
-
getIncludesPropertyEdge
public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<IncludeDeclaration>> getIncludesPropertyEdge() -
getNamespaces
-
getNamespacesPropertyEdge
public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Declaration>> getNamespacesPropertyEdge() -
addDeclaration
Description copied from interface:DeclarationHolderAdds the specified declaration to this declaration holder. Ideally, the declaration holder should use theDeclarationHolder.addIfNotContains(Collection, Declaration)method to consistently add declarations.- Specified by:
addDeclarationin interfaceDeclarationHolder- Parameters:
declaration- the declaration
-
getStatementEdges
public @NonNull java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Statement>> getStatementEdges()Description copied from interface:StatementHolderGetter to be implemented by implementing classes to gain read access to the classes member.- Specified by:
getStatementEdgesin interfaceStatementHolder- 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:
setStatementEdgesin interfaceStatementHolder
-
toString
public java.lang.String toString()- Overrides:
toStringin classde.fraunhofer.aisec.cpg.graph.Node
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classde.fraunhofer.aisec.cpg.graph.Node
-
hashCode
public int hashCode()- Overrides:
hashCodein classde.fraunhofer.aisec.cpg.graph.Node
-