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,StatementHolder,IVisitable<de.fraunhofer.aisec.cpg.graph.Node>
public class NamespaceDeclaration extends Declaration implements DeclarationHolder, StatementHolder
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 contain
FunctionDeclaration, FieldDeclaration and RecordDeclaration similar to a RecordDeclaration and the
semantic difference between NamespaceDeclaration and RecordDeclaration lies in the
non-instantiabillity of a namespace.
The name property of this node need to be a FQN for propery resolution.
-
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 NamespaceDeclaration() -
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> 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()@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)Methods inherited from class de.fraunhofer.aisec.cpg.graph.Node
addAnnotations, addNextDFG, addNextEOG, addPrevDFG, addPrevEOG, addTypedef, clearNextEOG, disconnectFromGraph, getAnnotations, getArgumentIndex, 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, toStringMethods 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
-
NamespaceDeclaration
public NamespaceDeclaration()
-
-
Method Details
-
getFields
-
getFunctions
-
getRecords
-
getNamespaces
-
getDeclarations
- Specified by:
getDeclarationsin interfaceDeclarationHolder
-
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) -
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
-
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
-
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
-