Package de.fraunhofer.aisec.cpg.graph
Class Node
- java.lang.Object
-
- de.fraunhofer.aisec.cpg.graph.Node
-
- All Implemented Interfaces:
Persistable,IVisitable<Node>
- Direct Known Subclasses:
Annotation,AnnotationMember,Declaration,Statement,TranslationResult,Type
public class Node extends java.lang.Object implements IVisitable<Node>, Persistable
The base class for all graph objects that are going to be persisted in the database.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Annotation>annotationsList of annotations associated with that node.protected @Nullable java.lang.StringcodeOriginal code snippet of this node.protected @Nullable java.lang.StringcommentOptional comment of this node.protected booleandummyIf a node is marked as being a dummy, it means that it was created artificially and does not necessarily have a real counterpart in the actual source codestatic java.lang.StringEMPTY_NAMEprotected @Nullable java.lang.StringfileName of the containing file.protected booleanimplicitSpecifies, whether this node is implicit, i.e.protected @Nullable PhysicalLocationlocationLocation of the finding in source code.protected static org.slf4j.Loggerlogprotected @NonNull java.lang.StringnameA human readable name.protected @NonNull java.util.List<PropertyEdge<Node>>nextCFGDeprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGprotected @NonNull java.util.Set<Node>nextDFGprotected @NonNull java.util.List<PropertyEdge<Node>>nextEOGoutgoing control flow edges.protected @NonNull java.util.Set<Node>prevDFGprotected @NonNull java.util.List<PropertyEdge<Node>>prevEOGIncoming control flow edges.static org.apache.commons.lang3.builder.ToStringStyleTO_STRING_STYLEprotected @NonNull java.util.Set<TypedefDeclaration>typedefs
-
Constructor Summary
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAnnotations(@NonNull java.util.Collection<Annotation> annotations)voidaddNextCFG(Node node)Deprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGvoidaddNextCFG(java.util.Collection<? extends Node> collection)Deprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGvoidaddNextDFG(Node next)voidaddNextEOG(@NonNull PropertyEdge<Node> propertyEdge)voidaddPrevDFG(Node prev)voidaddPrevEOG(@NonNull PropertyEdge<Node> propertyEdge)voidaddTypedef(TypedefDeclaration typedef)voidclearNextEOG()voiddisconnectFromGraph()If a node should be removed from the graph, just removing it from the AST is not enough (see issue #60).booleanequals(java.lang.Object o)@NonNull java.util.List<Annotation>getAnnotations()intgetArgumentIndex()@Nullable java.lang.StringgetCode()@Nullable java.lang.StringgetFile()java.lang.LonggetId()@Nullable PhysicalLocationgetLocation()@NonNull java.lang.StringgetName()@NonNull java.util.List<Node>getNextCFG()Deprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGn@NonNull java.util.Set<Node>getNextDFG()@NonNull java.util.List<Node>getNextEOG()@NonNull java.util.List<PropertyEdge<Node>>getNextEOGProperties()@NonNull java.util.List<PropertyEdge<Node>>getNextEOGPropertyEdge()@NonNull java.util.Set<Node>getPrevDFG()@NonNull java.util.List<Node>getPrevEOG()@NonNull java.util.List<PropertyEdge<Node>>getPrevEOGProperties()@NonNull java.util.Set<TypedefDeclaration>getTypedefs()inthashCode()booleanisDummy()Deprecated, for removal: This API element is subject to removal in a future version.You should rather useisImplicit()booleanisImplicit()voidremoveNextDFG(Node next)voidremovePrevDFG(Node prev)voidremovePrevEOGEntries(@NonNull java.util.List<Node> prevEOGs)voidremovePrevEOGEntry(@NonNull Node eog)voidsetArgumentIndex(int argumentIndex)voidsetCode(@Nullable java.lang.String code)voidsetComment(@NonNull java.lang.String comment)voidsetDummy(boolean dummy)Deprecated, for removal: This API element is subject to removal in a future version.You should rather usesetImplicit(boolean), if it is an implicit expressionvoidsetFile(@Nullable java.lang.String file)voidsetImplicit(boolean implicit)voidsetLocation(@Nullable PhysicalLocation location)voidsetName(@NonNull java.lang.String name)voidsetNextDFG(@NonNull java.util.Set<Node> nextDFG)voidsetNextEOG(@NonNull java.util.List<Node> nextEOG)voidsetPrevDFG(@NonNull java.util.Set<Node> prevDFG)voidsetPrevEOG(@NonNull java.util.List<Node> prevEOG)voidsetPrevEOGProperties(@NonNull java.util.List<PropertyEdge<Node>> prevEOG)voidsetTypedefs(@NonNull java.util.Set<TypedefDeclaration> typedefs)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable
accept
-
-
-
-
Field Detail
-
TO_STRING_STYLE
public static final org.apache.commons.lang3.builder.ToStringStyle TO_STRING_STYLE
-
log
protected static final org.slf4j.Logger log
-
EMPTY_NAME
public static final java.lang.String EMPTY_NAME
- See Also:
- Constant Field Values
-
name
protected @NonNull java.lang.String name
A human readable name.
-
code
protected @Nullable java.lang.String code
Original code snippet of this node. Most nodes will have a corresponding "code", but in cases where nodes are created artificially, it may be null.
-
comment
protected @Nullable java.lang.String comment
Optional comment of this node.
-
location
protected @Nullable PhysicalLocation location
Location of the finding in source code.
-
file
protected @Nullable java.lang.String file
Name of the containing file. It can be null for artificially created nodes or if just analyzing snippets of code without an associated file name.
-
prevEOG
protected @NonNull java.util.List<PropertyEdge<Node>> prevEOG
Incoming control flow edges.
-
nextEOG
protected @NonNull java.util.List<PropertyEdge<Node>> nextEOG
outgoing control flow edges.
-
nextCFG
@Deprecated(since="3.4", forRemoval=true) protected @NonNull java.util.List<PropertyEdge<Node>> nextCFGDeprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGoutgoing control flow edges.
-
prevDFG
protected @NonNull java.util.Set<Node> prevDFG
-
nextDFG
protected @NonNull java.util.Set<Node> nextDFG
-
typedefs
protected @NonNull java.util.Set<TypedefDeclaration> typedefs
-
dummy
protected boolean dummy
If a node is marked as being a dummy, it means that it was created artificially and does not necessarily have a real counterpart in the actual source code
-
implicit
protected boolean implicit
Specifies, whether this node is implicit, i.e. is not really existing in source code but only exists implicitly. This mostly relates to implicit casts, return statements or implicit this expressions.
-
annotations
protected java.util.List<Annotation> annotations
List of annotations associated with that node.
-
-
Method Detail
-
getId
public java.lang.Long getId()
-
getName
public @NonNull java.lang.String getName()
-
setName
public void setName(@NonNull java.lang.String name)
-
getFile
public @Nullable java.lang.String getFile()
-
setFile
public void setFile(@Nullable java.lang.String file)
-
getCode
public @Nullable java.lang.String getCode()
-
setCode
public void setCode(@Nullable java.lang.String code)
-
getLocation
public @Nullable PhysicalLocation getLocation()
-
setLocation
public void setLocation(@Nullable PhysicalLocation location)
-
getPrevEOGProperties
public @NonNull java.util.List<PropertyEdge<Node>> getPrevEOGProperties()
-
getNextEOGProperties
public @NonNull java.util.List<PropertyEdge<Node>> getNextEOGProperties()
-
setPrevEOGProperties
public void setPrevEOGProperties(@NonNull java.util.List<PropertyEdge<Node>> prevEOG)
-
removePrevEOGEntry
public void removePrevEOGEntry(@NonNull Node eog)
-
removePrevEOGEntries
public void removePrevEOGEntries(@NonNull java.util.List<Node> prevEOGs)
-
getPrevEOG
public @NonNull java.util.List<Node> getPrevEOG()
-
setPrevEOG
public void setPrevEOG(@NonNull java.util.List<Node> prevEOG)
-
addPrevEOG
public void addPrevEOG(@NonNull PropertyEdge<Node> propertyEdge)
-
getNextEOGPropertyEdge
public @NonNull java.util.List<PropertyEdge<Node>> getNextEOGPropertyEdge()
-
getNextEOG
public @NonNull java.util.List<Node> getNextEOG()
-
setNextEOG
public void setNextEOG(@NonNull java.util.List<Node> nextEOG)
-
addNextEOG
public void addNextEOG(@NonNull PropertyEdge<Node> propertyEdge)
-
clearNextEOG
public void clearNextEOG()
-
getNextCFG
@Deprecated(since="3.4", forRemoval=true) public @NonNull java.util.List<Node> getNextCFG()Deprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGn
-
addNextCFG
@Deprecated(since="3.4", forRemoval=true) public void addNextCFG(Node node)Deprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOG
-
addNextCFG
@Deprecated(since="3.4", forRemoval=true) public void addNextCFG(java.util.Collection<? extends Node> collection)Deprecated, for removal: This API element is subject to removal in a future version.This Edge-Type is deprecated as it is less precise then thenextEOGoutgoing control flow edges.
-
getNextDFG
public @NonNull java.util.Set<Node> getNextDFG()
-
setNextDFG
public void setNextDFG(@NonNull java.util.Set<Node> nextDFG)
-
addNextDFG
public void addNextDFG(Node next)
-
removeNextDFG
public void removeNextDFG(Node next)
-
getPrevDFG
public @NonNull java.util.Set<Node> getPrevDFG()
-
setPrevDFG
public void setPrevDFG(@NonNull java.util.Set<Node> prevDFG)
-
addPrevDFG
public void addPrevDFG(Node prev)
-
removePrevDFG
public void removePrevDFG(Node prev)
-
addTypedef
public void addTypedef(TypedefDeclaration typedef)
-
getTypedefs
public @NonNull java.util.Set<TypedefDeclaration> getTypedefs()
-
setTypedefs
public void setTypedefs(@NonNull java.util.Set<TypedefDeclaration> typedefs)
-
getArgumentIndex
public int getArgumentIndex()
-
setArgumentIndex
public void setArgumentIndex(int argumentIndex)
-
isDummy
@Deprecated(forRemoval=true) public boolean isDummy()
Deprecated, for removal: This API element is subject to removal in a future version.You should rather useisImplicit()
-
setDummy
@Deprecated(forRemoval=true) public void setDummy(boolean dummy)
Deprecated, for removal: This API element is subject to removal in a future version.You should rather usesetImplicit(boolean), if it is an implicit expression
-
setImplicit
public void setImplicit(boolean implicit)
-
isImplicit
public boolean isImplicit()
-
getAnnotations
public @NonNull java.util.List<Annotation> getAnnotations()
-
addAnnotations
public void addAnnotations(@NonNull java.util.Collection<Annotation> annotations)
-
disconnectFromGraph
public void disconnectFromGraph()
If a node should be removed from the graph, just removing it from the AST is not enough (see issue #60). It will most probably be referenced somewhere via DFG or EOG edges. Thus, if it needs to be disconnected completely, we will have to take care of correctly disconnecting these implicit edges.ATTENTION! Please note that this might kill an entire subgraph, if the node to disconnect has further children that have no alternative connection paths to the rest of the graph.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setComment
public void setComment(@NonNull java.lang.String comment)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-