org.eclipse.ocl.examples.impactanalyzer.instanceScope
Class InstanceScopeAnalysis

java.lang.Object
  extended by org.eclipse.ocl.examples.impactanalyzer.deltaPropagation.PartialEvaluatorFactoryImpl
      extended by org.eclipse.ocl.examples.impactanalyzer.instanceScope.InstanceScopeAnalysis
All Implemented Interfaces:
PartialEvaluatorFactory

public class InstanceScopeAnalysis
extends PartialEvaluatorFactoryImpl

Supports a lookup from a source model element of either an attribute value change event or a link add/remove event together with an OCLExpression to a set of context objects for which the expression may return a value different from the one it returned before the change event occurred. An instance of this class manages the analysis for all expression occuring within one root OCL expression, including the expressions reachable in operation body expressions where the operation may be called directly of indirectly by the root expression.


Field Summary
 
Fields inherited from interface org.eclipse.ocl.examples.impactanalyzer.PartialEvaluatorFactory
INSTANCE
 
Constructor Summary
  InstanceScopeAnalysis(OCLExpression expression, org.eclipse.emf.ecore.EClass exprContext, FilterSynthesisImpl filterSynthesizer, OppositeEndFinder oppositeEndFinder, ActivationOption configuration, OCLFactory oclFactory)
           
protected InstanceScopeAnalysis(OCLExpression expression, org.eclipse.emf.ecore.EClass exprContext, FilterSynthesisImpl filterSynthesizer, OppositeEndFinder oppositeEndFinder, PartialEvaluatorImpl partialEvaluator, ActivationOption configuration, OCLFactory oclFactory, PathCache pathCache, TracebackStepCache tracebackStepCache)
           
 
Method Summary
protected  Tracer createTracer(OCLExpression expression, java.util.Stack<java.lang.String> tuplePartNames, OCLFactory oclFactory)
          Factory method that creates an instance of some Tracer-implementing class specific to the type of the OCL expression.
static java.util.Set<org.eclipse.emf.ecore.EObject> getAllPossibleContextInstances(org.eclipse.emf.common.notify.Notifier context, org.eclipse.emf.ecore.EClass cls, OppositeEndFinder oppositeEndFinder)
          Finds all elements of type cls or conforming to cls such that based on the scope definition implemented by the oppositeEndFinder's OppositeEndFinder.getAllInstancesSeeing(EClass, org.eclipse.emf.common.notify.Notifier) method, the elements returned can "see" container.
 java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.ecore.EObject evaluationResult)
          Determines a superset of the set of context objects for which the overall expression managed by this instance scope analysis results in evaluationResult or a collection containing evaluationResult.
 java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.common.notify.Notification event, boolean notifyOnNewContextElements)
           
 PartialEvaluatorFactory getPartialEvaluatorFactory()
           
protected  PartialEvaluatorImpl getPartialEvaluatorForAllInstancesDeltaPropagation()
           
protected  PathCache getPathCache()
           
protected  java.util.Collection<AnnotatedEObject> getSourceElement(org.eclipse.emf.common.notify.Notification changeEvent, NavigationCallExp attributeOrAssociationEndCall)
           
protected  java.util.Collection<java.lang.Object> getSourceElementsForOppositePropertyCallExp(org.eclipse.emf.common.notify.Notification changeEvent)
           
protected  void initInstanceScopeAnalysisOnPathCache()
           
 boolean isUnaffectedDueToPrimitiveAttributeValueComparisonWithLiteralOnly(org.eclipse.emf.common.notify.Notification changeEvent, java.lang.String replacementFor__TEMP__)
          Checks if all ModelChangeEvents contained in events are attribute changes and the expressions affected by the change event are all attribute call expressions for an attribute of primitive type that is used in a direct comparison with a constant literal.
 
Methods inherited from class org.eclipse.ocl.examples.impactanalyzer.deltaPropagation.PartialEvaluatorFactoryImpl
createPartialEvaluator, createPartialEvaluator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceScopeAnalysis

public InstanceScopeAnalysis(OCLExpression expression,
                             org.eclipse.emf.ecore.EClass exprContext,
                             FilterSynthesisImpl filterSynthesizer,
                             OppositeEndFinder oppositeEndFinder,
                             ActivationOption configuration,
                             OCLFactory oclFactory)
Parameters:
expression - the OCL expression for which to perform instance scope impact analysis
oppositeEndFinder - used during partial evaluation and for metamodel queries, e.g., finding opposite role names, or finding all subclasses of a class; as well as for obtaining all instances of a type while performing an AllInstancesNavigationStep. It is handed to the PathCache object from where Tracers can retrieve it using AbstractPathCache.getOppositeEndFinder().

InstanceScopeAnalysis

protected InstanceScopeAnalysis(OCLExpression expression,
                                org.eclipse.emf.ecore.EClass exprContext,
                                FilterSynthesisImpl filterSynthesizer,
                                OppositeEndFinder oppositeEndFinder,
                                PartialEvaluatorImpl partialEvaluator,
                                ActivationOption configuration,
                                OCLFactory oclFactory,
                                PathCache pathCache,
                                TracebackStepCache tracebackStepCache)
Method Detail

initInstanceScopeAnalysisOnPathCache

protected void initInstanceScopeAnalysisOnPathCache()

getPathCache

protected PathCache getPathCache()

getAllPossibleContextInstances

public static java.util.Set<org.eclipse.emf.ecore.EObject> getAllPossibleContextInstances(org.eclipse.emf.common.notify.Notifier context,
                                                                                          org.eclipse.emf.ecore.EClass cls,
                                                                                          OppositeEndFinder oppositeEndFinder)
Finds all elements of type cls or conforming to cls such that based on the scope definition implemented by the oppositeEndFinder's OppositeEndFinder.getAllInstancesSeeing(EClass, org.eclipse.emf.common.notify.Notifier) method, the elements returned can "see" container.

Parameters:
cls - the overall context type for the entire expression; this context type defines the type for self if used outside of operation bodies.
oppositeEndFinder - used to determine all instances

createTracer

protected Tracer createTracer(OCLExpression expression,
                              java.util.Stack<java.lang.String> tuplePartNames,
                              OCLFactory oclFactory)
Factory method that creates an instance of some Tracer-implementing class specific to the type of the OCL expression.

Parameters:
caller - the calling tracer from which the list of tuple part names to look for are copied unchanged to the new tracer created by this operation. May be null in which case the new tracer does not look for any tuple literal parts initially.

getContextObjects

public java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.common.notify.Notification event,
                                                                             boolean notifyOnNewContextElements)

getContextObjects

public java.util.Collection<org.eclipse.emf.ecore.EObject> getContextObjects(org.eclipse.emf.ecore.EObject evaluationResult)
Determines a superset of the set of context objects for which the overall expression managed by this instance scope analysis results in evaluationResult or a collection containing evaluationResult. The result is always a valid collection, never null, but possibly empty.

Parameters:
evaluationResult - has to be a non-null EObject because backwards navigation is not easily possible for primitive-typed values and is impossible from null values for now.

isUnaffectedDueToPrimitiveAttributeValueComparisonWithLiteralOnly

public boolean isUnaffectedDueToPrimitiveAttributeValueComparisonWithLiteralOnly(org.eclipse.emf.common.notify.Notification changeEvent,
                                                                                 java.lang.String replacementFor__TEMP__)
Checks if all ModelChangeEvents contained in events are attribute changes and the expressions affected by the change event are all attribute call expressions for an attribute of primitive type that is used in a direct comparison with a constant literal. If this is the case, compares the old and new value with the literal's value, considering the comparison operator. If no change occurs in comparison result for any of the events, true is returned because then the expression value didn't change based on the change event. If any of the events is an event of different type or the attribute is not of primitive type or its value is not compared to a constant, false is returned.

Note that further performance improvements are conceivable but not yet implemented. For example, the attribute call expression may be used in a let-expression and then the variable may be compared to a primitive literal.

Parameters:
replacementFor__TEMP__ - as a special case, expressions can contain the special string literal "__TEMP__" (see GlobalDelayedReferenceResolver.TEMPORARY_QUERY_PARAM_REPLACEMENT). Those will be replaced by the value of a lexical token. This value can be passed here so that the comparison does not happen with the special "__TEMP__" constant but with the parameter value instead in case the comparison argument is a string literal with value "__TEMP__".

getSourceElement

protected java.util.Collection<AnnotatedEObject> getSourceElement(org.eclipse.emf.common.notify.Notification changeEvent,
                                                                  NavigationCallExp attributeOrAssociationEndCall)
Parameters:
changeEvent - either an AttributeValueChangeEvent or a LinkChangeEvent.
attributeOrAssociationEndCall - a (sub-)expression originally affected by changeEvent. For LinkChangeEvents it depends on which end the expression uses what will be considered the source element of the change which will then be returned by this method. The source is the element at the end of the link changed that is the opposite end of the end used by the AssociationEndCallExp. attributeOrAssociationEndCall has to be of type AttributeCallExp in case changeEvent is an AttributeValueChangeEvent, and of type AssociationEndCallExp in case changeEvent is of type LinkChangeEvent.
Returns:
null in case the source element indicated by the change event does not conform to the static attribute or association call's source expression type. null may also result if the element indicated by the event cannot be resolved (anymore). This is still an open issue. See the to-do marker below. In all other cases, the source element on which the event occured, is returned.

getSourceElementsForOppositePropertyCallExp

protected java.util.Collection<java.lang.Object> getSourceElementsForOppositePropertyCallExp(org.eclipse.emf.common.notify.Notification changeEvent)

getPartialEvaluatorForAllInstancesDeltaPropagation

protected PartialEvaluatorImpl getPartialEvaluatorForAllInstancesDeltaPropagation()

getPartialEvaluatorFactory

public PartialEvaluatorFactory getPartialEvaluatorFactory()