From 7448c074d67841693be82d998c3a7c921bbec0e5 Mon Sep 17 00:00:00 2001 From: Evan Chicoine Date: Mon, 26 Apr 2021 13:28:49 -0400 Subject: [PATCH] #437: newLine() called after processing comment. --- .../cql/tools/formatter/CqlFormatterVisitor.java | 1 + .../cql/tools/formatter/CqlFormatterVisitorTest.java | 2 ++ .../org/cqframework/cql/tools/formatter/git-issue-437.cql | 6 ++++++ 3 files changed, 9 insertions(+) create mode 100644 Src/java/tools/cql-formatter/src/test/resources/org/cqframework/cql/tools/formatter/git-issue-437.cql diff --git a/Src/java/tools/cql-formatter/src/main/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitor.java b/Src/java/tools/cql-formatter/src/main/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitor.java index 12820c90a..1fe68a201 100644 --- a/Src/java/tools/cql-formatter/src/main/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitor.java +++ b/Src/java/tools/cql-formatter/src/main/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitor.java @@ -248,6 +248,7 @@ private void appendComment(CommentToken token) { .append(whitespaceBefore); } output.append(token.token.getText()).append(whitespace); + newLine(); } private void appendTerminal(String terminal) { diff --git a/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java b/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java index 8267cb42d..45a7b7b72 100644 --- a/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java +++ b/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java @@ -64,6 +64,8 @@ public void TestFormatterSpecific() throws IOException { Assert.assertFalse(inError); runTest("git-issue-613.cql"); Assert.assertFalse(inError); + runTest("git-issue-437.cql"); + Assert.assertFalse(inError); try { runTest("invalid-syntax.cql"); } catch (AssertionError ae) { diff --git a/Src/java/tools/cql-formatter/src/test/resources/org/cqframework/cql/tools/formatter/git-issue-437.cql b/Src/java/tools/cql-formatter/src/test/resources/org/cqframework/cql/tools/formatter/git-issue-437.cql new file mode 100644 index 000000000..c62da7ed2 --- /dev/null +++ b/Src/java/tools/cql-formatter/src/test/resources/org/cqframework/cql/tools/formatter/git-issue-437.cql @@ -0,0 +1,6 @@ +define "Encounter With Principal Procedure of SCIP VTE Selected Surgery": + "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter + with ( "SCIP VTE Selected Surgery" Procedure + where Procedure.rank = 1 //in "Principal" + ) SelectedSCIPProcedure + such that SelectedSCIPProcedure.relevantPeriod during QualifyingEncounter.relevantPeriod \ No newline at end of file