Class NamespaceDeclaration
- java.lang.Object
-
- de.fraunhofer.aisec.cpg.graph.Node
-
- de.fraunhofer.aisec.cpg.graph.declarations.Declaration
-
- de.fraunhofer.aisec.cpg.graph.declarations.NamespaceDeclaration
-
- All Implemented Interfaces:
DeclarationHolder,Persistable,IVisitable<Node>
public class NamespaceDeclaration extends Declaration implements DeclarationHolder
Declares the scope of a namespace and appends its own name to the current namespace-prefix to form a new namespace prefix. While RecordDeclarations in C++ and Java have their own namespace, namespace declarations can be declared multiple times. At the beginning of a Java-file, a namespace declaration is used to represent the package name as namespace. In its explicit appearance a namespace declaration can containFunctionDeclaration,FieldDeclarationandRecordDeclarationsimilar to aRecordDeclarationand the semantical difference between NamespaceDeclaration andRecordDeclarationlies in the non-instantiabillity of a namespace.
-
-
Constructor Summary
Constructors Constructor Description NamespaceDeclaration()
-
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> TgetDeclarationAs(int i, java.lang.Class<T> clazz)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.java.util.List<FieldDeclaration>getFields()java.util.List<FunctionDeclaration>getFunctions()java.util.List<NamespaceDeclaration>getNamespaces()java.util.List<RecordDeclaration>getRecords()inthashCode()-
Methods inherited from class de.fraunhofer.aisec.cpg.graph.declarations.Declaration
toString
-
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
-
getFields
public java.util.List<FieldDeclaration> getFields()
-
getFunctions
public java.util.List<FunctionDeclaration> getFunctions()
-
getRecords
public java.util.List<RecordDeclaration> getRecords()
-
getNamespaces
public java.util.List<NamespaceDeclaration> getNamespaces()
-
getDeclarations
public java.util.List<Declaration> getDeclarations()
-
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.- 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.
-
getDeclarationAs
public <T> T getDeclarationAs(int i, java.lang.Class<T> clazz)
-
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
-
-