Refactor 'Crystal::Formatter#format_def_args' #4992
Merged
+116
−169
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.
Fix #1924
Close #4980, #4990
This is just refactoring but it contains many bug fixes and improvements. These come from refactoring effects, so I cannot separate them from this.
Bug fixes and improvements:
work formatting double splat with trailing comma (Correctly work formatting double splat argument with trailing comma #4990)
work formatting when there is newline or comment between argument and comma.
is formatted to correctly:
format arguments with 2 spaces indentation (Formatter indentation not matching with what I'd expect #1924)
distinguish comment followed on newline and argument. The formatter keeps this for example:
And, perhaps there are other bug fixes and improvements because
format_def_args
has too many bugs to remember.Refactoring is so great!!
I apologize to @asterite and other members for big commit. But I'm sure this is the best solution because fundamental problem is
format_def_args
is so complex. If we resolved issues explained in above separately, thenformat_def_args
would becomes more complex and it means refactoring becomes harder. I don't hope such a thing.Please read the source code. I believe it is clearer and simpler then past.
Thank you.