Skip to content

Commit

Permalink
Router: handle comma in repeated enum cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jan 15, 2022
1 parent b762f37 commit eae19b9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,11 @@ class Router(formatOps: FormatOps) {
Split(Space, 0),
Split(Newline, 1).withIndent(indent, right, After)
)
case _: Defn.RepeatedEnumCase if {
if (!style.newlines.sourceIgnored) newlines != 0
else style.newlines.source eq Newlines.unfold
} =>
Seq(Split(Newline, 0))
case _ =>
Seq(
Split(Space, 0),
Expand Down
9 changes: 6 additions & 3 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3330,9 +3330,12 @@ enum SerializedField extends jl.Enum[SerializedField] {
case UNKNOWN, // represents a field code we didn't recognize
END_MARKER, // end of a list of fields
ROOT_VALUE, // Fields at the root
ROOT_WAS_CONFIG, VALUE_DATA, // Fields that make up a value
VALUE_ORIGIN, ORIGIN_DESCRIPTION, // Fields that make up an origin
ORIGIN_LINE_NUMBER, ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL,
ROOT_WAS_CONFIG,
VALUE_DATA, // Fields that make up a value
VALUE_ORIGIN,
ORIGIN_DESCRIPTION, // Fields that make up an origin
ORIGIN_LINE_NUMBER,
ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL,
ORIGIN_COMMENTS, ORIGIN_NULL_URL, ORIGIN_NULL_COMMENTS, ORIGIN_RESOURCE,
ORIGIN_NULL_RESOURCE
}
Original file line number Diff line number Diff line change
Expand Up @@ -3319,9 +3319,12 @@ enum SerializedField extends jl.Enum[SerializedField] {
case UNKNOWN, // represents a field code we didn't recognize
END_MARKER, // end of a list of fields
ROOT_VALUE, // Fields at the root
ROOT_WAS_CONFIG, VALUE_DATA, // Fields that make up a value
VALUE_ORIGIN, ORIGIN_DESCRIPTION, // Fields that make up an origin
ORIGIN_LINE_NUMBER, ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL,
ROOT_WAS_CONFIG,
VALUE_DATA, // Fields that make up a value
VALUE_ORIGIN,
ORIGIN_DESCRIPTION, // Fields that make up an origin
ORIGIN_LINE_NUMBER,
ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL,
ORIGIN_COMMENTS, ORIGIN_NULL_URL, ORIGIN_NULL_COMMENTS, ORIGIN_RESOURCE,
ORIGIN_NULL_RESOURCE
}
Original file line number Diff line number Diff line change
Expand Up @@ -3421,9 +3421,17 @@ enum SerializedField extends jl.Enum[SerializedField] {
case UNKNOWN, // represents a field code we didn't recognize
END_MARKER, // end of a list of fields
ROOT_VALUE, // Fields at the root
ROOT_WAS_CONFIG, VALUE_DATA, // Fields that make up a value
VALUE_ORIGIN, ORIGIN_DESCRIPTION, // Fields that make up an origin
ORIGIN_LINE_NUMBER, ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL,
ORIGIN_COMMENTS, ORIGIN_NULL_URL, ORIGIN_NULL_COMMENTS, ORIGIN_RESOURCE,
ROOT_WAS_CONFIG,
VALUE_DATA, // Fields that make up a value
VALUE_ORIGIN,
ORIGIN_DESCRIPTION, // Fields that make up an origin
ORIGIN_LINE_NUMBER,
ORIGIN_END_LINE_NUMBER,
ORIGIN_TYPE,
ORIGIN_URL,
ORIGIN_COMMENTS,
ORIGIN_NULL_URL,
ORIGIN_NULL_COMMENTS,
ORIGIN_RESOURCE,
ORIGIN_NULL_RESOURCE
}

0 comments on commit eae19b9

Please sign in to comment.