Class PurityChecker
java.lang.Object
org.checkerframework.dataflow.util.PurityChecker
A visitor that determines the purity (as defined by
SideEffectFree, Deterministic, and Pure) of a statement or expression. The entry point is method
checkPurity(com.sun.source.util.TreePath, org.checkerframework.javacutil.AnnotationProvider, boolean, boolean, boolean).
This class does not check SideEffectsOnly, which is
the other purity annotation. Verifying @SideEffectsOnly requires parsing the Java
expressions in the annotation and viewpoint-adapting them at each call site, which this module
cannot do. org.checkerframework.common.basetype.DisallowedSideEffects, which
BaseTypeVisitor calls, checks @SideEffectsOnly.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classHelper class to keepPurityChecker's interface clean.static classResult of thePurityChecker. -
Method Summary
Modifier and TypeMethodDescriptionstatic PurityChecker.PurityResultcheckPurity(TreePath statement, AnnotationProvider annoProvider, boolean assumeSideEffectFree, boolean assumeDeterministic, boolean assumePureGetters) Compute whether the given statement is side-effect-free, deterministic, or both.static PurityChecker.PurityResultcheckPurity(List<TreePath> statements, AnnotationProvider annoProvider, boolean assumeSideEffectFree, boolean assumeDeterministic, boolean assumePureGetters) Compute whether the given statements, taken together, are side-effect-free, deterministic, or both.
-
Method Details
-
checkPurity
public static PurityChecker.PurityResult checkPurity(TreePath statement, AnnotationProvider annoProvider, boolean assumeSideEffectFree, boolean assumeDeterministic, boolean assumePureGetters) Compute whether the given statement is side-effect-free, deterministic, or both. Returns a result that can be queried.- Parameters:
statement- the statement to checkannoProvider- the annotation providerassumeSideEffectFree- true if all methods should be assumed to be @SideEffectFreeassumeDeterministic- true if all methods should be assumed to be @DeterministicassumePureGetters- true if all getter methods should be assumed to be @Pure- Returns:
- information about whether the given statement is side-effect-free, deterministic, or both
-
checkPurity
public static PurityChecker.PurityResult checkPurity(List<TreePath> statements, AnnotationProvider annoProvider, boolean assumeSideEffectFree, boolean assumeDeterministic, boolean assumePureGetters) Compute whether the given statements, taken together, are side-effect-free, deterministic, or both. Returns a result that can be queried.Use this rather than calling
checkPurity(TreePath, AnnotationProvider, boolean, boolean, boolean)once per statement, for code that runs as a unit but is not contiguous in the source code: a constructor together with the instance initializers that run as part of it, for example.- Parameters:
statements- the statements to checkannoProvider- the annotation providerassumeSideEffectFree- true if all methods should be assumed to be @SideEffectFreeassumeDeterministic- true if all methods should be assumed to be @DeterministicassumePureGetters- true if all getter methods should be assumed to be @Pure- Returns:
- information about whether the given statements are side-effect-free, deterministic, or both
-