Loading plugins/Prototypes/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/formatting2/TDLtxFormatter.java +4 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.prepend(e, p -> p.setNewLines(1)); var rbs = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getBEGINRule()); var res = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getENDRule()); System.out.println(res.size()); // System.out.println(res.size()); int i = 0; for (var rs : rbs) { i++; Loading @@ -58,9 +58,11 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.format(comment); } for (Annotation _annotation : e.getAnnotation()) { doc.surround(_annotation, p -> p.setNewLines(1)); // this.textRegionExtensions.regionFor(e).keyword("@") doc.append(_annotation, p -> p.setNewLines(1)); doc.format(_annotation); } // doc.surround(this.textRegionExtensions.regionFor(e).keyword("@"), p->p.noSpace()); for (var c : e.eContents()) { if (c instanceof NamedElement || c instanceof MemberAssignment Loading plugins/Prototypes/org.etsi.mts.tdl.txi/src/org/etsi/mts/tdl/formatting2/TDLtxiFormatter.java +57 −9 Original line number Diff line number Diff line Loading @@ -5,49 +5,96 @@ package org.etsi.mts.tdl.formatting2; import org.eclipse.xtext.formatting2.IFormattableDocument; import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion; import org.eclipse.xtext.xbase.lib.Extension; import org.etsi.mts.tdl.Element; import org.etsi.mts.tdl.ElementImport; import org.etsi.mts.tdl.PackageableElement; import org.etsi.mts.tdl.StructuredDataType; import org.etsi.mts.tdl.StructuredDataInstance; import org.etsi.mts.tdl.TestObjective; import org.etsi.mts.tdl.ComponentType; import org.etsi.mts.tdl.Annotation; import org.etsi.mts.tdl.Extension; import org.etsi.mts.tdl.DataElementMapping; import org.etsi.mts.tdl.services.TDLtxGrammarAccess; import org.etsi.mts.tdl.TestConfiguration; import org.etsi.mts.tdl.TestDescription; import org.etsi.mts.tdl.Behaviour; import org.etsi.mts.tdl.FormalParameter; import org.etsi.mts.tdl.LocalExpression; import org.etsi.mts.tdl.services.TDLtxiGrammarAccess; import com.google.inject.Inject; public class TDLtxiFormatter extends TDLtxFormatter { @Inject @Extension private TDLtxiGrammarAccess _grammarAccess; @Override protected void formatCustom(Element e, IFormattableDocument doc) { } protected void format(org.etsi.mts.tdl.Block e, IFormattableDocument doc) { for (var m : e.eContents()) { if (!(m instanceof Annotation) && !(m instanceof LocalExpression)) { //TODO: handle nested behaviour doc.prepend(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); } else if (m instanceof Annotation) { doc.append(m, p->p.newLine()); } else { } doc.format(m); } } @Override protected void format(org.etsi.mts.tdl.NamedElement e, IFormattableDocument doc) { doc.surround(e, p->p.newLine()); doc.interior(e, p->p.indent()); // doc.interior(e, p->p.indent()); // doc.format(e); // doc.interior(e, p->p.indent()); if (e instanceof StructuredDataType) { // var open = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getBEGINRule()); // var close = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getENDRule()); // // doc.append(open.get(0), p->p.newLine()); // doc.interior(open.get(0), close.get(0), p->p.indent()); for (var m : ((StructuredDataType)e).getMember()) { doc.surround(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } if (e instanceof StructuredDataInstance) { for (var m : ((StructuredDataInstance)e).getMemberAssignment()) { doc.surround(m, p->p.newLine()); doc.prepend(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } if (e instanceof ComponentType || e instanceof TestConfiguration || e instanceof TestDescription) { for (var m : e.eContents()) { if (!(m instanceof Annotation) && !(m instanceof Extension) && !(m instanceof FormalParameter)) { doc.prepend(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } } if (e instanceof DataElementMapping) { for (var m : ((DataElementMapping)e).getParameterMapping()) { doc.surround(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } Loading @@ -74,12 +121,13 @@ public class TDLtxiFormatter extends TDLtxFormatter { //withKeyword.getNextSemanticRegion(); // var rbs = this.textRegionExtensions.regionFor(e).ruleCallTo(this._grammarAccess.()); for (var c : e.getComment()) { doc.surround(c, p->p.newLine()); doc.surround(c, p->p.indent()); doc.append(c, p->p.newLine()); doc.format(c); } for (var a : e.getAnnotation()) { doc.surround(a, p->p.newLine()); doc.append(a, p->p.newLine()); doc.format(a); } Loading Loading
plugins/Prototypes/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/formatting2/TDLtxFormatter.java +4 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.prepend(e, p -> p.setNewLines(1)); var rbs = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getBEGINRule()); var res = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getENDRule()); System.out.println(res.size()); // System.out.println(res.size()); int i = 0; for (var rs : rbs) { i++; Loading @@ -58,9 +58,11 @@ public class TDLtxFormatter extends AbstractJavaFormatter { doc.format(comment); } for (Annotation _annotation : e.getAnnotation()) { doc.surround(_annotation, p -> p.setNewLines(1)); // this.textRegionExtensions.regionFor(e).keyword("@") doc.append(_annotation, p -> p.setNewLines(1)); doc.format(_annotation); } // doc.surround(this.textRegionExtensions.regionFor(e).keyword("@"), p->p.noSpace()); for (var c : e.eContents()) { if (c instanceof NamedElement || c instanceof MemberAssignment Loading
plugins/Prototypes/org.etsi.mts.tdl.txi/src/org/etsi/mts/tdl/formatting2/TDLtxiFormatter.java +57 −9 Original line number Diff line number Diff line Loading @@ -5,49 +5,96 @@ package org.etsi.mts.tdl.formatting2; import org.eclipse.xtext.formatting2.IFormattableDocument; import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion; import org.eclipse.xtext.xbase.lib.Extension; import org.etsi.mts.tdl.Element; import org.etsi.mts.tdl.ElementImport; import org.etsi.mts.tdl.PackageableElement; import org.etsi.mts.tdl.StructuredDataType; import org.etsi.mts.tdl.StructuredDataInstance; import org.etsi.mts.tdl.TestObjective; import org.etsi.mts.tdl.ComponentType; import org.etsi.mts.tdl.Annotation; import org.etsi.mts.tdl.Extension; import org.etsi.mts.tdl.DataElementMapping; import org.etsi.mts.tdl.services.TDLtxGrammarAccess; import org.etsi.mts.tdl.TestConfiguration; import org.etsi.mts.tdl.TestDescription; import org.etsi.mts.tdl.Behaviour; import org.etsi.mts.tdl.FormalParameter; import org.etsi.mts.tdl.LocalExpression; import org.etsi.mts.tdl.services.TDLtxiGrammarAccess; import com.google.inject.Inject; public class TDLtxiFormatter extends TDLtxFormatter { @Inject @Extension private TDLtxiGrammarAccess _grammarAccess; @Override protected void formatCustom(Element e, IFormattableDocument doc) { } protected void format(org.etsi.mts.tdl.Block e, IFormattableDocument doc) { for (var m : e.eContents()) { if (!(m instanceof Annotation) && !(m instanceof LocalExpression)) { //TODO: handle nested behaviour doc.prepend(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); } else if (m instanceof Annotation) { doc.append(m, p->p.newLine()); } else { } doc.format(m); } } @Override protected void format(org.etsi.mts.tdl.NamedElement e, IFormattableDocument doc) { doc.surround(e, p->p.newLine()); doc.interior(e, p->p.indent()); // doc.interior(e, p->p.indent()); // doc.format(e); // doc.interior(e, p->p.indent()); if (e instanceof StructuredDataType) { // var open = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getBEGINRule()); // var close = this.textRegionExtensions.regionFor(e).ruleCallsTo(this._grammarAccess.getENDRule()); // // doc.append(open.get(0), p->p.newLine()); // doc.interior(open.get(0), close.get(0), p->p.indent()); for (var m : ((StructuredDataType)e).getMember()) { doc.surround(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } if (e instanceof StructuredDataInstance) { for (var m : ((StructuredDataInstance)e).getMemberAssignment()) { doc.surround(m, p->p.newLine()); doc.prepend(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } if (e instanceof ComponentType || e instanceof TestConfiguration || e instanceof TestDescription) { for (var m : e.eContents()) { if (!(m instanceof Annotation) && !(m instanceof Extension) && !(m instanceof FormalParameter)) { doc.prepend(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } } if (e instanceof DataElementMapping) { for (var m : ((DataElementMapping)e).getParameterMapping()) { doc.surround(m, p->p.newLine()); doc.surround(m, p->p.indent()); doc.append(m, p->p.newLine()); doc.format(m); } } Loading @@ -74,12 +121,13 @@ public class TDLtxiFormatter extends TDLtxFormatter { //withKeyword.getNextSemanticRegion(); // var rbs = this.textRegionExtensions.regionFor(e).ruleCallTo(this._grammarAccess.()); for (var c : e.getComment()) { doc.surround(c, p->p.newLine()); doc.surround(c, p->p.indent()); doc.append(c, p->p.newLine()); doc.format(c); } for (var a : e.getAnnotation()) { doc.surround(a, p->p.newLine()); doc.append(a, p->p.newLine()); doc.format(a); } Loading