77//
88// Permission is hereby granted, free of charge, to any person
99// obtaining a copy of this software and associated documentation
10- // files (the " Software" ), to deal in the Software without
10+ // files (the “ Software” ), to deal in the Software without
1111// restriction, including without limitation the rights to use,
1212// copy, modify, merge, publish, distribute, sublicense, and/or
1313// sell copies of the Software, and to permit persons to whom the
1717// The above copyright notice and this permission notice shall be
1818// included in all copies or substantial portions of the Software.
1919//
20- // THE SOFTWARE IS PROVIDED " AS IS" , WITHOUT WARRANTY OF ANY KIND,
20+ // THE SOFTWARE IS PROVIDED “ AS IS” , WITHOUT WARRANTY OF ANY KIND,
2121// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2222// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2323// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -69,17 +69,19 @@ public struct Catch: CodeBlock {
6969 var catchItems : CatchItemListSyntax ?
7070 if let pattern = pattern {
7171 let patternSyntax : PatternSyntax
72-
72+
7373 if let enumCase = pattern as? EnumCase {
7474 if let associated = enumCase. caseAssociatedValue {
7575 // Handle EnumCase with associated value
7676 // Split the case name into type and case if needed
7777 let baseName = enumCase. caseName
7878 let baseParts = baseName. split ( separator: " . " )
79- let ( typeName, caseName) = baseParts. count == 2 ? ( String ( baseParts [ 0 ] ) , String ( baseParts [ 1 ] ) ) : ( " " , baseName)
79+ let ( typeName, caseName) =
80+ baseParts. count == 2 ? ( String ( baseParts [ 0 ] ) , String ( baseParts [ 1 ] ) ) : ( " " , baseName)
8081 // Build the pattern: Type.caseName(let associatedName)
8182 let memberAccess = MemberAccessExprSyntax (
82- base: typeName. isEmpty ? nil : ExprSyntax ( DeclReferenceExprSyntax ( baseName: . identifier( typeName) ) ) ,
83+ base: typeName. isEmpty
84+ ? nil : ExprSyntax ( DeclReferenceExprSyntax ( baseName: . identifier( typeName) ) ) ,
8385 dot: . periodToken( ) ,
8486 name: . identifier( caseName)
8587 )
@@ -91,7 +93,8 @@ public struct Catch: CodeBlock {
9193 pattern: PatternSyntax (
9294 ValueBindingPatternSyntax (
9395 bindingSpecifier: . keyword( . let, trailingTrivia: . space) ,
94- pattern: PatternSyntax ( IdentifierPatternSyntax ( identifier: . identifier( associated. name) ) )
96+ pattern: PatternSyntax (
97+ IdentifierPatternSyntax ( identifier: . identifier( associated. name) ) )
9598 )
9699 ) ,
97100 trailingComma: nil
@@ -103,7 +106,8 @@ public struct Catch: CodeBlock {
103106 let enumPattern = ExpressionPatternSyntax (
104107 expression: ExprSyntax (
105108 MemberAccessExprSyntax (
106- base: typeName. isEmpty ? nil : ExprSyntax ( DeclReferenceExprSyntax ( baseName: . identifier( typeName) ) ) ,
109+ base: typeName. isEmpty
110+ ? nil : ExprSyntax ( DeclReferenceExprSyntax ( baseName: . identifier( typeName) ) ) ,
107111 dot: . periodToken( ) ,
108112 name: . identifier( caseName)
109113 )
@@ -118,7 +122,8 @@ public struct Catch: CodeBlock {
118122 pattern: PatternSyntax (
119123 ValueBindingPatternSyntax (
120124 bindingSpecifier: . keyword( . let, trailingTrivia: . space) ,
121- pattern: PatternSyntax ( IdentifierPatternSyntax ( identifier: . identifier( associated. name) ) )
125+ pattern: PatternSyntax (
126+ IdentifierPatternSyntax ( identifier: . identifier( associated. name) ) )
122127 )
123128 ) ,
124129 trailingComma: nil
@@ -143,7 +148,8 @@ public struct Catch: CodeBlock {
143148 pattern: PatternSyntax (
144149 ValueBindingPatternSyntax (
145150 bindingSpecifier: . keyword( . let, trailingTrivia: . space) ,
146- pattern: PatternSyntax ( IdentifierPatternSyntax ( identifier: . identifier( associated. name) ) )
151+ pattern: PatternSyntax (
152+ IdentifierPatternSyntax ( identifier: . identifier( associated. name) ) )
147153 )
148154 )
149155 )
@@ -174,7 +180,7 @@ public struct Catch: CodeBlock {
174180 )
175181 )
176182 }
177-
183+
178184 catchItems = CatchItemListSyntax ( [
179185 CatchItemSyntax ( pattern: patternSyntax)
180186 ] )
@@ -208,4 +214,4 @@ public struct Catch: CodeBlock {
208214 public var syntax : SyntaxProtocol {
209215 catchClauseSyntax
210216 }
211- }
217+ }
0 commit comments