Skip to content

Commit 42f0fc9

Browse files
committed
Unified: Simplify enum case raw values
An optional capture takes care of the potentially missing value (meaning we don't need a separate rule for it).
1 parent f0f22ab commit 42f0fc9

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

  • unified/extractor/src/languages/swift

‎unified/extractor/src/languages/swift/swift.rs‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
539539
}
540540
),
541541
rule!(
542-
(enumCaseElement name: @@name rawValue: (initializerClause value: @val))
542+
(enumCaseElement
543+
name: @@name
544+
rawValue: (initializerClause value: @val)?)
543545
=>
544546
(variable_declaration
545547
modifier: {ctx.outer_modifiers.clone()}
@@ -548,15 +550,6 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
548550
pattern: (identifier #{name})
549551
value: {val})
550552
),
551-
rule!(
552-
(enumCaseElement name: @@name)
553-
=>
554-
(variable_declaration
555-
modifier: {ctx.outer_modifiers.clone()}
556-
modifier: [(modifier "chained_declaration") if { ctx.is_chained }]
557-
modifier: (modifier "enum_case")
558-
pattern: (identifier #{name}))
559-
),
560553
// Enum cases. A single `case` declaration may carry modifiers
561554
// (e.g. `indirect`) and list several comma-separated elements; each
562555
// becomes its own declaration carrying those shared modifiers, and

0 commit comments

Comments
 (0)