@@ -155,16 +155,15 @@ public final class ImportSwiftMacros {
155155 }
156156 }
157157
158-
159158 /// Extracts the jsName argument value from a @JSSetter attribute, if present.
160159 static func extractJSName( from attribute: AttributeSyntax ) -> String ? {
161160 guard let arguments = attribute. arguments? . as ( LabeledExprListSyntax . self) else {
162161 return nil
163162 }
164163 for argument in arguments {
165164 if argument. label? . text == " jsName " ,
166- let stringLiteral = argument. expression. as ( StringLiteralExprSyntax . self) ,
167- let segment = stringLiteral. segments. first? . as ( StringSegmentSyntax . self)
165+ let stringLiteral = argument. expression. as ( StringLiteralExprSyntax . self) ,
166+ let segment = stringLiteral. segments. first? . as ( StringSegmentSyntax . self)
168167 {
169168 return segment. content. text
170169 }
@@ -217,7 +216,8 @@ public final class ImportSwiftMacros {
217216 jsSetter: AttributeSyntax ,
218217 enclosingTypeName: String ?
219218 ) -> SetterValidationResult ? {
220- guard let effects = validateEffects ( node. signature. effectSpecifiers, node: node, attributeName: " JSSetter " ) else {
219+ guard let effects = validateEffects ( node. signature. effectSpecifiers, node: node, attributeName: " JSSetter " )
220+ else {
221221 return nil
222222 }
223223
@@ -270,7 +270,8 @@ public final class ImportSwiftMacros {
270270 return ( propertyName: propertyName, functionBaseName: functionBaseName)
271271 }
272272
273- let rawFunctionName = functionName. hasPrefix ( " ` " ) && functionName. hasSuffix ( " ` " ) && functionName. count > 2
273+ let rawFunctionName =
274+ functionName. hasPrefix ( " ` " ) && functionName. hasSuffix ( " ` " ) && functionName. count > 2
274275 ? String ( functionName. dropFirst ( ) . dropLast ( ) )
275276 : functionName
276277
@@ -367,7 +368,8 @@ public final class ImportSwiftMacros {
367368
368369 private func handleTopLevelFunction( _ node: FunctionDeclSyntax ) -> SyntaxVisitorContinueKind {
369370 if AttributeChecker . hasJSFunctionAttribute ( node. attributes) ,
370- let function = parseFunction ( node, enclosingTypeName: nil , isStaticMember: true ) {
371+ let function = parseFunction ( node, enclosingTypeName: nil , isStaticMember: true )
372+ {
371373 importedFunctions. append ( function)
372374 return . skipChildren
373375 }
@@ -392,9 +394,13 @@ public final class ImportSwiftMacros {
392394 ) -> Bool {
393395 if AttributeChecker . hasJSFunctionAttribute ( node. attributes) {
394396 if isStaticMember {
395- parseFunction ( node, enclosingTypeName: typeName, isStaticMember: true ) . map { importedFunctions. append ( $0) }
397+ parseFunction ( node, enclosingTypeName: typeName, isStaticMember: true ) . map {
398+ importedFunctions. append ( $0)
399+ }
396400 } else {
397- parseFunction ( node, enclosingTypeName: typeName, isStaticMember: false ) . map { type. methods. append ( $0) }
401+ parseFunction ( node, enclosingTypeName: typeName, isStaticMember: false ) . map {
402+ type. methods. append ( $0)
403+ }
398404 }
399405 return true
400406 }
@@ -404,11 +410,13 @@ public final class ImportSwiftMacros {
404410 errors. append (
405411 DiagnosticError (
406412 node: node,
407- message: " @JSSetter is not supported for static members. Use it only for instance members in @JSClass types. "
413+ message:
414+ " @JSSetter is not supported for static members. Use it only for instance members in @JSClass types. "
408415 )
409416 )
410417 } else if let jsSetter = AttributeChecker . firstJSSetterAttribute ( node. attributes) ,
411- let setter = parseSetterSkeleton ( jsSetter, node, enclosingTypeName: typeName) {
418+ let setter = parseSetterSkeleton ( jsSetter, node, enclosingTypeName: typeName)
419+ {
412420 type. setters. append ( setter)
413421 }
414422 return true
@@ -440,7 +448,8 @@ public final class ImportSwiftMacros {
440448 errors. append (
441449 DiagnosticError (
442450 node: node,
443- message: " @JSGetter is not supported for static members. Use it only for instance members in @JSClass types. "
451+ message:
452+ " @JSGetter is not supported for static members. Use it only for instance members in @JSClass types. "
444453 )
445454 )
446455 } else if let getter = parseGetterSkeleton ( node, enclosingTypeName: typeName) {
@@ -481,29 +490,32 @@ public final class ImportSwiftMacros {
481490 }
482491 }
483492
484-
485493 // MARK: - Member Collection
486494
487495 private func collectStaticMembers( in members: MemberBlockItemListSyntax , typeName: String ) {
488496 for member in members {
489497 if let function = member. decl. as ( FunctionDeclSyntax . self) {
490498 if AttributeChecker . hasJSFunctionAttribute ( function. attributes) ,
491- let parsed = parseFunction ( function, enclosingTypeName: typeName, isStaticMember: true ) {
499+ let parsed = parseFunction ( function, enclosingTypeName: typeName, isStaticMember: true )
500+ {
492501 importedFunctions. append ( parsed)
493502 } else if AttributeChecker . hasJSSetterAttribute ( function. attributes) {
494503 errors. append (
495504 DiagnosticError (
496505 node: function,
497- message: " @JSSetter is not supported for static members. Use it only for instance members in @JSClass types. "
506+ message:
507+ " @JSSetter is not supported for static members. Use it only for instance members in @JSClass types. "
498508 )
499509 )
500510 }
501511 } else if let variable = member. decl. as ( VariableDeclSyntax . self) ,
502- AttributeChecker . hasJSGetterAttribute ( variable. attributes) {
512+ AttributeChecker . hasJSGetterAttribute ( variable. attributes)
513+ {
503514 errors. append (
504515 DiagnosticError (
505516 node: variable,
506- message: " @JSGetter is not supported for static members. Use it only for instance members in @JSClass types. "
517+ message:
518+ " @JSGetter is not supported for static members. Use it only for instance members in @JSClass types. "
507519 )
508520 )
509521 }
@@ -516,7 +528,10 @@ public final class ImportSwiftMacros {
516528 _ initializer: InitializerDeclSyntax ,
517529 typeName: String
518530 ) -> ImportedConstructorSkeleton ? {
519- guard validateEffects ( initializer. signature. effectSpecifiers, node: initializer, attributeName: " JSFunction " ) != nil else {
531+ guard
532+ validateEffects ( initializer. signature. effectSpecifiers, node: initializer, attributeName: " JSFunction " )
533+ != nil
534+ else {
520535 return nil
521536 }
522537 return ImportedConstructorSkeleton (
@@ -532,7 +547,8 @@ public final class ImportSwiftMacros {
532547 enclosingTypeName: String ? ,
533548 isStaticMember: Bool
534549 ) -> ImportedFunctionSkeleton ? {
535- guard validateEffects ( node. signature. effectSpecifiers, node: node, attributeName: " JSFunction " ) != nil else {
550+ guard validateEffects ( node. signature. effectSpecifiers, node: node, attributeName: " JSFunction " ) != nil
551+ else {
536552 return nil
537553 }
538554
@@ -562,15 +578,15 @@ public final class ImportSwiftMacros {
562578 )
563579 }
564580
565-
566581 /// Extracts property info from a VariableDeclSyntax (binding, identifier, type)
567582 private func extractPropertyInfo(
568583 _ node: VariableDeclSyntax ,
569584 errorMessage: String = " @JSGetter must declare a single stored property with an explicit type. "
570585 ) -> ( identifier: IdentifierPatternSyntax , type: TypeSyntax ) ? {
571586 guard let binding = node. bindings. first,
572- let identifier = binding. pattern. as ( IdentifierPatternSyntax . self) ,
573- let typeAnnotation = binding. typeAnnotation else {
587+ let identifier = binding. pattern. as ( IdentifierPatternSyntax . self) ,
588+ let typeAnnotation = binding. typeAnnotation
589+ else {
574590 errors. append ( DiagnosticError ( node: node, message: errorMessage) )
575591 return nil
576592 }
@@ -605,11 +621,13 @@ public final class ImportSwiftMacros {
605621 }
606622
607623 let functionName = node. name. text
608- guard let ( propertyName, functionBaseName) = PropertyNameResolver . resolve (
609- functionName: functionName,
610- jsName: validation. jsName,
611- normalizeIdentifier: normalizeIdentifier
612- ) else {
624+ guard
625+ let ( propertyName, functionBaseName) = PropertyNameResolver . resolve (
626+ functionName: functionName,
627+ jsName: validation. jsName,
628+ normalizeIdentifier: normalizeIdentifier
629+ )
630+ else {
613631 return nil
614632 }
615633
@@ -621,7 +639,6 @@ public final class ImportSwiftMacros {
621639 )
622640 }
623641
624-
625642 // MARK: - Type and Parameter Parsing
626643
627644 private func parseParameters(
@@ -648,7 +665,6 @@ public final class ImportSwiftMacros {
648665 }
649666 }
650667
651-
652668 private func parseType( _ type: TypeSyntax , enclosingTypeName: String ? ) -> BridgeType {
653669 guard let identifier = type. as ( IdentifierTypeSyntax . self) else {
654670 errors. append (
0 commit comments