Class FunctionDeclaration

java.lang.Object
de.fraunhofer.aisec.cpg.graph.Node
All Implemented Interfaces:
DeclarationHolder, HasType, Persistable, IVisitable<de.fraunhofer.aisec.cpg.graph.Node>
Direct Known Subclasses:
MethodDeclaration

public class FunctionDeclaration
extends ValueDeclaration
implements DeclarationHolder
Represents the declaration or definition of a function.
  • Field Details

    • body

      protected Statement body
      The function body. Usually a CompoundStatement.
    • records

      protected java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<RecordDeclaration>> records
      Classes and Structs can be declared inside a function and are only valid within the function.
    • parameters

      protected java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<ParamVariableDeclaration>> parameters
      The list of function parameters.
    • throwsTypes

      protected java.util.List<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<Type>> throwsTypes
  • Constructor Details

    • FunctionDeclaration

      public FunctionDeclaration()
  • Method Details

    • hasBody

      public boolean hasBody()
    • getSignature

      public java.lang.String getSignature()
    • hasSameSignature

      public boolean hasSameSignature​(FunctionDeclaration targetFunctionDeclaration)
    • 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<de.fraunhofer.aisec.cpg.graph.edge.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<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<FunctionDeclaration>> getOverridesPropertyEdge()
    • addOverrides

      public void addOverrides​(FunctionDeclaration functionDeclaration)
    • getThrowsTypes

      public java.util.List<Type> getThrowsTypes()
    • getThrowsTypesPropertyEdge

      public java.util.List<de.fraunhofer.aisec.cpg.graph.edge.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()
    • getDefaultParameters

      public java.util.List<Expression> getDefaultParameters()
    • getDefaultParameterSignature

      public java.util.List<Type> getDefaultParameterSignature()
    • getSignatureTypes

      public java.util.List<Type> getSignatureTypes()
    • getParametersPropertyEdge

      public java.util.List<de.fraunhofer.aisec.cpg.graph.edge.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

      @NotNull public java.lang.String toString()
      Overrides:
      toString in class ValueDeclaration
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class ValueDeclaration
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ValueDeclaration
    • 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<de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<RecordDeclaration>> getRecordsPropertyEdge()
    • setRecords

      public void setRecords​(java.util.List<RecordDeclaration> records)
    • addDeclaration

      public void addDeclaration​(@NonNull Declaration declaration)
      Description copied from interface: DeclarationHolder
      Adds the specified declaration to this declaration holder. Ideally, the declaration holder should use the DeclarationHolder.addIfNotContains(Collection, Declaration) method to consistently add declarations.
      Specified by:
      addDeclaration in interface DeclarationHolder
      Parameters:
      declaration - the declaration
    • getDeclarations

      @NotNull public java.util.List<Declaration> getDeclarations()
      Specified by:
      getDeclarations in interface DeclarationHolder