Loading plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/formatting2/TDLtxFormatter.java +41 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ import java.util.List; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.Assignment; import org.eclipse.xtext.Keyword; import org.eclipse.xtext.TerminalRule; import org.eclipse.xtext.formatting2.AbstractJavaFormatter; import org.eclipse.xtext.formatting2.FormatterPreferenceKeys; import org.eclipse.xtext.formatting2.IFormattableDocument; Loading Loading @@ -42,6 +44,11 @@ import org.etsi.mts.tdl.LocalExpression; import org.etsi.mts.tdl.Member; import org.etsi.mts.tdl.MemberAssignment; import org.etsi.mts.tdl.Package; import org.etsi.mts.tdl.structuredobjectives.EventOccurrence; import org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour; import org.etsi.mts.tdl.structuredobjectives.FinalConditions; import org.etsi.mts.tdl.structuredobjectives.InitialConditions; import org.etsi.mts.tdl.structuredobjectives.StructuredTestObjective; import org.etsi.mts.tdl.services.TDLtxGrammarAccess; import com.google.inject.Inject; Loading Loading @@ -99,6 +106,17 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.prepend(e, p->p.newLine()); } if (e instanceof EventOccurrence) { doc.prepend(e, p->p.newLine()); doc.surround(e, p->p.indent()); doc.append(e, p->p.newLine()); //TODO: expand custom formatting - when then, event occurrence arguments, etc. return; } if (e instanceof ExpectedBehaviour) { } for (EObject m : e.eContents()) { if (m instanceof TimeLabel || Loading @@ -109,9 +127,13 @@ public class TDLtxFormatter extends AbstractJavaFormatter { } else if ( m instanceof Annotation || m instanceof Comment ) { doc.prepend(m, p->p.newLine()); doc.append(m, p->p.newLine()); } else if (m instanceof EventOccurrence) { doc.prepend(m, p->p.newLine()); doc.append(m, p->p.newLine()); } else if ( m instanceof Annotation || m instanceof Comment || Loading Loading @@ -242,6 +264,24 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.append(f, p->p.newLine()); } if (e instanceof StructuredTestObjective) { InitialConditions ic = ((StructuredTestObjective) e).getInitialConditions(); doc.prepend(ic, p->p.newLine()); doc.surround(ic, p->p.indent()); doc.append(ic, p->p.newLine()); doc.format(ic); ExpectedBehaviour eb = ((StructuredTestObjective) e).getExpectedBehaviour(); doc.prepend(eb, p->p.newLine()); doc.surround(eb, p->p.indent()); doc.append(eb, p->p.newLine()); doc.format(eb); FinalConditions fc = ((StructuredTestObjective) e).getFinalConditions(); doc.prepend(fc, p->p.newLine()); doc.surround(fc, p->p.indent()); doc.append(fc, p->p.newLine()); doc.format(fc); } } //All ISemanticRegion withKeyword = this.textRegionExtensions.regionFor(e).keyword("with"); Loading plugins/org.etsi.mts.tdl.txi/src/org/etsi/mts/tdl/formatting2/TDLtxiFormatter.java +35 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,41 @@ */ package org.etsi.mts.tdl.formatting2; import java.util.List; import org.eclipse.xtext.TerminalRule; import org.eclipse.xtext.formatting2.IFormattableDocument; import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion; import org.etsi.mts.tdl.services.TDLtxGrammarAccess; import org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour; import com.google.inject.Inject; public class TDLtxiFormatter extends TDLtxFormatter { @Inject private TDLtxGrammarAccess _grammarAccess; protected void format(org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour e, IFormattableDocument doc) { //DONE: a bit of a hack, moved to TXi formatter? ISemanticRegion thatKeyword = this.textRegionExtensions.regionFor(e).keyword("that"); if (thatKeyword!=null) { doc.append(thatKeyword, p->p.newLine()); doc.append(thatKeyword, p->p.indent()); } List<ISemanticRegion> when = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getWhenRule()); List<ISemanticRegion> then = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getThenRule()); if (!when.isEmpty()) { doc.surround(when.get(0), p->p.indent()); doc.append(when.get(0), p->p.newLine()); doc.interior(when.get(0), then.get(0), p->p.indent()); doc.surround(then.get(0), p->p.indent()); doc.append(then.get(0), p->p.newLine()); doc.append(then.get(0), p->p.indent()); doc.surround(((ExpectedBehaviour) e).getThenClause(), p->p.indent()); } super.format(e, doc); } } Loading
plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/formatting2/TDLtxFormatter.java +41 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ import java.util.List; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.Assignment; import org.eclipse.xtext.Keyword; import org.eclipse.xtext.TerminalRule; import org.eclipse.xtext.formatting2.AbstractJavaFormatter; import org.eclipse.xtext.formatting2.FormatterPreferenceKeys; import org.eclipse.xtext.formatting2.IFormattableDocument; Loading Loading @@ -42,6 +44,11 @@ import org.etsi.mts.tdl.LocalExpression; import org.etsi.mts.tdl.Member; import org.etsi.mts.tdl.MemberAssignment; import org.etsi.mts.tdl.Package; import org.etsi.mts.tdl.structuredobjectives.EventOccurrence; import org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour; import org.etsi.mts.tdl.structuredobjectives.FinalConditions; import org.etsi.mts.tdl.structuredobjectives.InitialConditions; import org.etsi.mts.tdl.structuredobjectives.StructuredTestObjective; import org.etsi.mts.tdl.services.TDLtxGrammarAccess; import com.google.inject.Inject; Loading Loading @@ -99,6 +106,17 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.prepend(e, p->p.newLine()); } if (e instanceof EventOccurrence) { doc.prepend(e, p->p.newLine()); doc.surround(e, p->p.indent()); doc.append(e, p->p.newLine()); //TODO: expand custom formatting - when then, event occurrence arguments, etc. return; } if (e instanceof ExpectedBehaviour) { } for (EObject m : e.eContents()) { if (m instanceof TimeLabel || Loading @@ -109,9 +127,13 @@ public class TDLtxFormatter extends AbstractJavaFormatter { } else if ( m instanceof Annotation || m instanceof Comment ) { doc.prepend(m, p->p.newLine()); doc.append(m, p->p.newLine()); } else if (m instanceof EventOccurrence) { doc.prepend(m, p->p.newLine()); doc.append(m, p->p.newLine()); } else if ( m instanceof Annotation || m instanceof Comment || Loading Loading @@ -242,6 +264,24 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.append(f, p->p.newLine()); } if (e instanceof StructuredTestObjective) { InitialConditions ic = ((StructuredTestObjective) e).getInitialConditions(); doc.prepend(ic, p->p.newLine()); doc.surround(ic, p->p.indent()); doc.append(ic, p->p.newLine()); doc.format(ic); ExpectedBehaviour eb = ((StructuredTestObjective) e).getExpectedBehaviour(); doc.prepend(eb, p->p.newLine()); doc.surround(eb, p->p.indent()); doc.append(eb, p->p.newLine()); doc.format(eb); FinalConditions fc = ((StructuredTestObjective) e).getFinalConditions(); doc.prepend(fc, p->p.newLine()); doc.surround(fc, p->p.indent()); doc.append(fc, p->p.newLine()); doc.format(fc); } } //All ISemanticRegion withKeyword = this.textRegionExtensions.regionFor(e).keyword("with"); Loading
plugins/org.etsi.mts.tdl.txi/src/org/etsi/mts/tdl/formatting2/TDLtxiFormatter.java +35 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,41 @@ */ package org.etsi.mts.tdl.formatting2; import java.util.List; import org.eclipse.xtext.TerminalRule; import org.eclipse.xtext.formatting2.IFormattableDocument; import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion; import org.etsi.mts.tdl.services.TDLtxGrammarAccess; import org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour; import com.google.inject.Inject; public class TDLtxiFormatter extends TDLtxFormatter { @Inject private TDLtxGrammarAccess _grammarAccess; protected void format(org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour e, IFormattableDocument doc) { //DONE: a bit of a hack, moved to TXi formatter? ISemanticRegion thatKeyword = this.textRegionExtensions.regionFor(e).keyword("that"); if (thatKeyword!=null) { doc.append(thatKeyword, p->p.newLine()); doc.append(thatKeyword, p->p.indent()); } List<ISemanticRegion> when = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getWhenRule()); List<ISemanticRegion> then = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getThenRule()); if (!when.isEmpty()) { doc.surround(when.get(0), p->p.indent()); doc.append(when.get(0), p->p.newLine()); doc.interior(when.get(0), then.get(0), p->p.indent()); doc.surround(then.get(0), p->p.indent()); doc.append(then.get(0), p->p.newLine()); doc.append(then.get(0), p->p.indent()); doc.surround(((ExpectedBehaviour) e).getThenClause(), p->p.indent()); } super.format(e, doc); } }