Class ProcessingContextInformation
java.lang.Object
org.apache.groovy.contracts.common.spi.ProcessingContextInformation
-
Constructor Summary
ConstructorsConstructorDescriptionProcessingContextInformation(ClassNode classNode, SourceUnit sourceUnit, ReaderSource source) Creates the processing context for one class and the contract model derived from it. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a syntax error tied to the given AST node while allowing compilation to continue collecting errors.contract()Returns the mutable contract domain model associated with the current class.Returns an auxiliary value previously stored in the per-class processing context.booleanIndicates whether class invariant processing is currently enabled.booleanIndicates whether constructor assertions are currently enabled.booleanIndicates whether postcondition processing is currently enabled.booleanIndicates whether precondition processing is currently enabled.voidStores an auxiliary value in the per-class processing context.Returns the reader source used to look up source fragments during code generation.voidsetConstructorAssertionsEnabled(boolean other) Enables or disables constructor assertion generation for the current class.Returns the source unit currently being transformed.
-
Constructor Details
-
ProcessingContextInformation
public ProcessingContextInformation(ClassNode classNode, SourceUnit sourceUnit, ReaderSource source) Creates the processing context for one class and the contract model derived from it.- Parameters:
classNode- the class currently being transformedsourceUnit- the owning source unitsource- the reader source backing the source unit
-
-
Method Details
-
setConstructorAssertionsEnabled
public void setConstructorAssertionsEnabled(boolean other) Enables or disables constructor assertion generation for the current class.- Parameters:
other-trueto keep constructor assertions enabled
-
isConstructorAssertionsEnabled
public boolean isConstructorAssertionsEnabled()Indicates whether constructor assertions are currently enabled.- Returns:
trueif constructor assertions should be generated
-
isPreconditionsEnabled
public boolean isPreconditionsEnabled()Indicates whether precondition processing is currently enabled.- Returns:
trueif preconditions should be generated
-
isPostconditionsEnabled
public boolean isPostconditionsEnabled()Indicates whether postcondition processing is currently enabled.- Returns:
trueif postconditions should be generated
-
isClassInvariantsEnabled
public boolean isClassInvariantsEnabled()Indicates whether class invariant processing is currently enabled.- Returns:
trueif class invariants should be generated
-
contract
Returns the mutable contract domain model associated with the current class.- Returns:
- the contract model
-
readerSource
Returns the reader source used to look up source fragments during code generation.- Returns:
- the reader source
-
sourceUnit
Returns the source unit currently being transformed.- Returns:
- the source unit
-
put
Stores an auxiliary value in the per-class processing context.- Parameters:
key- the metadata keyvalue- the value to store
-
get
Returns an auxiliary value previously stored in the per-class processing context.- Parameters:
key- the metadata key- Returns:
- the associated value, or
nullif none has been stored
-
addError
Adds a syntax error tied to the given AST node while allowing compilation to continue collecting errors.- Parameters:
msg- the error messageexpr- the AST node providing source coordinates
-