io.sarl.lang.typesystem
Interface IOperationHelper
All Known Implementing Classes:
SARLOperationHelper
interface IOperationHelper
Helper on operations.

This implementation extends the Xtend expression helper by assuming that any function with a name starting with "get", "is", "has" is a pure function. It also assumes that "equals", "hashCode", "clone" and "toString" are also pure functions.
Maven Group Identifier:
io.sarl.lang
Maven Artifact Identifier:
compiler
Since:
0.6
Action Summary
Modifier and type Action and description
abstract void attachPureAnnotationAdapter(JvmOperation,Function2<P1,P2,Result>)
Create an adapter for attached an pure annotation adapter to given operation.
abstract boolean evaluatePureAnnotationAdapters(JvmOperation)
Replies if the given operation could be annotated with @Pure according to its associated adapters.
abstract java.lang.Iterable<T> getSideEffectExpressions(InferredPrototype,XExpression)
Replies the list of calls that have side effects into the given expression.
abstract boolean hasSideEffects(InferredPrototype,XExpression)
Replies if the given expression has a side effect in the context of its containing operation.
abstract boolean isPurableOperation(XtendFunction)
Check if the given operation could be annoted with @Pure.
abstract boolean isPureOperation(JvmOperation)
Check if the given operation is annoted with @Pure.
Action Details
attachPureAnnotationAdapter(JvmOperation,Function2<P1,P2,Result>)
def attachPureAnnotationAdapter(JvmOperation,Function2<P1,P2,Result>)
Create an adapter for attached an pure annotation adapter to given operation.
Parameters:
operation - the operation to update.
dynamicCallback - the code to run for adapting the operation. This call back replies true if the operation could be annotated with @Pure.
See:
org.eclipse.xtext.xbase.lib.Pure , evaluatePureAnnotationAdapters(JvmOperation)
evaluatePureAnnotationAdapters(JvmOperation)
def evaluatePureAnnotationAdapters(JvmOperation) : boolean
Replies if the given operation could be annotated with @Pure according to its associated adapters.
Parameters:
operation - the operation to update.
Returns:
true if the given operation could be annotated.
See:
org.eclipse.xtext.xbase.lib.Pure
getSideEffectExpressions(InferredPrototype,XExpression)
def getSideEffectExpressions(InferredPrototype,XExpression) : java.lang.Iterable<T>
Replies the list of calls that have side effects into the given expression.

This function differs from hasSideEffects(XExpression) because it explore the syntax tree for determining if one action has a side effect.
Parameters:
calledOperation - the called operation. It is used for detecting recursive calls.
expr - the expression to test, usually, the body of the expression.
Returns:
the list of side-effect calls.
Since:
0.12
See:
hasSideEffects(InferredPrototype,XExpression)
hasSideEffects(InferredPrototype,XExpression)
def hasSideEffects(InferredPrototype,XExpression) : boolean
Replies if the given expression has a side effect in the context of its containing operation.

This function differs from hasSideEffects(XExpression) because it explore the syntax tree for determining if one action has a side effect.
Parameters:
calledOperation - the called operation. It is used for detecting recursive calls.
expr - the expression to test, usually, the body of the expression.
Returns:
true if a side effect was detected into the expression.
See:
getSideEffectExpressions(InferredPrototype,XExpression)
isPurableOperation(XtendFunction)
def isPurableOperation(XtendFunction) : boolean
Check if the given operation could be annoted with @Pure.

This function is usually used by the inferrers for automatically generating the pure function annotation.

This function does not consider the @Pure annotation that is associated to the overridden function declaration. Only the current operation block is considered
Parameters:
operation - the operation to test.
Returns:
true if the given operation has not a side effect; otherwise false .
See:
org.eclipse.xtext.xbase.lib.Pure , isPureOperation(JvmOperation)
isPureOperation(JvmOperation)
def isPureOperation(JvmOperation) : boolean
Check if the given operation is annoted with @Pure.
Parameters:
operation - the operation to test.
Returns:
true if the operation is marked as pure; otherwise false .
See:
org.eclipse.xtext.xbase.lib.Pure , isPurableOperation(XtendFunction)