Fix FML parsing missing locations

This commit is contained in:
Grahame Grieve 2023-03-07 20:58:01 +11:00
parent 453f073411
commit bbc3cd5121
2 changed files with 8 additions and 2 deletions

View File

@ -659,6 +659,12 @@ public class Element extends Base {
return this;
}
public Element markLocation(Element src) {
this.line = src.line();
this.col = src.col();
return this;
}
public void clearDecorations() {
clearUserData("fhir.decorations");
for (Element e : children) {

View File

@ -361,7 +361,7 @@ public class FmlParser extends ParserBase {
rule.forceElement("source").makeElement("variable").setValue(StructureMapUtilities.AUTO_VAR_NAME);
rule.forceElement("target").makeElement("variable").setValue(StructureMapUtilities.AUTO_VAR_NAME);
rule.forceElement("target").makeElement("transform").setValue(StructureMapTransform.CREATE.toCode());
Element dep = rule.forceElement("dependent");
Element dep = rule.forceElement("dependent").markLocation(rule);
dep.makeElement("name").setValue(StructureMapUtilities.DEF_GROUP_NAME);
dep.addElement("parameter").makeElement("valueId").setValue(StructureMapUtilities.AUTO_VAR_NAME);
dep.addElement("parameter").makeElement("valueId").setValue(StructureMapUtilities.AUTO_VAR_NAME);
@ -387,7 +387,7 @@ public class FmlParser extends ParserBase {
}
private void parseRuleReference(Element rule, FHIRLexer lexer) throws FHIRLexerException {
Element ref = rule.addElement("dependent");
Element ref = rule.addElement("dependent").markLocation(lexer.getCommentLocation());
ref.makeElement("name").markLocation(lexer.getCurrentLocation()).setValue(lexer.take());
lexer.token("(");
boolean done = false;