Loading plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/TDLtx.xtext +48 −24 Original line number Diff line number Diff line Loading @@ -50,12 +50,30 @@ PackageableElement returns tdl::PackageableElement: //Element : Abstract fragment AnnotationFragment returns tdl::Element: (annotation+=Annotation)* '@' //Workaround for upstream issue ( annotation+=Annotation | ('[' annotation+=Annotation (',' annotation+=Annotation)+ ']') ) ; fragment CommentFragment returns tdl::Element: 'Note' //Workaround for upstream issue ( comment+=SingleComment | ('[' comment+=MultiComment (',' comment+=MultiComment)+ ']') ) ; fragment AnnotationCommentFragment returns tdl::Element: (comment+=Comment)* (annotation+=Annotation)* CommentFragment? AnnotationFragment? //(annotation+=Annotation)* ; fragment NameFragment returns tdl::Element: Loading @@ -65,7 +83,7 @@ fragment NameFragment returns tdl::Element: fragment WithCommentFragment returns tdl::Element: 'with' BEGIN (comment+=Comment)+ CommentFragment END ; Loading @@ -89,13 +107,19 @@ ElementImport returns tdl::ElementImport: 'from' importedPackage=[tdl::Package|QIdentifier] ; Comment returns tdl::Comment: 'Note' (name=NIdentifier)? SingleComment returns tdl::Comment: (name=NIdentifier)? ':' body=EString ; MultiComment returns tdl::Comment: (name=NIdentifier ':')? body=EString ; Annotation returns tdl::Annotation: '@' key=[tdl::AnnotationType|AIdentifier] key=[tdl::AnnotationType|AIdentifier] (':' value=EString)? ; Loading Loading @@ -246,7 +270,7 @@ ProcedureSignature returns tdl::ProcedureSignature: ; ProcedureParameter returns tdl::ProcedureParameter: AnnotationFragment AnnotationFragment? kind=ParameterKind dataType=[tdl::DataType|Identifier] name=Identifier Loading @@ -257,7 +281,7 @@ enum ParameterKind returns tdl::ParameterKind: In = 'in' | Out = 'out' | Exception = 'exception'; FormalParameter returns tdl::FormalParameter: AnnotationFragment AnnotationFragment? dataType=[tdl::DataType|Identifier] name=Identifier WithCommentFragment? Loading Loading @@ -729,7 +753,7 @@ fragment WithBehaviourFragment returns tdl::Behaviour: BEGIN NameFragment? ObjectiveFragment? (comment+=Comment)* CommentFragment? END ; Loading @@ -742,7 +766,7 @@ Block returns tdl::Block: //NOTE: No annotations or comments ('[' // ('@' annotation+=PICSAnnotation)? //TODO: Exception for PICS? seems not enough AnnotationFragment AnnotationFragment? guard+=LocalExpression ( ',' guard+=LocalExpression)* ']')? BEGIN Loading Loading @@ -773,7 +797,7 @@ fragment WithCombinedFragment returns tdl::CombinedBehaviour: BEGIN NameFragment? ObjectiveFragment? (comment+=Comment)* CommentFragment? (periodic+=PeriodicBehaviour //)* | exceptional+=ExceptionalBehaviour)* END Loading @@ -788,23 +812,23 @@ SingleCombinedBehaviour returns tdl::SingleCombinedBehaviour: ; CompoundBehaviour returns tdl::CompoundBehaviour: AnnotationFragment AnnotationFragment? block=Block ; BoundedLoopBehaviour returns tdl::BoundedLoopBehaviour: AnnotationFragment AnnotationFragment? 'repeat' numIteration+=LocalLoopExpression (',' numIteration+=LocalLoopExpression)* block=Block ; UnboundedLoopBehaviour returns tdl::UnboundedLoopBehaviour: AnnotationFragment AnnotationFragment? 'while' block=Block ; OptionalBehaviour returns tdl::OptionalBehaviour: AnnotationFragment AnnotationFragment? 'optionally' block=Block ; Loading @@ -815,7 +839,7 @@ MultipleCombinedBehaviour returns tdl::MultipleCombinedBehaviour: ; ConditionalBehaviour returns tdl::ConditionalBehaviour: AnnotationFragment AnnotationFragment? 'if' block+=Block (=>('else' block+=Block) | (('else' 'if' block+=Block)* Loading @@ -823,13 +847,13 @@ ConditionalBehaviour returns tdl::ConditionalBehaviour: ; AlternativeBehaviour returns tdl::AlternativeBehaviour: AnnotationFragment AnnotationFragment? 'alternatively' block+=Block ('or' block+=Block)+ ; ParallelBehaviour returns tdl::ParallelBehaviour: AnnotationFragment AnnotationFragment? 'run' block+=Block ('in' 'parallel' 'to' block+=Block) ('and' block+=Block)* Loading @@ -840,7 +864,7 @@ ExceptionalBehaviour returns tdl::ExceptionalBehaviour: ; DefaultBehaviour returns tdl::DefaultBehaviour: AnnotationFragment AnnotationFragment? 'default' ('on' guardedComponent=[tdl::ComponentInstance|Identifier])? block=Block Loading @@ -848,7 +872,7 @@ DefaultBehaviour returns tdl::DefaultBehaviour: ; InterruptBehaviour returns tdl::InterruptBehaviour: AnnotationFragment AnnotationFragment? 'interrupt' ('on' guardedComponent=[tdl::ComponentInstance|Identifier])? block=Block Loading @@ -856,7 +880,7 @@ InterruptBehaviour returns tdl::InterruptBehaviour: ; PeriodicBehaviour returns tdl::PeriodicBehaviour: AnnotationFragment AnnotationFragment? 'every' (period+=LocalExpression (',' period+=LocalExpression)*) block=Block Loading Loading @@ -1496,7 +1520,7 @@ fragment EventOccurrenceSpecificationFragment returns to::EventOccurrenceSpecifi (',' oppositeEntityReference+=OppositeEntityReference)* )? EventTimingSuffix? (comment+=Comment)* CommentFragment? ; EntityReference returns to::EntityReference: Loading Loading @@ -1708,7 +1732,7 @@ fragment EventTemplateOccurrenceFragment returns to::EventTemplateOccurrence: ('argument' 'replaced' 'by' occurrenceArgument=Argument)? END )? (comment+=Comment)* CommentFragment? ; EntityBinding returns to::EntityBinding: Loading plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/formatting2/TDLtxFormatter.java +40 −6 Original line number Diff line number Diff line Loading @@ -381,21 +381,55 @@ public class TDLtxFormatter extends AbstractJavaFormatter { //withKeyword.getNextSemanticRegion(); // var rbs = this.textRegionExtensions.regionFor(e).ruleCallTo(this._grammarAccess.()); ISemanticRegion noteKeyword = this.textRegionExtensions.regionFor(e).keyword("Note"); if (noteKeyword!=null) { doc.prepend(noteKeyword, newLine()); } ISemanticRegion atKeyword = this.textRegionExtensions.regionFor(e).keyword("@"); if (atKeyword!=null) { doc.prepend(atKeyword, newLine()); } for (Comment c : e.getComment()) { if (e.getComment().size() > 1) { doc.prepend(c, newLine()); doc.surround(c, indent()); } else { if (!(e instanceof Member)) { doc.surround(c, indent()); } if (!(e instanceof EntityReference)) { doc.append(c, newLine()); } } doc.format(c); } for (Annotation a : e.getAnnotation()) { if (e.getAnnotation().size() > 1) { doc.prepend(a, newLine()); doc.surround(a, indent()); } else { doc.append(a, newLine()); } doc.format(a); } List<ISemanticRegion> closeItems = this.textRegionExtensions.allRegionsFor(e).keywords("]"); for (ISemanticRegion r : closeItems) { doc.surround(r, newLine()); } // List<ISemanticRegion> comments = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.get); // if (!comments.isEmpty()) { // doc.append(comments.get(0), newLine()); // } // List<ISemanticRegion> annotations = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getAnnotationFragmentRule()); // if (!annotations.isEmpty()) { // doc.surround(annotations.get(0), newLine()); // } } protected void format(org.etsi.mts.tdl.TestDescription e, IFormattableDocument doc) { Loading Loading
plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/TDLtx.xtext +48 −24 Original line number Diff line number Diff line Loading @@ -50,12 +50,30 @@ PackageableElement returns tdl::PackageableElement: //Element : Abstract fragment AnnotationFragment returns tdl::Element: (annotation+=Annotation)* '@' //Workaround for upstream issue ( annotation+=Annotation | ('[' annotation+=Annotation (',' annotation+=Annotation)+ ']') ) ; fragment CommentFragment returns tdl::Element: 'Note' //Workaround for upstream issue ( comment+=SingleComment | ('[' comment+=MultiComment (',' comment+=MultiComment)+ ']') ) ; fragment AnnotationCommentFragment returns tdl::Element: (comment+=Comment)* (annotation+=Annotation)* CommentFragment? AnnotationFragment? //(annotation+=Annotation)* ; fragment NameFragment returns tdl::Element: Loading @@ -65,7 +83,7 @@ fragment NameFragment returns tdl::Element: fragment WithCommentFragment returns tdl::Element: 'with' BEGIN (comment+=Comment)+ CommentFragment END ; Loading @@ -89,13 +107,19 @@ ElementImport returns tdl::ElementImport: 'from' importedPackage=[tdl::Package|QIdentifier] ; Comment returns tdl::Comment: 'Note' (name=NIdentifier)? SingleComment returns tdl::Comment: (name=NIdentifier)? ':' body=EString ; MultiComment returns tdl::Comment: (name=NIdentifier ':')? body=EString ; Annotation returns tdl::Annotation: '@' key=[tdl::AnnotationType|AIdentifier] key=[tdl::AnnotationType|AIdentifier] (':' value=EString)? ; Loading Loading @@ -246,7 +270,7 @@ ProcedureSignature returns tdl::ProcedureSignature: ; ProcedureParameter returns tdl::ProcedureParameter: AnnotationFragment AnnotationFragment? kind=ParameterKind dataType=[tdl::DataType|Identifier] name=Identifier Loading @@ -257,7 +281,7 @@ enum ParameterKind returns tdl::ParameterKind: In = 'in' | Out = 'out' | Exception = 'exception'; FormalParameter returns tdl::FormalParameter: AnnotationFragment AnnotationFragment? dataType=[tdl::DataType|Identifier] name=Identifier WithCommentFragment? Loading Loading @@ -729,7 +753,7 @@ fragment WithBehaviourFragment returns tdl::Behaviour: BEGIN NameFragment? ObjectiveFragment? (comment+=Comment)* CommentFragment? END ; Loading @@ -742,7 +766,7 @@ Block returns tdl::Block: //NOTE: No annotations or comments ('[' // ('@' annotation+=PICSAnnotation)? //TODO: Exception for PICS? seems not enough AnnotationFragment AnnotationFragment? guard+=LocalExpression ( ',' guard+=LocalExpression)* ']')? BEGIN Loading Loading @@ -773,7 +797,7 @@ fragment WithCombinedFragment returns tdl::CombinedBehaviour: BEGIN NameFragment? ObjectiveFragment? (comment+=Comment)* CommentFragment? (periodic+=PeriodicBehaviour //)* | exceptional+=ExceptionalBehaviour)* END Loading @@ -788,23 +812,23 @@ SingleCombinedBehaviour returns tdl::SingleCombinedBehaviour: ; CompoundBehaviour returns tdl::CompoundBehaviour: AnnotationFragment AnnotationFragment? block=Block ; BoundedLoopBehaviour returns tdl::BoundedLoopBehaviour: AnnotationFragment AnnotationFragment? 'repeat' numIteration+=LocalLoopExpression (',' numIteration+=LocalLoopExpression)* block=Block ; UnboundedLoopBehaviour returns tdl::UnboundedLoopBehaviour: AnnotationFragment AnnotationFragment? 'while' block=Block ; OptionalBehaviour returns tdl::OptionalBehaviour: AnnotationFragment AnnotationFragment? 'optionally' block=Block ; Loading @@ -815,7 +839,7 @@ MultipleCombinedBehaviour returns tdl::MultipleCombinedBehaviour: ; ConditionalBehaviour returns tdl::ConditionalBehaviour: AnnotationFragment AnnotationFragment? 'if' block+=Block (=>('else' block+=Block) | (('else' 'if' block+=Block)* Loading @@ -823,13 +847,13 @@ ConditionalBehaviour returns tdl::ConditionalBehaviour: ; AlternativeBehaviour returns tdl::AlternativeBehaviour: AnnotationFragment AnnotationFragment? 'alternatively' block+=Block ('or' block+=Block)+ ; ParallelBehaviour returns tdl::ParallelBehaviour: AnnotationFragment AnnotationFragment? 'run' block+=Block ('in' 'parallel' 'to' block+=Block) ('and' block+=Block)* Loading @@ -840,7 +864,7 @@ ExceptionalBehaviour returns tdl::ExceptionalBehaviour: ; DefaultBehaviour returns tdl::DefaultBehaviour: AnnotationFragment AnnotationFragment? 'default' ('on' guardedComponent=[tdl::ComponentInstance|Identifier])? block=Block Loading @@ -848,7 +872,7 @@ DefaultBehaviour returns tdl::DefaultBehaviour: ; InterruptBehaviour returns tdl::InterruptBehaviour: AnnotationFragment AnnotationFragment? 'interrupt' ('on' guardedComponent=[tdl::ComponentInstance|Identifier])? block=Block Loading @@ -856,7 +880,7 @@ InterruptBehaviour returns tdl::InterruptBehaviour: ; PeriodicBehaviour returns tdl::PeriodicBehaviour: AnnotationFragment AnnotationFragment? 'every' (period+=LocalExpression (',' period+=LocalExpression)*) block=Block Loading Loading @@ -1496,7 +1520,7 @@ fragment EventOccurrenceSpecificationFragment returns to::EventOccurrenceSpecifi (',' oppositeEntityReference+=OppositeEntityReference)* )? EventTimingSuffix? (comment+=Comment)* CommentFragment? ; EntityReference returns to::EntityReference: Loading Loading @@ -1708,7 +1732,7 @@ fragment EventTemplateOccurrenceFragment returns to::EventTemplateOccurrence: ('argument' 'replaced' 'by' occurrenceArgument=Argument)? END )? (comment+=Comment)* CommentFragment? ; EntityBinding returns to::EntityBinding: Loading
plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/formatting2/TDLtxFormatter.java +40 −6 Original line number Diff line number Diff line Loading @@ -381,21 +381,55 @@ public class TDLtxFormatter extends AbstractJavaFormatter { //withKeyword.getNextSemanticRegion(); // var rbs = this.textRegionExtensions.regionFor(e).ruleCallTo(this._grammarAccess.()); ISemanticRegion noteKeyword = this.textRegionExtensions.regionFor(e).keyword("Note"); if (noteKeyword!=null) { doc.prepend(noteKeyword, newLine()); } ISemanticRegion atKeyword = this.textRegionExtensions.regionFor(e).keyword("@"); if (atKeyword!=null) { doc.prepend(atKeyword, newLine()); } for (Comment c : e.getComment()) { if (e.getComment().size() > 1) { doc.prepend(c, newLine()); doc.surround(c, indent()); } else { if (!(e instanceof Member)) { doc.surround(c, indent()); } if (!(e instanceof EntityReference)) { doc.append(c, newLine()); } } doc.format(c); } for (Annotation a : e.getAnnotation()) { if (e.getAnnotation().size() > 1) { doc.prepend(a, newLine()); doc.surround(a, indent()); } else { doc.append(a, newLine()); } doc.format(a); } List<ISemanticRegion> closeItems = this.textRegionExtensions.allRegionsFor(e).keywords("]"); for (ISemanticRegion r : closeItems) { doc.surround(r, newLine()); } // List<ISemanticRegion> comments = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.get); // if (!comments.isEmpty()) { // doc.append(comments.get(0), newLine()); // } // List<ISemanticRegion> annotations = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getAnnotationFragmentRule()); // if (!annotations.isEmpty()) { // doc.surround(annotations.get(0), newLine()); // } } protected void format(org.etsi.mts.tdl.TestDescription e, IFormattableDocument doc) { Loading