Class PostconditionGenerator
java.lang.Object
org.apache.groovy.contracts.generation.BaseGenerator
org.apache.groovy.contracts.generation.PostconditionGenerator
Code generator for postconditions.
-
Field Summary
Fields inherited from class org.apache.groovy.contracts.generation.BaseGenerator
INVARIANT_CLOSURE_PREFIX, META_DATA_USE_INLINE_MODE, source -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOldVariablesMethod(org.codehaus.groovy.ast.ClassNode classNode) Adds a synthetic method to the given classNode which can be used to create a map of most instance variables found in this class.voidgenerateDefaultPostconditionStatement(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.MethodNode method) Adds a default postcondition if a postcondition has already been defined for thisMethodNodein a super-class.voidgeneratePostconditionAssertionStatement(org.codehaus.groovy.ast.MethodNode method, Postcondition postcondition) Injects a postcondition assertion statement in the given method, based on the booleanExpression.Methods inherited from class org.apache.groovy.contracts.generation.BaseGenerator
addCallsToSuperMethodNodeAnnotationClosure, getInlineModeBlockStatement, getInvariantMethodName, getInvariantMethodNode, wrapAssertionBooleanExpression
-
Constructor Details
-
PostconditionGenerator
public PostconditionGenerator(org.codehaus.groovy.control.io.ReaderSource source)
-
-
Method Details
-
addOldVariablesMethod
public void addOldVariablesMethod(org.codehaus.groovy.ast.ClassNode classNode) Adds a synthetic method to the given classNode which can be used to create a map of most instance variables found in this class. Used for the old variable mechanism.- Parameters:
classNode- theClassNodeto add the synthetic method to
-
generatePostconditionAssertionStatement
public void generatePostconditionAssertionStatement(org.codehaus.groovy.ast.MethodNode method, Postcondition postcondition) Injects a postcondition assertion statement in the given method, based on the booleanExpression.- Parameters:
method- theMethodNodefor assertion injectionpostcondition- thePostconditionthe assertion statement should be generated from
-
generateDefaultPostconditionStatement
public void generateDefaultPostconditionStatement(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.MethodNode method) Adds a default postcondition if a postcondition has already been defined for thisMethodNodein a super-class.- Parameters:
type- the currentClassNodeof the given methodNodemethod- theMethodNodeto create the default postcondition for
-