From 5feb40eda2543fbb00bdd8efec52d6550bdebdcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Andersen?= Date: Thu, 4 Apr 2024 20:11:56 +0200 Subject: [PATCH] Update CobolGenerator.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Søren Andersen --- .../testSuiteParser/CobolGenerator.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java index 5c266f2f..5ab11a88 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java @@ -75,17 +75,28 @@ static void addStartAndEndTags(List lines){ lines.add(getInjectEndTagComment()); } - static List generateWhenOtherLines(String identifier, String type, List commentLines, List bodyLines){ + static List generateWhenOtherLines(String identifier, String type, List commentLines, List bodyLines) { List lines = new ArrayList<>(); - if(type.equals(Constants.SECTION_TOKEN)) + if (type.equals(Constants.SECTION_TOKEN)) lines.add(String.format(WHEN_OTHER_SECTION_HEADER_FORMAT, identifier)); - else lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier)); + else + lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier)); + if (commentLines != null) lines.addAll(commentLines); - if (bodyLines != null) + + if (bodyLines != null) { lines.addAll(bodyLines); - lines.add(ENDING_PERIOD); + // Check if the last line in bodyLines ends with a period + if (!bodyLines.get(bodyLines.size() - 1).endsWith(".")) { + lines.add(ENDING_PERIOD); + } + } else { + // If bodyLines is null, add ENDING_PERIOD + lines.add(ENDING_PERIOD); + } return lines; } + }