diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java b/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java index c9890cb3..28e75970 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/interpreter/InterpreterController.java @@ -274,6 +274,7 @@ private void updateDependencies(CobolLine line) throws IOException { if (reader.isFlagSet(Constants.DATA_DIVISION)) { this.currentDataStructure = updateCurrentDataStructure(currentStatement, currentDataStructure); + line = line.convertCobolLinesToCobolLine(currentStatement); updateNumericFields(line); } diff --git a/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/CobolLine.java b/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/CobolLine.java index b23901ab..549681d0 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/CobolLine.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/CobolLine.java @@ -1,5 +1,7 @@ package org.openmainframeproject.cobolcheck.services.cobolLogic; +import org.openmainframeproject.cobolcheck.features.interpreter.StringTokenizerExtractor; + import java.util.Collection; import java.util.List; import java.util.Locale; @@ -111,4 +113,13 @@ private String removeSequenceNumberArea(String originalLine){ else return " " + originalLine.substring(index); } + + public CobolLine convertCobolLinesToCobolLine(List cobolLines) { + String line = ""; + for (CobolLine cobolLine : cobolLines){ + line += cobolLine.getUnNumberedString(); + } + TokenExtractor tokenExtractor = new StringTokenizerExtractor(); + return new CobolLine(line, tokenExtractor); + } } diff --git a/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/Interpreter.java b/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/Interpreter.java index e9f2e9cf..52d799d9 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/Interpreter.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/services/cobolLogic/Interpreter.java @@ -537,8 +537,18 @@ private static Integer determineCobolLevelNumber(String levelNumberString){ private static String[] extractStatementWords(List currentStatement){ String statementString = ""; - for(CobolLine loopLine: currentStatement){ - statementString += loopLine.getTrimmedString(); + boolean[] isContinuationLine = new boolean[currentStatement.size()]; + Arrays.fill(isContinuationLine, false); + for(int i = 1; i < currentStatement.size(); ++i) { + if(currentStatement.get(i).getTrimmedString().startsWith("-")){ + isContinuationLine[i] = true; + } + } + for(int i = 0; i < currentStatement.size(); ++i){ + statementString += currentStatement.get(i).getTrimmedString(); + if(!isContinuationLine[i]){ + statementString += " "; + } } statementString = statementString.trim().replace(Constants.PERIOD, ""); String[] statementWords = statementString.split("\\s+"); diff --git a/src/test/java/org/openmainframeproject/cobolcheck/InterpreterControllerTest.java b/src/test/java/org/openmainframeproject/cobolcheck/InterpreterControllerTest.java index 5aa9a6ee..8574c963 100644 --- a/src/test/java/org/openmainframeproject/cobolcheck/InterpreterControllerTest.java +++ b/src/test/java/org/openmainframeproject/cobolcheck/InterpreterControllerTest.java @@ -730,19 +730,19 @@ public void it_updates_numeric_fields() throws IOException { String str4 = " 05 OUTPUT-FILE-STATUS PIC XX."; String str5 = " 88 OUTPUT-OK VALUE '00'."; String str6 = " 05."; - String str7 = " 08 WS-COUNT PIC S9(5) COMP-3."; - String str8 = " 05 WS-DISPLAY-NUM2 PIC 9(04) OCCURS"; - String str9 = " 20."; - String str10 = " 05 TEMP-VAL PIC X(200) VALUE SPACES."; - String str11 = " 77 CHAR-CT PIC S9(3) COMP."; + String str7 = " 08 WS-COUNT "; + String str8 = " PIC S9(5) COMP-3."; + String str9 = " 05 WS-DISPLAY-NUM2 PIC 9(04) OCCURS"; + String str10 = " 20."; + String str11 = " 05 TEMP-VAL PIC X(200) VALUE SPACES."; + String str12 = " 77 CHAR-CT PIC S9(3) COMP."; - Mockito.when(mockedReader.readLine()).thenReturn(str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, null); + Mockito.when(mockedReader.readLine()).thenReturn(str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12, null); while (interpreterController.interpretNextLine() != null){ interpreterController.interpretNextLine(); } - assertEquals("PACKED_DECIMAL", interpreterController.getNumericFieldDataTypeFor("WS-COUNT").name()); assertEquals("DISPLAY_NUMERIC",