Class FunctionDeclaration
- java.lang.Object
-
- de.fraunhofer.aisec.cpg.graph.Node
-
- de.fraunhofer.aisec.cpg.graph.declarations.Declaration
-
- de.fraunhofer.aisec.cpg.graph.declarations.ValueDeclaration
-
- de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration
-
- All Implemented Interfaces:
DeclarationHolder,HasType,Persistable,IVisitable<Node>
- Direct Known Subclasses:
MethodDeclaration
public class FunctionDeclaration extends ValueDeclaration implements DeclarationHolder
Represents the declaration or definition of a function.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.fraunhofer.aisec.cpg.graph.HasType
HasType.TypeListener
-
-
Field Summary
Fields Modifier and Type Field Description protected StatementbodyThe function body.protected java.util.List<PropertyEdge<ParamVariableDeclaration>>parametersThe list of function parameters.protected java.util.List<PropertyEdge<RecordDeclaration>>recordsClasses and Structs can be declared inside a function and are only valid within the function.protected java.util.List<PropertyEdge<Type>>throwsTypes-
Fields inherited from class de.fraunhofer.aisec.cpg.graph.declarations.ValueDeclaration
possibleSubTypes, type
-
-
Constructor Summary
Constructors Constructor Description FunctionDeclaration()
-
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.voidaddOverriddenBy(FunctionDeclaration functionDeclaration)voidaddOverriddenBy(java.util.Collection<? extends FunctionDeclaration> c)voidaddOverrides(FunctionDeclaration functionDeclaration)voidaddParameter(ParamVariableDeclaration paramVariableDeclaration)voidaddThrowTypes(Type type)voidaddThrowTypes(java.util.Collection<Type> collection)booleanequals(java.lang.Object o)StatementgetBody()<T> @Nullable TgetBodyStatementAs(int i, java.lang.Class<T> clazz)FunctionDeclarationgetDefinition()java.util.List<FunctionDeclaration>getOverriddenBy()java.util.List<PropertyEdge<FunctionDeclaration>>getOverriddenByPropertyEdge()java.util.List<FunctionDeclaration>getOverrides()java.util.List<PropertyEdge<FunctionDeclaration>>getOverridesPropertyEdge()java.util.List<ParamVariableDeclaration>getParameters()java.util.List<PropertyEdge<ParamVariableDeclaration>>getParametersPropertyEdge()java.util.List<RecordDeclaration>getRecords()java.util.List<PropertyEdge<RecordDeclaration>>getRecordsPropertyEdge()java.lang.StringgetSignature()java.util.List<Type>getSignatureTypes()java.util.List<Type>getThrowsTypes()java.util.List<PropertyEdge<Type>>getThrowsTypesPropertyEdge()java.util.Optional<VariableDeclaration>getVariableDeclarationByName(java.lang.String name)Looks for a variable declaration by the given name.booleanhasBody()inthashCode()booleanhasSignature(java.util.List<Type> targetSignature)booleanisDefinition()booleanisOverrideCandidate(FunctionDeclaration other)voidremoveParameter(ParamVariableDeclaration paramVariableDeclaration)voidsetBody(Statement body)voidsetDefinition(FunctionDeclaration definition)voidsetIsDefinition(boolean definition)voidsetParameters(java.util.List<ParamVariableDeclaration> parameters)voidsetRecords(java.util.List<RecordDeclaration> records)voidsetThrowsTypes(java.util.List<Type> throwsTypes)java.lang.StringtoString()-
Methods inherited from class de.fraunhofer.aisec.cpg.graph.declarations.ValueDeclaration
getPossibleSubTypes, getPropagationType, getType, getTypeListeners, refreshType, registerTypeListener, resetTypes, setPossibleSubTypes, setType, unregisterTypeListener, updatePossibleSubtypes, updateType
-
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.graph.HasType
setPossibleSubTypes, setType
-
Methods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable
accept
-
-
-
-
Field Detail
-
body
protected Statement body
The function body. Usually aCompoundStatement.
-
records
protected java.util.List<PropertyEdge<RecordDeclaration>> records
Classes and Structs can be declared inside a function and are only valid within the function.
-
parameters
protected java.util.List<PropertyEdge<ParamVariableDeclaration>> parameters
The list of function parameters.
-
throwsTypes
protected java.util.List<PropertyEdge<Type>> throwsTypes
-
-
Method Detail
-
hasBody
public boolean hasBody()
-
getSignature
public java.lang.String getSignature()
-
hasSignature
public boolean hasSignature(java.util.List<Type> targetSignature)
-
isOverrideCandidate
public boolean isOverrideCandidate(FunctionDeclaration other)
-
getOverriddenBy
public java.util.List<FunctionDeclaration> getOverriddenBy()
-
getOverriddenByPropertyEdge
public java.util.List<PropertyEdge<FunctionDeclaration>> getOverriddenByPropertyEdge()
-
addOverriddenBy
public void addOverriddenBy(java.util.Collection<? extends FunctionDeclaration> c)
-
addOverriddenBy
public void addOverriddenBy(FunctionDeclaration functionDeclaration)
-
getOverrides
public java.util.List<FunctionDeclaration> getOverrides()
-
getOverridesPropertyEdge
public java.util.List<PropertyEdge<FunctionDeclaration>> getOverridesPropertyEdge()
-
addOverrides
public void addOverrides(FunctionDeclaration functionDeclaration)
-
getThrowsTypes
public java.util.List<Type> getThrowsTypes()
-
getThrowsTypesPropertyEdge
public java.util.List<PropertyEdge<Type>> getThrowsTypesPropertyEdge()
-
setThrowsTypes
public void setThrowsTypes(java.util.List<Type> throwsTypes)
-
addThrowTypes
public void addThrowTypes(Type type)
-
addThrowTypes
public void addThrowTypes(java.util.Collection<Type> collection)
-
getBody
public Statement getBody()
-
getBodyStatementAs
public <T> @Nullable T getBodyStatementAs(int i, java.lang.Class<T> clazz)
-
setBody
public void setBody(Statement body)
-
getParameters
public java.util.List<ParamVariableDeclaration> getParameters()
-
getSignatureTypes
public java.util.List<Type> getSignatureTypes()
-
getParametersPropertyEdge
public java.util.List<PropertyEdge<ParamVariableDeclaration>> getParametersPropertyEdge()
-
addParameter
public void addParameter(ParamVariableDeclaration paramVariableDeclaration)
-
removeParameter
public void removeParameter(ParamVariableDeclaration paramVariableDeclaration)
-
setParameters
public void setParameters(java.util.List<ParamVariableDeclaration> parameters)
-
getVariableDeclarationByName
public java.util.Optional<VariableDeclaration> getVariableDeclarationByName(java.lang.String name)
Looks for a variable declaration by the given name.- Parameters:
name- the name of the variable- Returns:
- an optional value containing the variable declaration if found
-
toString
public java.lang.String toString()
- Overrides:
toStringin classValueDeclaration
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classValueDeclaration
-
hashCode
public int hashCode()
- Overrides:
hashCodein classValueDeclaration
-
getDefinition
public FunctionDeclaration getDefinition()
-
isDefinition
public boolean isDefinition()
-
setIsDefinition
public void setIsDefinition(boolean definition)
-
setDefinition
public void setDefinition(FunctionDeclaration definition)
-
getRecords
public java.util.List<RecordDeclaration> getRecords()
-
getRecordsPropertyEdge
public java.util.List<PropertyEdge<RecordDeclaration>> getRecordsPropertyEdge()
-
setRecords
public void setRecords(java.util.List<RecordDeclaration> records)
-
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
-
-