Support trailing commas in parameter declarations. Include newline after trailing comma. #296
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.
Hi, the initial trailing comma support (#262) is very limited. Even the "expected" code in the test case is not valid (it expects the trailing comma in the same line as closing paren which is forbidden in Scala). The other problem with current master is that whenever the trailing comma appears in parameter declaration (eg. case class fields or function declaration), an assertion fails with
java.lang.IllegalArgumentException: requirement failed: Parse tokens differ from expected.
(SpecificFormatter.scala:54
).My commit fixes both of these issues.
tokens
field in classesImportClause
andParamClause
in AstNodes.scala. This also prevents the trailing comma from disappearing in the formatted code.DanglingCloseParenthesis
would not normally result in a newline. This is to prevent Scala compiler errors.I added a bunch of test cases.
Please let me know if you can merge this and make a new release, so that this fix could be propagated to sbt-scalariform.