Loading plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java +15 −4 Changes for plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java: 15 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -427,11 +427,14 @@ public class Generator { map.put(Placeholders.INITIAL, initialConditions); } //TODO:check if defined? if (sto.getExpectedBehaviour()!=null) { String expected = NodeModelUtils.getNode(sto.getExpectedBehaviour()).getText(); expected = expected.replaceAll("\\s*Expected behaviour", ""); expected = filterSource(expected, "\n", "ensure").trim(); map.put(Placeholders.EXPECTED, expected); } else { map.put(Placeholders.EXPECTED, ""); } map.put(Placeholders.FINAL, ""); if (sto.getFinalConditions()!=null) { Loading @@ -442,22 +445,29 @@ public class Generator { map.put(Placeholders.FINAL, finalConditions); } if (sto.getExpectedBehaviour()!=null && sto.getExpectedBehaviour().getWhenClause()!=null && sto.getExpectedBehaviour().getThenClause()!=null ) { String when = NodeModelUtils.getNode(sto.getExpectedBehaviour().getWhenClause()).getText(); String then = NodeModelUtils.getNode(sto.getExpectedBehaviour().getThenClause()).getText(); //TODO: a bit of a hack when = filterSource(when, "\n", "\\s\\s\\s\\s\\w"); then = filterSource(then, "\n", "\\s\\s\\s\\s\\w"); then = filterSource(then, "\n", "\\s+\\w"); map.put(Placeholders.WHEN, "when {"+when+"\n}"); map.put(Placeholders.THEN, "then {"+then+"\n}"); } return map; } private String filterSource(String source, String prefix, String offsetKeyword) { Matcher matcher = Pattern.compile(prefix+"(.+?)"+offsetKeyword).matcher(source); matcher.find(); String offset = matcher.group(1); String offset = ""; if (matcher.find()) { offset = matcher.group(1); System.out.println("|"+offset+"|"); } source = source .replaceAll("\t", " ") //tabs .replaceAll("\n"+offset, "\n") //leading space Loading @@ -465,6 +475,7 @@ public class Generator { .replaceAll("[\\s\n\r]+"+prefix, prefix) .replaceAll(" \\((typed|predefined)\\) ", " ") //shall be optional .replaceAll(" entity ", " ") //shall be optional .replaceAll("\\^", "") //shall be optional .replaceAll(";", "") //shall be optional .replaceAll("\\(|\\)", "") //shall be optional ; Loading Loading
plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java +15 −4 Changes for plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java: 15 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -427,11 +427,14 @@ public class Generator { map.put(Placeholders.INITIAL, initialConditions); } //TODO:check if defined? if (sto.getExpectedBehaviour()!=null) { String expected = NodeModelUtils.getNode(sto.getExpectedBehaviour()).getText(); expected = expected.replaceAll("\\s*Expected behaviour", ""); expected = filterSource(expected, "\n", "ensure").trim(); map.put(Placeholders.EXPECTED, expected); } else { map.put(Placeholders.EXPECTED, ""); } map.put(Placeholders.FINAL, ""); if (sto.getFinalConditions()!=null) { Loading @@ -442,22 +445,29 @@ public class Generator { map.put(Placeholders.FINAL, finalConditions); } if (sto.getExpectedBehaviour()!=null && sto.getExpectedBehaviour().getWhenClause()!=null && sto.getExpectedBehaviour().getThenClause()!=null ) { String when = NodeModelUtils.getNode(sto.getExpectedBehaviour().getWhenClause()).getText(); String then = NodeModelUtils.getNode(sto.getExpectedBehaviour().getThenClause()).getText(); //TODO: a bit of a hack when = filterSource(when, "\n", "\\s\\s\\s\\s\\w"); then = filterSource(then, "\n", "\\s\\s\\s\\s\\w"); then = filterSource(then, "\n", "\\s+\\w"); map.put(Placeholders.WHEN, "when {"+when+"\n}"); map.put(Placeholders.THEN, "then {"+then+"\n}"); } return map; } private String filterSource(String source, String prefix, String offsetKeyword) { Matcher matcher = Pattern.compile(prefix+"(.+?)"+offsetKeyword).matcher(source); matcher.find(); String offset = matcher.group(1); String offset = ""; if (matcher.find()) { offset = matcher.group(1); System.out.println("|"+offset+"|"); } source = source .replaceAll("\t", " ") //tabs .replaceAll("\n"+offset, "\n") //leading space Loading @@ -465,6 +475,7 @@ public class Generator { .replaceAll("[\\s\n\r]+"+prefix, prefix) .replaceAll(" \\((typed|predefined)\\) ", " ") //shall be optional .replaceAll(" entity ", " ") //shall be optional .replaceAll("\\^", "") //shall be optional .replaceAll(";", "") //shall be optional .replaceAll("\\(|\\)", "") //shall be optional ; Loading