Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve linenumbers from original source to enable a more robust met… #350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public String interpretNextLine() {
}

// Current line might change from when it was originally read
return reader.getCurrentLine().getUnNumberedString();
return reader.getCurrentLine().getOriginalString();
}

public void closeReader() {
Expand Down Expand Up @@ -606,7 +606,7 @@ public void removeSectionOrParagraphLines(){
public void addSectionOrParagraphLine(){
if(Interpreter.shouldLineBeStubbed(reader.getCurrentLine(), reader.getState()))
sectionOrParagraph.addLine(StringHelper.stubLine(reader.getCurrentLine().getUnNumberedString(), stubTag));
else sectionOrParagraph.addLine(reader.getCurrentLine().getUnNumberedString());
else sectionOrParagraph.addLine(reader.getCurrentLine().getOriginalString());
}

public void addSectionOrParagraphLine(String line){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ public class CobolGenerator {



static List<String> generateSectionLines(String identifier, List<String> commentLines, List<String> bodyLines){
List<String> lines = new ArrayList<>();
lines.add(String.format(SECTION_HEADER_FORMAT, identifier));
if (commentLines != null)
lines.addAll(commentLines);
if (bodyLines != null) {
lines.addAll(bodyLines);
// 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;
}

static List<String> generateParagraphLines(String identifier, List<String> commentLines, List<String> bodyLines){
List<String> lines = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ private String tryInsertEndEvaluateAtMockedCompomentEnd(String sourceLine) throw
}
}
return sourceLine;

}


/**
* Writes the given line to the output file. If a multiline statement has been read, this will
* be written instead (this statement will include the line). Comments out lines and statements
Expand Down Expand Up @@ -248,6 +250,10 @@ private void writeWhenOtherSectionOrParagraph(String sourceLine) throws IOExcep
private void echoingSourceLineToOutput(String sourceLine){
try{
if(interpreter.isInsideSectionOrParagraphMockBody()){
// Avoid giving mocked section ending period line numbers, as they would be duplicates
if (sourceLine.length() > 6 && sourceLine.substring(6).trim().equals(".")) {
sourceLine = " " + sourceLine.substring(6);
}
interpreter.addSectionOrParagraphLine();
}
sourceLine = tryInsertEndEvaluateAtMockedCompomentEnd(sourceLine);
Expand Down
Loading