From bbc3cd512132200ae8753a64371fa7539b8f7032 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 7 Mar 2023 20:58:01 +1100 Subject: [PATCH] Fix FML parsing missing locations --- .../src/main/java/org/hl7/fhir/r5/elementmodel/Element.java | 6 ++++++ .../main/java/org/hl7/fhir/r5/elementmodel/FmlParser.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java index 06b781f26..9efbe7345 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java @@ -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) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/FmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/FmlParser.java index a0716a98e..5bfa95387 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/FmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/FmlParser.java @@ -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;