Class PurityUtils
java.lang.Object
org.checkerframework.dataflow.util.PurityUtils
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic EnumSet<PurityKind> getPurityKinds(AnnotationProvider provider, MethodTree methodTree) Returns the purity annotations on the methodmethodTree.static EnumSet<PurityKind> getPurityKinds(AnnotationProvider provider, ExecutableElement methodElement) Returns the purity annotations on the methodmethodElement.static booleanhasPurityAnnotation(AnnotationProvider provider, MethodTree methodTree) Does the methodmethodTreehave any purity annotation?static booleanhasPurityAnnotation(AnnotationProvider provider, ExecutableElement methodElement) Does the methodmethodElementhave any purity annotation?static booleanisDeterministic(AnnotationProvider provider, MethodTree methodTree) Is the methodmethodTreedeterministic?static booleanisDeterministic(AnnotationProvider provider, ExecutableElement methodElement) Is the methodmethodElementdeterministic?static booleanisPure(AnnotationProvider provider, JavaExpression expression) Returns true if the given expression is pure: evaluating it has no side effect, and, in an unchanged environment, every evaluation yields the same location or value.static booleanisSideEffectFree(AnnotationProvider provider, ExecutableElement methodElement) Is the methodmethodElementside-effect-free?
-
Method Details
-
hasPurityAnnotation
Does the methodmethodTreehave any purity annotation?- Parameters:
provider- how to get annotationsmethodTree- a method to test- Returns:
- true if the method has any purity annotations
-
hasPurityAnnotation
public static boolean hasPurityAnnotation(AnnotationProvider provider, ExecutableElement methodElement) Does the methodmethodElementhave any purity annotation?- Parameters:
provider- how to get annotationsmethodElement- a method to test- Returns:
- true if the method has any purity annotations
-
isDeterministic
Is the methodmethodTreedeterministic?- Parameters:
provider- how to get annotationsmethodTree- a method to test- Returns:
- true if the method is deterministic
-
isDeterministic
Is the methodmethodElementdeterministic?- Parameters:
provider- how to get annotationsmethodElement- a method to test- Returns:
- true if the method is deterministic
-
isSideEffectFree
public static boolean isSideEffectFree(AnnotationProvider provider, ExecutableElement methodElement) Is the methodmethodElementside-effect-free?This method does not use, and has different semantics than,
AnnotationProvider.isSideEffectFree(javax.lang.model.element.ExecutableElement). This method is concerned only with standard purity annotations.- Parameters:
provider- how to get annotationsmethodElement- a method to test- Returns:
- true if the method is side-effect-free
-
getPurityKinds
public static EnumSet<PurityKind> getPurityKinds(AnnotationProvider provider, MethodTree methodTree) Returns the purity annotations on the methodmethodTree.- Parameters:
provider- how to get annotations. ItsAnnotationProvider.isSideEffectFree(javax.lang.model.element.ExecutableElement)andAnnotationProvider.isDeterministic(javax.lang.model.element.ExecutableElement)methods are not used.methodTree- a method to test- Returns:
- the types of purity of the method
methodTree
-
getPurityKinds
public static EnumSet<PurityKind> getPurityKinds(AnnotationProvider provider, ExecutableElement methodElement) Returns the purity annotations on the methodmethodElement.@Pureis treated as an alias for@SideEffectFreeand@Deterministic.- Parameters:
provider- how to get annotations. ItsAnnotationProvider.isSideEffectFree(javax.lang.model.element.ExecutableElement)andAnnotationProvider.isDeterministic(javax.lang.model.element.ExecutableElement)methods are not used.methodElement- a method to test- Returns:
- the types of purity of the method
methodElement
-
isPure
Returns true if the given expression is pure: evaluating it has no side effect, and, in an unchanged environment, every evaluation yields the same location or value.In one way, this method is more conservative than
isDeterministic: it returns false for an expression such asa + b, which is pure but denotes no location that a method could modify.- Parameters:
provider- how to get annotationsexpression- an expression- Returns:
- true if the given expression is pure
-