org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback
Class AbstractTracebackStep<E extends OCLExpression>

java.lang.Object
  extended by org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.AbstractTracebackStep<E>
All Implemented Interfaces:
TracebackStep
Direct Known Subclasses:
BranchingTracebackStep, EmptyTracebackStep, IteratorTracebackStep, OppositePropertyCallTracebackStep, PropertyCallTracebackStep

public abstract class AbstractTracebackStep<E extends OCLExpression>
extends java.lang.Object
implements TracebackStep


Nested Class Summary
static class AbstractTracebackStep.TracebackStepAndScopeChange
          Encapsulates the scope change that has to happen before invoking a subsequent traceback step.
protected static class AbstractTracebackStep.TracebackStepAndScopeChangeWithOperationCallExp
          When executed using the AbstractTracebackStep.TracebackStepAndScopeChangeWithOperationCallExp.traceback(AnnotatedEObject, UnusedEvaluationRequestSet, TracebackCache, Notification) method, results will be keyed with AbstractTracebackStep.TracebackStepAndScopeChangeWithOperationCallExp.callToWhichResultsAreSpecific because the TracebackStep encapsulated by this object navigates back to the specified call expression, and there either to the source or an argument expression.
 
Field Summary
protected  OCLFactory oclFactory
           
static int provenUnused
           
protected  org.eclipse.emf.ecore.EClass requiredType
          If set to a non-null class, this step asserts that if the source objects passed to its traceback(AnnotatedEObject, UnusedEvaluationRequestSet, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) or #traceback(Set, UnusedEvaluationRequestSet, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) operation are not compatible to that type, then the result set will be empty.
static int tracebackExecutions
           
 
Constructor Summary
protected AbstractTracebackStep(E sourceExpression, java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor, OppositeEndFinder oppositeEndFinder, OperationBodyToCallMapper operationBodyToCallMapper, UnusedEvaluationRequestFactory unusedEvaluationRequestFactory, OCLFactory oclFactory)
          If the expression's type for which this traceback step is constructed is class-like, requiredType is set to the expression's type.
 
Method Summary
protected  java.util.Set<AnnotatedEObject> annotate(AnnotatedEObject fromObject, java.util.Set<AnnotatedEObject> newResults)
          If in debug mode, creates a new AnnotatedEObject for each one in newResults, assuming that there is no "from" object; as an alibi "from" object, the annotated objects from newResults are used.
protected  AnnotatedEObject annotateEObject(AnnotatedEObject object)
          Annotates a non-navigation where object is forwarded unchanged from this step to another.
protected  AnnotatedEObject annotateEObject(AnnotatedEObject fromObject, org.eclipse.emf.ecore.EObject next)
          Annotates a navigation from fromObject to next by taking over fromObject's annotation, adding a description of this step and telling at which object the navigation arrived.
protected  java.util.Stack<java.lang.String> cloneWithTypeCheck(java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor)
           
protected  AbstractTracebackStep.TracebackStepAndScopeChange createTracebackStepAndScopeChange(OCLExpression sourceExpression, OCLExpression targetExpression, org.eclipse.emf.ecore.EClass context, OperationBodyToCallMapper operationBodyToCallMapper, java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor, TracebackStepCache tracebackStepCache)
          Creates a new AbstractTracebackStep.TracebackStepAndScopeChange} object.
protected  AbstractTracebackStep.TracebackStepAndScopeChangeWithOperationCallExp createTracebackStepAndScopeChange(OCLExpression sourceExpression, OCLExpression targetExpression, OperationCallExp call, org.eclipse.emf.ecore.EClass context, OperationBodyToCallMapper operationBodyToCallMapper, java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor, TracebackStepCache tracebackStepCache)
          Creates a new AbstractTracebackStep.TracebackStepAndScopeChange} object, remembering an OperationCallExp to which the results produced by this step are specific.
protected static java.util.Set<Variable> getAllVariablesInScope(OCLExpression e, OperationBodyToCallMapper operationBodyToCallMapper)
          Starting from e and ascending its containment hierarchy, adds to the resulting set all variables that are scoped by any of the expressions visited.
 E getExpression()
           
protected  org.eclipse.emf.ecore.EClass getInnermostClass(org.eclipse.emf.ecore.EClassifier type)
          We assume a collection, possibly nested, that eventually has elements of a class-like type inside.
protected  org.eclipse.emf.ecore.EClassifier getInnermostElementType(org.eclipse.emf.ecore.EClassifier type)
          We assume a collection, possibly nested, that eventually has elements of a class-like type inside.
protected  org.eclipse.emf.ecore.EClass getInnermostTypeConsideringTupleLiteralsLookedFor(java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor, org.eclipse.emf.ecore.EClassifier type)
           
protected  OppositeEndFinder getOppositeEndFinder()
           
protected static java.util.Set<Variable> getVariablesScopedByExpression(OCLExpression e, OperationBodyToCallMapper operationBodyToCallMapper)
           
protected abstract  OperationCallExpKeyedSet performSubsequentTraceback(AnnotatedEObject source, UnusedEvaluationRequestSet pendingUnusedEvalRequests, TracebackCache tracebackCache, org.eclipse.emf.common.notify.Notification changeEvent)
          This method is used to invoke the TracebackStep#traceback(AnnotatedEObject, Set, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) method on all necessary subsequent TracebackSteps and return their results.
 OperationCallExpKeyedSet traceback(AnnotatedEObject source, UnusedEvaluationRequestSet pendingUnusedEvalRequests, TracebackCache tracebackCache, org.eclipse.emf.common.notify.Notification changeEvent)
          When being executed, the step computes a conservative superset of the objects that, when used as the context for the overall OCLExpression, may cause the expression for which this TracebackStep was created to evaluate to source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requiredType

protected org.eclipse.emf.ecore.EClass requiredType
If set to a non-null class, this step asserts that if the source objects passed to its traceback(AnnotatedEObject, UnusedEvaluationRequestSet, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) or #traceback(Set, UnusedEvaluationRequestSet, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) operation are not compatible to that type, then the result set will be empty.


oclFactory

protected final OCLFactory oclFactory

tracebackExecutions

public static int tracebackExecutions

provenUnused

public static int provenUnused
Constructor Detail

AbstractTracebackStep

protected AbstractTracebackStep(E sourceExpression,
                                java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor,
                                OppositeEndFinder oppositeEndFinder,
                                OperationBodyToCallMapper operationBodyToCallMapper,
                                UnusedEvaluationRequestFactory unusedEvaluationRequestFactory,
                                OCLFactory oclFactory)
If the expression's type for which this traceback step is constructed is class-like, requiredType is set to the expression's type.

Parameters:
tupleLiteralNamesToLookFor - if a tuple part is being sought, the expression type will be a tuple type; in this case, extract the sought part's type as the requiredType.
Method Detail

getExpression

public E getExpression()
Returns:
the expression for which this step is responsible

getInnermostTypeConsideringTupleLiteralsLookedFor

protected org.eclipse.emf.ecore.EClass getInnermostTypeConsideringTupleLiteralsLookedFor(java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor,
                                                                                         org.eclipse.emf.ecore.EClassifier type)

traceback

public OperationCallExpKeyedSet traceback(AnnotatedEObject source,
                                          UnusedEvaluationRequestSet pendingUnusedEvalRequests,
                                          TracebackCache tracebackCache,
                                          org.eclipse.emf.common.notify.Notification changeEvent)
Description copied from interface: TracebackStep
When being executed, the step computes a conservative superset of the objects that, when used as the context for the overall OCLExpression, may cause the expression for which this TracebackStep was created to evaluate to source.

Specified by:
traceback in interface TracebackStep
Parameters:
source - the object to which the expression, for which this step was created, shall evaluate
pendingUnusedEvalRequests - When tracing back a VariableExp expression, this infers a value for the variable referred to by the expression. This may trigger a previously delayed "unused" evaluation to be triggered. Those triggerable "unused" evaluation requests are passed using this parameter. When triggering one of them proves the location of the original change to be unused, an empty set will result from this call. May be null, having the same effect as passing a set that contains no requests.
tracebackCache - cache in which previous results of TracebackStep.traceback(AnnotatedEObject, UnusedEvaluationRequestSet, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) executions can be found
changeEvent - the original change event; used for performing pre/post evaluations
Returns:
the set of objects (with optional annotation explaining the derivation path of each object) for which, when used as context for the overall expression, the OCL (sub-)expression for which this step is responsible may evaluate to source. The resulting objects may additionally be keyed by OperationCallExp expressions in case their inference left an operation body through a self or parameter variable. These keys are removed again in the OperationCallTracebackStep, keying the results specific to the call being traced by the null key. All object reached without leaving an operation body through a self or parameter variable are also keyed by the null key.

performSubsequentTraceback

protected abstract OperationCallExpKeyedSet performSubsequentTraceback(AnnotatedEObject source,
                                                                       UnusedEvaluationRequestSet pendingUnusedEvalRequests,
                                                                       TracebackCache tracebackCache,
                                                                       org.eclipse.emf.common.notify.Notification changeEvent)
This method is used to invoke the TracebackStep#traceback(AnnotatedEObject, Set, org.eclipse.ocl.examples.impactanalyzer.instanceScope.traceback.TracebackCache, Notification) method on all necessary subsequent TracebackSteps and return their results. Which subsequent steps are necessary depends on the respective source OCLExpression the TracebackStep was created for.


getVariablesScopedByExpression

protected static java.util.Set<Variable> getVariablesScopedByExpression(OCLExpression e,
                                                                        OperationBodyToCallMapper operationBodyToCallMapper)

getAllVariablesInScope

protected static java.util.Set<Variable> getAllVariablesInScope(OCLExpression e,
                                                                OperationBodyToCallMapper operationBodyToCallMapper)
Starting from e and ascending its containment hierarchy, adds to the resulting set all variables that are scoped by any of the expressions visited.

Returns:
a new set that the client may modify at will without doing any harm

createTracebackStepAndScopeChange

protected AbstractTracebackStep.TracebackStepAndScopeChange createTracebackStepAndScopeChange(OCLExpression sourceExpression,
                                                                                              OCLExpression targetExpression,
                                                                                              org.eclipse.emf.ecore.EClass context,
                                                                                              OperationBodyToCallMapper operationBodyToCallMapper,
                                                                                              java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor,
                                                                                              TracebackStepCache tracebackStepCache)
Creates a new AbstractTracebackStep.TracebackStepAndScopeChange} object. Fetches from the cache or produces the TracebackStep} and computes the variable scope changes (see getVariablesChangingScope(OCLExpression, OCLExpression, OperationBodyToCallMapper). The results of these two operations are used for the AbstractTracebackStep.TracebackStepAndScopeChange constructor.


createTracebackStepAndScopeChange

protected AbstractTracebackStep.TracebackStepAndScopeChangeWithOperationCallExp createTracebackStepAndScopeChange(OCLExpression sourceExpression,
                                                                                                                  OCLExpression targetExpression,
                                                                                                                  OperationCallExp call,
                                                                                                                  org.eclipse.emf.ecore.EClass context,
                                                                                                                  OperationBodyToCallMapper operationBodyToCallMapper,
                                                                                                                  java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor,
                                                                                                                  TracebackStepCache tracebackStepCache)
Creates a new AbstractTracebackStep.TracebackStepAndScopeChange} object, remembering an OperationCallExp to which the results produced by this step are specific. The results produced by the step returned will all be keyed by the call. Fetches from the cache or produces the TracebackStep} and computes the variable scope changes (see getVariablesChangingScope(OCLExpression, OCLExpression, OperationBodyToCallMapper). The results of these two operations are used for the AbstractTracebackStep.TracebackStepAndScopeChange constructor.


getInnermostClass

protected org.eclipse.emf.ecore.EClass getInnermostClass(org.eclipse.emf.ecore.EClassifier type)
We assume a collection, possibly nested, that eventually has elements of a class-like type inside. If the innermost type is not an EClass, null is returned.


getInnermostElementType

protected org.eclipse.emf.ecore.EClassifier getInnermostElementType(org.eclipse.emf.ecore.EClassifier type)
We assume a collection, possibly nested, that eventually has elements of a class-like type inside. If the innermost type is not an EClass, null is returned.


cloneWithTypeCheck

protected java.util.Stack<java.lang.String> cloneWithTypeCheck(java.util.Stack<java.lang.String> tupleLiteralNamesToLookFor)

annotateEObject

protected AnnotatedEObject annotateEObject(AnnotatedEObject fromObject,
                                           org.eclipse.emf.ecore.EObject next)
Annotates a navigation from fromObject to next by taking over fromObject's annotation, adding a description of this step and telling at which object the navigation arrived. In case we're not in debug mode, a default message (see AnnotatedEObject.NOT_IN_DEBUG_MODE_MESSAGE) is used instead to save memory.


annotateEObject

protected AnnotatedEObject annotateEObject(AnnotatedEObject object)
Annotates a non-navigation where object is forwarded unchanged from this step to another. The result is an AnnotatedEObject with its from-object and reached object both being set to object, adding a description of this step and telling at which object the navigation arrived. In case we're not in debug mode, a default message (see AnnotatedEObject.NOT_IN_DEBUG_MODE_MESSAGE) is used instead to save memory.


annotate

protected java.util.Set<AnnotatedEObject> annotate(AnnotatedEObject fromObject,
                                                   java.util.Set<AnnotatedEObject> newResults)
If in debug mode, creates a new AnnotatedEObject for each one in newResults, assuming that there is no "from" object; as an alibi "from" object, the annotated objects from newResults are used.


getOppositeEndFinder

protected OppositeEndFinder getOppositeEndFinder()