Commit bdfd5572 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ Advanced Test Objective exploration (experimental)

parent 83d692be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ Require-Bundle: org.etsi.mts.tdl.model,
 org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
 org.eclipse.xtext.util,
 org.eclipse.xtend.lib,
 org.antlr.runtime,
 org.antlr.runtime;bundle-version="[3.2.0,3.2.1)",
 org.etsi.mts.tdl.common
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.etsi.mts.tdl.scoping,
+264 −13
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ Package returns tdl::Package:
    
    	//TODO: move to a type of package, similar to group perhaps?
    	('Domain' '{'
           ('annotations' ':' ( packagedElement+=AnnotationType)+ ';' )?
	        
	        ('pics' ':' ( packagedElement+=PICS)+';' )?
	        ('entity' 'types' ':' ( packagedElement+=EntityType)+ ';' )?
	        ('entities' ':' ( packagedElement+=Entity)+ ';' )?
@@ -39,6 +41,7 @@ Package returns tdl::Package:
    	'}'
    	)?
        (packagedElement+=StructuredTestObjective)*
        (packagedElement+=TestPurposeDescription)*
        (nestedPackage+=Group)*
    '}';

@@ -99,6 +102,13 @@ EntityType returns tdl::AnnotationType:
    name=Identifier
    ;

AnnotationType returns tdl::AnnotationType:
    {tdl::AnnotationType}
    '-'
    name=Identifier
    ;


Entity returns to::Entity:
    {to::Entity}
    '-'
@@ -204,11 +214,14 @@ EventSequence returns to::EventSequence:

SimpleEventSequence returns to::EventSequence:
	{to::EventSequence}
    events+=FirstEventOccurrence (events+=EventOccurrence)*  
    //events+=FirstEventOccurrence (events+=EventOccurrence)*
    
    behaviours+=FirstBehaviour (behaviours+=Behaviour)*  
    ;

RepeatedEventSequence returns to::RepeatedEventSequence:
	{to::RepeatedEventSequence}
	//TODO: adapt for behaviours
	'repeat'
	('every' interval=IterationValue | repetitions=IterationValue 'times')? 
	'{'
@@ -227,16 +240,118 @@ EventOccurrence returns to::EventOccurrence:
	EventOccurrenceSpecification | EventTemplateOccurrence
;

FirstBehaviour returns tdl::Behaviour:
	//TODO: fix
	FirstEventOccurrenceSpecification | FirstEventTemplateOccurrence
;


Behaviour returns tdl::Behaviour:
	EventOccurrenceSpecification
	 | EventTemplateOccurrence
	 | Message
;

//------------BEGIN CARRYOVER FROM TDLan2-----------------------------
Message returns tdl::Message:
	//add qualifier?
    comment+=AndOrQualifier?
    //only one qualifier?
    comment+=ArticleQualifier?
	sourceGate=[tdl::GateReference|IdentifierDot]
	('sends' | (isTrigger?='triggers')) 
	//TODO: use TDLan notation?
	//TODO: expand to more data uses?
	argument=StaticDataUse
	'to' 
	target+=TargetMessage ( "," target+=TargetMessage)* 
	(
	'with'
	'{'
		(comment+=Comment (comment+=Comment)*)?
		(annotation+=Annotation (annotation+=Annotation)*)?
		('test' 'objectives' ':' testObjective+=[tdl::TestObjective|Identifier] ( "," testObjective+=[tdl::TestObjective|Identifier])* ';')?
		('name' name=Identifier)? //USE FOR STEPS?
		('time' 'label' timeLabel=TimeLabel)?
		('time' 'constraints' ':' timeConstraint+=TimeConstraint ( "," timeConstraint+=TimeConstraint)* ';' )?
	'}')?
//	';'
	;

IdentifierDot returns ecore::EString:
	ID '.' ID
;

Comment returns tdl::Comment:
	'Note'
		(name=Identifier)?
	':'
		body=String0

	(
	'with'
	'{'
		(comment+=Comment (comment+=Comment)*)?
		(annotation+=Annotation (annotation+=Annotation)*)?
	'}')?
	';';

String0 returns ecore::EString:
	STRING
;

TargetMessage returns tdl::Target:
	targetGate=[tdl::GateReference|IdentifierDot]
	//TODO: check what the correct syntax shall be
	(valueAssignment+=ValueAssignmentMessage)?
   	(
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
		('name' name=Identifier)?
    '}')?
    ;

ValueAssignmentMessage returns tdl::ValueAssignment:
    //TODO: check what the correct syntax shall be
    'where' 'it' 'is' 'assigned' 'to' variable=[tdl::Variable|Identifier]
    (
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
        ('name' name=Identifier)?
    '}')?
    ;

LiteralValueUse returns tdl::LiteralValueUse:
	{tdl::LiteralValueUse}
	value=String0
	(
 		'of' 'type' dataType=[tdl::DataType|Identifier]
	)?
    ('with'
    '{'
		('name' name=Identifier)?
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
    '}')?
	;


//------------------------------END-----------------------------

FirstEventOccurrenceSpecification returns to::EventOccurrenceSpecification:
    {to::EventOccurrenceSpecification}

	//TODO: syntactically 0..1, but shall be 0..*
    (	(	(timeLabel=TimeLabel 
    			(	(',' timeConstraint=TimeConstraint)
    			(	(',' timeConstraint+=TimeConstraint)
    				| ':'
    			)
    		) 
    		| 
    		(timeConstraint=TimeConstraint)
    		(timeConstraint+=TimeConstraint)
		)
    )?
    (entityReference=EntityReference)?
@@ -248,14 +363,14 @@ FirstEventOccurrenceSpecification returns to::EventOccurrenceSpecification:

FirstEventTemplateOccurrence returns to::EventTemplateOccurrence:
    {to::EventTemplateOccurrence}

	//TODO: shall be 0..*
    (	(	(timeLabel=TimeLabel 
    			(	(',' timeConstraint=TimeConstraint)
    			(	(',' timeConstraint+=TimeConstraint)
    				| ':'
    			)
    		) 
    		| 
    		(timeConstraint=TimeConstraint)
    		(timeConstraint+=TimeConstraint)
		)
    )?
    'event' 
@@ -289,14 +404,15 @@ Note returns tdl::Comment:

EventOccurrenceSpecification returns to::EventOccurrenceSpecification:
    {to::EventOccurrenceSpecification}
    	//TODO: shall be 0..*
    comment+=AndOrQualifier
    (		(timeLabel=TimeLabel 
    			(	(',' timeConstraint=TimeConstraint)
    			(	(',' timeConstraint+=TimeConstraint)
    				| ':'
    			)
    		) 
    		| 
    		(timeConstraint=TimeConstraint)
    		(timeConstraint+=TimeConstraint)
		
    )?
    (entityReference=EntityReference)?
@@ -306,16 +422,18 @@ EventOccurrenceSpecification returns to::EventOccurrenceSpecification:
    (comment+=Note)*
    ;


EventTemplateOccurrence returns to::EventTemplateOccurrence:
    {to::EventTemplateOccurrence}
    comment+=AndOrQualifier
	//TODO: shall be 0..*
    (		(timeLabel=TimeLabel 
    			(	(',' timeConstraint=TimeConstraint)
    			(	(',' timeConstraint+=TimeConstraint)
    				| ':'
    			)
    		) 
    		| 
    		(timeConstraint=TimeConstraint)
    		(timeConstraint+=TimeConstraint)
		
    )?
    'event' 
@@ -555,6 +673,7 @@ ReferenceQualifier returns tdl::Comment:
DataInstanceUse returns tdl::DataInstanceUse:
	( dataInstance=[tdl::DataInstance|Identifier]
		| dataInstance=[tdl::DataInstance|NumberAsIdentifier]
        | 'a' dataType=[tdl::DataType|Identifier]
	)
	('containing' argument+=ParameterBinding ( ',' argument+=ParameterBinding)* ';')?
	;
@@ -565,7 +684,9 @@ RepetitionDataInstanceUse returns tdl::DataInstanceUse:


StaticDataUse returns tdl::StaticDataUse:
	DataInstanceUse | AnyValue | AnyValueOrOmit | OmitValue;
	DataInstanceUse | AnyValue | AnyValueOrOmit | OmitValue
	| LiteralValueUse
	;

AnyValue returns tdl::AnyValue:
	'any'
@@ -771,7 +892,7 @@ Variants returns to::Variants:
	(variants+=Variant)+
	;

Variant returns to::Variant:
Variant returns to::TestObjectiveVariant:
 	name=Identifier
	'{'
    ('Test objective' description=Identifier)? 
@@ -842,6 +963,136 @@ BindingDataReference returns to::DataReference:
   	content=StaticDataUse
    ;


TestPurposeDescription returns tdl::TestDescription:
    'Advanced Test Purpose'
    '{'
    //no locally ordered
//        (isLocallyOrdered?='Implementation')?
    
        'TP Id' name=Identifier
//        no formal parameters
//        ('(' formalParameter+=FormalParameter ( "," formalParameter+=FormalParameter)* ')')?
        'Config Id' testConfiguration=[tdl::TestConfiguration|Identifier] 

    //from test objectives
    //either extend TD or add annotations
    //    annotations will need to be expanded to TOs + references
//        'Test objective' description=STRING 
//        ('Reference' objectiveURI+=STRING (',' objectiveURI+=STRING )*)?
    //for PICS - make them extend annotations?
//        ('PICS Selection' picsReference+=FirstPICSReference (picsReference+=PICSReference)*)? 
    //variants?
    
        (behaviourDescription=BehaviourDescription)?
    '}'
    ('with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
        ('test' 'objectives' ':' testObjective+=[tdl::TestObjective|Identifier] ( "," testObjective+=[tdl::TestObjective|Identifier])* ';')?
    '}')?
    ;

BehaviourDescription returns tdl::BehaviourDescription:
    behaviour=TOCompoundBehaviour
;

TOCompoundBehaviour returns tdl::CompoundBehaviour:
    block=TOBlock
;

TOBlock returns tdl::Block:
    //no guard
//    ('[' guard+=LocalExpression (',' guard+=LocalExpression)* ']')?
        {tdl::Block} 
        (behaviour+=InitialConditionsBehaviour)? 
        (behaviour+=ExpectedBehaviourBehaviour)? 
        (behaviour+=FinalConditionsBehaviour)? 
;

InitialConditionsBehaviour returns tdl::CompoundBehaviour:
    annotation+=InitialConditionsAnnotation
    ':'
    annotation+=WithAnnotation
    block=AtomicBehaviourBlock
;

ExpectedBehaviourBehaviour returns tdl::CompoundBehaviour:
    annotation+=ExpectedBehaviourAnnotation
    ':'
    block=WhenThenBlock
;

FinalConditionsBehaviour returns tdl::CompoundBehaviour:
    annotation+=FinalConditionsAnnotation
    ':'
    annotation+=WithAnnotation
    block=AtomicBehaviourBlock
;

WhenThenBlock returns tdl::Block:
        (behaviour+=WhenBehaviour) 
        (behaviour+=ThenBehaviour) 
;

WhenBehaviour returns tdl::CompoundBehaviour:
    annotation+=WhenAnnotation
    block=AtomicBehaviourBlock
;

ThenBehaviour returns tdl::CompoundBehaviour:
    annotation+=ThenAnnotation
    block=AtomicBehaviourBlock
;


AtomicBehaviourBlock returns tdl::Block:
    //no guard
//    ('[' guard+=LocalExpression (',' guard+=LocalExpression)* ']')?
        {tdl::Block} 
        '{'
        (behaviour+=AtomicBehaviour)*
        '}'
;

AtomicBehaviour returns tdl::Behaviour:
    Message
    //procedure call
    //action
;

WithAnnotation returns tdl::Annotation:
    //try without prefix
    key=[tdl::AnnotationType|Identifier]
;

WhenAnnotation returns tdl::Annotation:
    //try without prefix
    key=[tdl::AnnotationType|Identifier]
;

ThenAnnotation returns tdl::Annotation:
    //try without prefix
    key=[tdl::AnnotationType|Identifier]
;

InitialConditionsAnnotation returns tdl::Annotation:
    //try without prefix
    key=[tdl::AnnotationType|Identifier]
;

FinalConditionsAnnotation returns tdl::Annotation:
    //try without prefix
    key=[tdl::AnnotationType|Identifier]
;

ExpectedBehaviourAnnotation returns tdl::Annotation:
    //try without prefix
    key=[tdl::AnnotationType|Identifier]
;


QIdentifier returns ecore::EString:
	ID ('.' ID)+
;
+52 −23
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.nodemodel.ICompositeNode;
@@ -54,6 +56,8 @@ import org.etsi.mts.tdl.ValueAssignment;
import org.etsi.mts.tdl.Variable;
import org.etsi.mts.tdl.VariableUse;
import org.etsi.mts.tdl.tdlPackage;
import org.etsi.mts.tdl.structuredobjectives.EntityReference;
import org.etsi.mts.tdl.structuredobjectives.EventSequence;
import org.etsi.mts.tdl.structuredobjectives.StructuredTestObjective;

import com.google.common.base.Function;
@@ -86,7 +90,16 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
				}
			}
		} else if (reference.getEType().getInstanceClass() == ComponentInstance.class) {
			if (context instanceof Behaviour || context instanceof Block || context instanceof LocalExpression || context instanceof VariableUse) {
			if (context instanceof EntityReference) {
				StructuredTestObjective testObjective = EcoreUtil2.getContainerOfType(context, StructuredTestObjective.class);
				TestConfiguration configuration = testObjective.getConfiguration();
				if (configuration == null) {
					return  IScope.NULLSCOPE;
				}
				IScope scope = Scopes.scopeFor(configuration.getComponentInstance());
				return scope;

			} else if (context instanceof Behaviour || context instanceof Block || context instanceof LocalExpression || context instanceof VariableUse) {
				TestDescription testDescription = getTestDescription((Element) context);
				if (testDescription!=null) {
					TestConfiguration configuration = testDescription.getTestConfiguration();
@@ -113,13 +126,26 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
			//TODO: safety checks in case invalid configuration is specified
			//TODO: only suggest connected gates as targets?

			if (context instanceof Behaviour || context instanceof Target || context instanceof Block) {
				TestConfiguration configuration = getTestDescription((Element) context).getTestConfiguration();
			if (context instanceof Behaviour || context instanceof Target || context instanceof Block || context instanceof EventSequence) {
				TestConfiguration configuration;
				//TODO: this will need to be abstracted away as it is needed in other contexts too
				StructuredTestObjective testObjective = EcoreUtil2.getContainerOfType(context, StructuredTestObjective.class);
				if (testObjective!=null) {
					configuration = testObjective.getConfiguration();
				} else {
					configuration = getTestDescription((Element) context).getTestConfiguration();
				}
				if (configuration == null) {
					return  IScope.NULLSCOPE;
				}
				EList<EObject> elements = new BasicEList<>();
				for (Connection c : configuration.getConnection()) {
					if (context instanceof Message) {
						//TODO: quick hack until a better solution is found
						ICompositeNode oppositeNode = NodeModelUtils.findActualNodeFor(((Message) context).getTarget().get(0));
						//TODO: add further safety checks 
						EList<Target> targets = ((Message) context).getTarget();
						if (!targets.isEmpty()) {
							ICompositeNode oppositeNode = NodeModelUtils.findActualNodeFor(targets.get(0));
							if (oppositeNode != null) {
								String targetGateName = oppositeNode.getText()
										.replaceAll("(?s)where\\s+it\\s+is.+", "")
@@ -143,6 +169,9 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
								//TODO: double check
								elements.addAll(c.getEndPoint());
							}
						}  else {
							//handle
						}
						
//						GateReference opposite = ((Message) context).getTarget().get(0).getTargetGate();
//						if (c.getEndPoint().get(0) == opposite) {
+8 −13
Original line number Diff line number Diff line
@@ -18,20 +18,18 @@
    <eStructuralFeatures xsi:type="ecore:EReference" name="variants" eType="#//Variants"
        containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="AdvancedTestObjective" eSuperTypes="#//StructuredTestObjective"/>
  <eClassifiers xsi:type="ecore:EClass" name="InitialConditions" eSuperTypes="tdl.ecore#//Element">
    <eStructuralFeatures xsi:type="ecore:EReference" name="conditions" lowerBound="1"
        eType="#//EventSequence" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="EventSequence" eSuperTypes="tdl.ecore#//Element">
    <eStructuralFeatures xsi:type="ecore:EReference" name="events" lowerBound="1"
        upperBound="-1" eType="#//EventOccurrence" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="EventOccurrence" abstract="true" eSuperTypes="tdl.ecore#//Element">
    <eStructuralFeatures xsi:type="ecore:EReference" name="timeConstraint" eType="ecore:EClass tdl.ecore#//TimeConstraint"
        containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="timeLabel" eType="ecore:EClass tdl.ecore#//TimeLabel"
        containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="events" upperBound="-1"
        eType="#//EventOccurrence" containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="behaviours" lowerBound="1"
        upperBound="-1" eType="ecore:EClass tdl.ecore#//Behaviour" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="EventOccurrence" abstract="true" eSuperTypes="tdl.ecore#//AtomicBehaviour"/>
  <eClassifiers xsi:type="ecore:EClass" name="ExpectedBehaviour" eSuperTypes="tdl.ecore#//Element">
    <eStructuralFeatures xsi:type="ecore:EReference" name="whenClause" eType="#//EventSequence"
        containment="true"/>
@@ -117,12 +115,9 @@
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Variants" eSuperTypes="tdl.ecore#//Element">
    <eStructuralFeatures xsi:type="ecore:EReference" name="variants" upperBound="-1"
        eType="#//Variant" containment="true"/>
        eType="#//TestObjectiveVariant" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Variant" eSuperTypes="tdl.ecore#//NamedElement">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="objectiveURI" upperBound="-1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  <eClassifiers xsi:type="ecore:EClass" name="TestObjectiveVariant" eSuperTypes="tdl.ecore#//TestObjective">
    <eStructuralFeatures xsi:type="ecore:EReference" name="picsReference" upperBound="-1"
        eType="#//PICSReference" containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="bindings" upperBound="-1"
+6 −9
Original line number Diff line number Diff line
@@ -44,16 +44,15 @@
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//StructuredTestObjective/picsReference"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//StructuredTestObjective/variants"/>
    </genClasses>
    <genClasses ecoreClass="structured.ecore#//AdvancedTestObjective"/>
    <genClasses ecoreClass="structured.ecore#//InitialConditions">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//InitialConditions/conditions"/>
    </genClasses>
    <genClasses ecoreClass="structured.ecore#//EventSequence">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//EventSequence/events"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//EventSequence/behaviours"/>
    </genClasses>
    <genClasses image="false" ecoreClass="structured.ecore#//EventOccurrence">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//EventOccurrence/timeConstraint"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//EventOccurrence/timeLabel"/>
    </genClasses>
    <genClasses image="false" ecoreClass="structured.ecore#//EventOccurrence"/>
    <genClasses ecoreClass="structured.ecore#//ExpectedBehaviour">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//ExpectedBehaviour/whenClause"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//ExpectedBehaviour/thenClause"/>
@@ -119,11 +118,9 @@
    <genClasses ecoreClass="structured.ecore#//Variants">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//Variants/variants"/>
    </genClasses>
    <genClasses ecoreClass="structured.ecore#//Variant">
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute structured.ecore#//Variant/objectiveURI"/>
      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute structured.ecore#//Variant/description"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//Variant/picsReference"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//Variant/bindings"/>
    <genClasses ecoreClass="structured.ecore#//TestObjectiveVariant">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//TestObjectiveVariant/picsReference"/>
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//TestObjectiveVariant/bindings"/>
    </genClasses>
    <genClasses ecoreClass="structured.ecore#//VariantBinding">
      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference structured.ecore#//VariantBinding/value"/>