Implement closing-block procedure without relying on missed_span module #3691
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.
In this PR I have updated
close_block
so that it does not rely onmissed_spans
when dealing with the comment between the last statement and the closing brace. This fixes some issues related to the block formatting: see the commits that update tests for detail.The background and the motivation of this PR:
missed_spans
is a necessary evil for recovering unformattable code and formatting missing comments. However, it should be the last resort since it's extremely complicated and buggish, especially on handling comments. Also, it's nigh-impossible to implementblank_lines_lower_bound
andblank_lines_upper_bound
correctly if we rely onmissed_spans
for handling comments between items, statements and blocks.The current implementation is not really well-thought, adding a better abstraction will be future work. I am planning to do it on fixing
blank_lines_lower_bound
.