Commit 086cfd05 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ maintenance and enhancements to tplan

+ variants
+ improved data definitions
+ improved pics references
+ not qualifier (pics, data)
parent 4140762f
......@@ -29,8 +29,7 @@ Package returns tdl::Package:
('event' 'templates' ':' ( packagedElement+=EventOccurrenceTemplate)+ ';' )?
'}')?
('Data' '{'
(packagedElement+=StructuredDataType)*
(packagedElement+=StructuredDataInstance)*
(packagedElement+=DataElement)*
'}'
)?
('Configuration' '{'
......@@ -43,6 +42,18 @@ Package returns tdl::Package:
(nestedPackage+=Group)*
'}';
DataElement returns tdl::MappableDataElement:
DataType | DataInstance
;
DataType returns tdl::DataType:
SimpleDataType | StructuredDataType
;
DataInstance returns tdl::DataInstance:
SimpleDataInstance | StructuredDataInstance
;
ElementImport returns tdl::ElementImport:
{tdl::ElementImport}
......@@ -71,11 +82,17 @@ PICS returns to::PICS:
("(" comment+=Qualifier ")")?
;
PICSReference returns to::PICSReference :
(comment+=AndOrQualifier)?
FirstPICSReference returns to::PICSReference :
(comment+=NotQualifier)?
pics=[to::PICS|Identifier]
;
PICSReference returns to::PICSReference :
(comment+=AndOrQualifier)
(comment+=NotQualifier)?
pics=[to::PICS|Identifier]
;
EntityType returns tdl::AnnotationType:
{tdl::AnnotationType}
'-'
......@@ -133,10 +150,11 @@ StructuredTestObjective returns to::StructuredTestObjective:
'Test objective' description=Identifier
('Reference' objectiveURI+=Identifier (',' objectiveURI+=Identifier )*)?
('Config Id' configuration=[tdl::TestConfiguration|Identifier])?
('PICS Selection' picsReference+=PICSReference (picsReference+=PICSReference)*)?
('PICS Selection' picsReference+=FirstPICSReference (picsReference+=PICSReference)*)?
(initialConditions=InitialConditions)?
(expectedBehaviour=ExpectedBehaviour)?
(finalConditions=FinalConditions)?
(variants=Variants)?
'}';
InitialConditions returns to::InitialConditions:
......@@ -377,7 +395,7 @@ OppositeEntityReference returns to::EntityReference:
EventReference returns to::EventReference:
{to::EventReference}
(comment+=Qualifier | comment+=CommonWordQualifier)*
(comment+=Qualifier | comment+=CommonWordQualifier | comment+=NotQualifier)*
event=[to::Event|Identifier]
;
......@@ -425,6 +443,7 @@ TypedLiteralValueAsArgument returns to::LiteralValue:
TypedLiteralValue returns to::LiteralValue:
{to::LiteralValue}
(comment+=NotQualifier)?
comment+=AssignmentQualifier
(comment+=Qualifier)*
(name=Identifier | name=NumberAsIdentifier)
......@@ -434,6 +453,7 @@ TypedLiteralValue returns to::LiteralValue:
TypedDataContent returns to::Content:
{to::Content}
(comment+=NotQualifier)?
(comment+=Qualifier)*
member=[tdl::Member|Identifier]
(
......@@ -456,6 +476,7 @@ LiteralValueAsArgument returns to::LiteralValue:
LiteralValue returns to::LiteralValue:
{to::LiteralValue}
(comment+=NotQualifier)?
comment+=AssignmentQualifier
(comment+=Qualifier)*
(name=Identifier | name=NumberAsIdentifier)
......@@ -475,6 +496,7 @@ IterationDataReference returns to::DataReference:
DataContent returns to::Content:
{to::Content}
(comment+=NotQualifier)?
(comment+=Qualifier)*
//(parameter=[Parameter|Identifier] | name=Identifier | name=NumberAsIdentifier)
(name=Identifier | name=NumberAsIdentifier)
......@@ -512,6 +534,10 @@ AndOrQualifier returns tdl::Comment:
(body='and' | body='or')
;
NotQualifier returns tdl::Comment:
(body='not')
;
DirectionQualifier returns tdl::Comment:
( body='by' |
body='in' |
......@@ -558,12 +584,14 @@ OmitValue returns tdl::OmitValue:
ParameterBinding returns tdl::ParameterBinding:
parameter=[tdl::Parameter|Identifier]
(comment+=NotQualifier)?
comment+=AssignmentQualifier
(comment+=Qualifier)*
dataUse=StaticDataUse
;
ContentReference returns to::ContentReference:
(comment+=NotQualifier)?
comment+=ReferenceQualifier
'the' 'value' 'contained in'
//make more complex: simplify
......@@ -577,6 +605,7 @@ ContentReference returns to::ContentReference:
;
LiteralValueReference returns to::LiteralValueReference:
(comment+=NotQualifier)?
comment+=ReferenceQualifier
'the' 'value' 'of'
(comment+=Qualifier)*
......@@ -597,6 +626,7 @@ LiteralValueReferenceArgument returns to::LiteralValueReference:
DataReference returns to::DataReference:
(name=Identifier)?
(comment+=NotQualifier)?
comment+=ReferenceQualifier
(comment+=Qualifier)*
content=StaticDataUse
......@@ -615,11 +645,19 @@ DataReferenceAsArgument returns to::DataReference:
NumberAsIdentifier returns ecore::EString:
'-'? INT ('.' INT)?;
SimpleDataType returns tdl::SimpleDataType:
{tdl::SimpleDataType}
'type'
name=Identifier
';'
;
StructuredDataType returns tdl::StructuredDataType:
{tdl::StructuredDataType}
'type'
name=Identifier
('with' member+=Member ( "," member+=Member)* )?
'with' member+=Member ( "," member+=Member)*
';';
Member returns tdl::Member:
......@@ -633,16 +671,25 @@ Optional returns ecore::EBoolean :
'optional'
;
SimpleDataInstance returns tdl::SimpleDataInstance:
{tdl::SimpleDataInstance}
dataType=[tdl::SimpleDataType|Identifier]
(name=Identifier | name=NumberAsIdentifier)
';'
;
StructuredDataInstance returns tdl::StructuredDataInstance:
{tdl::StructuredDataInstance}
dataType=[tdl::DataType|Identifier]
dataType=[tdl::StructuredDataType|Identifier]
(name=Identifier | name=NumberAsIdentifier)
('containing' memberAssignment+=MemberAssignment (',' memberAssignment+=MemberAssignment)* )?
'containing' memberAssignment+=MemberAssignment (',' memberAssignment+=MemberAssignment)*
';'
;
MemberAssignment returns tdl::MemberAssignment:
member=[tdl::Member|Identifier]
(comment+=NotQualifier)?
comment+=AssignmentQualifier
memberSpec=StaticDataUse
;
......@@ -718,6 +765,83 @@ GateInstance returns tdl::GateInstance:
;
Variants returns to::Variants:
'Variants'
(variants+=Variant)+
;
Variant returns to::Variant:
name=Identifier
'{'
('Test objective' description=Identifier)?
('Reference' objectiveURI+=Identifier (',' objectiveURI+=Identifier )*)?
('PICS Selection' picsReference+=FirstPICSReference (picsReference+=PICSReference)*)?
('Bindings' (bindings+=VariantBinding)+)?
'}'
;
VariantBinding returns to::VariantBinding:
VariantBindingValue | VariantBindingAttribute | VariantBindingPredefined
;
VariantBindingValue returns to::VariantBinding:
'value'
value=BindingLiteralValueReference
'set to'
boundTo=LiteralOrDataReferenceAsBinding
';'
;
VariantBindingAttribute returns to::VariantBinding:
'attribute'
value=BindingContentReference
'set to'
boundTo=LiteralValueAsBinding
';'
;
LiteralOrDataReferenceAsBinding returns to::Value:
LiteralValueAsBinding | DataReferenceAsBinding
;
VariantBindingPredefined returns to::VariantBinding:
'predefined' 'value'
value=BindingDataReference
'set to'
boundTo=BindingDataReference
';'
;
LiteralValueAsBinding returns to::LiteralValue:
{to::LiteralValue}
(comment+=Qualifier)*
(name=Identifier | name=NumberAsIdentifier)
('containing' content+=DataContent (',' content+=DataContent)* ';')?
;
DataReferenceAsBinding returns to::DataReference:
'(predefined)'
(comment+=Qualifier)*
//name=Identifier
content=StaticDataUse
;
BindingContentReference returns to::ContentReference:
content=[to::Content|Identifier]
;
BindingLiteralValueReference returns to::LiteralValueReference:
content=[to::LiteralValue|Identifier] | content=[to::LiteralValue|NumberAsIdentifier]
;
BindingDataReference returns to::DataReference:
content=StaticDataUse
;
terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'/')*;
terminal INT returns ecore::EInt: ('0'..'9')+;
......
......@@ -3,20 +3,30 @@
*/
package org.etsi.mts.tdl.scoping;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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.scoping.IScope;
import org.eclipse.xtext.scoping.Scopes;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.etsi.mts.tdl.DataInstanceUse;
import org.etsi.mts.tdl.DataUse;
import org.etsi.mts.tdl.Element;
import org.etsi.mts.tdl.ElementImport;
import org.etsi.mts.tdl.GateInstance;
import org.etsi.mts.tdl.GateReference;
import org.etsi.mts.tdl.MemberAssignment;
import org.etsi.mts.tdl.MemberReference;
import org.etsi.mts.tdl.NamedElement;
import org.etsi.mts.tdl.Package;
import org.etsi.mts.tdl.PackageableElement;
import org.etsi.mts.tdl.Parameter;
......@@ -24,7 +34,17 @@ import org.etsi.mts.tdl.ParameterBinding;
import org.etsi.mts.tdl.StructuredDataInstance;
import org.etsi.mts.tdl.StructuredDataType;
import org.etsi.mts.tdl.structuredobjectives.Content;
import org.etsi.mts.tdl.structuredobjectives.ContentReference;
import org.etsi.mts.tdl.structuredobjectives.DataReference;
import org.etsi.mts.tdl.structuredobjectives.EventOccurrenceSpecification;
import org.etsi.mts.tdl.structuredobjectives.EventSequence;
import org.etsi.mts.tdl.structuredobjectives.LiteralValue;
import org.etsi.mts.tdl.structuredobjectives.LiteralValueReference;
import org.etsi.mts.tdl.structuredobjectives.StructuredTestObjective;
import org.etsi.mts.tdl.structuredobjectives.VariantBinding;
import com.google.common.base.Function;
import com.google.inject.Inject;
/**
* This class contains custom scoping description.
......@@ -33,13 +53,16 @@ import org.etsi.mts.tdl.structuredobjectives.LiteralValue;
* on how and when to use it.
*/
public class TPLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
@Inject
private IQualifiedNameConverter qualifiedNameConverter;
@Override
public IScope getScope(EObject context, EReference reference) {
if (PackageableElement.class.isAssignableFrom(reference.getEType().getInstanceClass())
&& !(context instanceof ElementImport)) {
EList<EObject> elements = getScopedElementsOfType(context, reference.getEType().getInstanceClass());
return Scopes.scopeFor(elements);
IScope scope = Scopes.scopeFor(elements);
return scope;
}
if (reference.getEType().getInstanceClass() == GateInstance.class) {
if (context instanceof GateReference) {
......@@ -91,10 +114,34 @@ public class TPLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
}
}
}
} else if (context.eContainer() instanceof VariantBinding) {
// System.out.println(context +" -> " + reference);
if (context instanceof LiteralValueReference) {
StructuredTestObjective sto = EcoreUtil2.getContainerOfType(context, StructuredTestObjective.class);
List<LiteralValue> literalValues = new ArrayList<>();
if (sto.getInitialConditions() != null) {
literalValues.addAll(EcoreUtil2.getAllContentsOfType(sto.getInitialConditions(), LiteralValue.class));
}
if (sto.getExpectedBehaviour() != null) {
literalValues.addAll(EcoreUtil2.getAllContentsOfType(sto.getExpectedBehaviour(), LiteralValue.class));
}
if (sto.getFinalConditions() != null) {
literalValues.addAll(EcoreUtil2.getAllContentsOfType(sto.getFinalConditions(), LiteralValue.class));
}
IScope scope = Scopes.scopeFor(literalValues);
return scope;
} else if (context instanceof ContentReference) {
StructuredTestObjective sto = EcoreUtil2.getContainerOfType(context, StructuredTestObjective.class);
List<Content> content = EcoreUtil2.getAllContentsOfType(sto, Content.class);
IScope scope = Scopes.scopeFor(content);
return scope;
}
} else {
}
return super.getScope(context, reference);
IScope scope = super.getScope(context, reference);
return scope;
}
public IScope scope_ElementImport_importedElement(ElementImport context, EReference ref) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment