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,IVisitable<Node>
public class TranslationUnitDeclaration extends Declaration implements DeclarationHolder
The top most declaration, representing a translation unit, for example a file.
-
-
Constructor Summary
Constructors Constructor Description TranslationUnitDeclaration()
-
Method Summary
All Methods Instance Methods Concrete Methods 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<PropertyEdge<Declaration>>getDeclarationsPropertyEdge()@Nullable IncludeDeclarationgetIncludeByName(@NonNull java.lang.String name)@NonNull java.util.List<IncludeDeclaration>getIncludes()@NonNull java.util.List<PropertyEdge<IncludeDeclaration>>getIncludesPropertyEdge()@NonNull java.util.List<Declaration>getNamespaces()@NonNull java.util.List<PropertyEdge<Declaration>>getNamespacesPropertyEdge()inthashCode()java.lang.StringtoString()-
Methods inherited from class de.fraunhofer.aisec.cpg.graph.Node
addAnnotations, addNextCFG, addNextCFG, addNextDFG, addNextEOG, addPrevDFG, addPrevEOG, addTypedef, clearNextEOG, disconnectFromGraph, getAnnotations, getArgumentIndex, getCode, getFile, getId, getLocation, getName, getNextCFG, getNextDFG, getNextEOG, getNextEOGProperties, getNextEOGPropertyEdge, getPrevDFG, getPrevEOG, getPrevEOGProperties, getTypedefs, isDummy, isImplicit, removeNextDFG, removePrevDFG, removePrevEOGEntries, removePrevEOGEntry, setArgumentIndex, setCode, setComment, setDummy, setFile, setImplicit, setLocation, setName, setNextDFG, setNextEOG, setPrevDFG, setPrevEOG, setPrevEOGProperties, 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
-
-
-
-
Method Detail
-
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 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
public @Nullable IncludeDeclaration getIncludeByName(@NonNull java.lang.String name)
-
getDeclarations
public @NonNull java.util.List<Declaration> getDeclarations()
-
getDeclarationsPropertyEdge
public @NonNull java.util.List<PropertyEdge<Declaration>> getDeclarationsPropertyEdge()
-
getIncludes
public @NonNull java.util.List<IncludeDeclaration> getIncludes()
-
getIncludesPropertyEdge
public @NonNull java.util.List<PropertyEdge<IncludeDeclaration>> getIncludesPropertyEdge()
-
getNamespaces
public @NonNull java.util.List<Declaration> getNamespaces()
-
getNamespacesPropertyEdge
public @NonNull java.util.List<PropertyEdge<Declaration>> getNamespacesPropertyEdge()
-
addDeclaration
public void addDeclaration(@NonNull Declaration declaration)
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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classDeclaration
-
-