Correct newline style in json emitter #4743
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested fix for issue #4273. The main change is in
add_misformatted_file()
to use the proper newline styles in each of theoriginal/expected
fields in eachMismatchedBlock
. The original code"s newline style is used fororiginal
while the confignewline_style
is used forexpected
.The other changes are to add parameters to functions/structures to allow passing the config
newline_style
value toadd_misformatted_file()
. The new parameters required adding them to function calls in some of theemitter/json.rs
test cases. In all these cases default values used.Test new cases were added to
emitter/json.rs
, assuming there is no way to verify the json output using test cases files.The approach taken is that
add_misformatted_file()
gets the proper newline strings and continues to add the newline to the end of theoriginal/expected
strings, using these values instead of constant\n
. A simpler alternative may have been to continue adding\n
to the end of the strings and then callapply_newline_style()
to convert them to the proper newline style. However, that approach seem to be problematic from performance point of view, as the call is done separately for eachoriginal/expected
field for eachMismatchedBlock
.(This is probably the last new PR I am submitting in a while. I know it is a lot of effort and time to review and verify the changes, but I had the time and energy lately to try resolving some of the open issues. Still, if there are issues I can help resolving I will be happy to do that.)