@@ -529,23 +529,22 @@ struct VariadicsGenerator: ParsableCommand {
529
529
let matchType = arity == 0
530
530
? " W "
531
531
: " (W, " + ( 0 ..< arity) . map { " C \( $0) " } . joined ( separator: " , " ) + " ) "
532
- func newMatchType( transformed: Bool ) -> String {
533
- let newCaptureType = transformed ? " NewCapture " : baseMatchTypeName
532
+ func newMatchType( newCaptureType: String ) -> String {
534
533
return arity == 0
535
- ? " (W , \( newCaptureType) ) "
536
- : " (W , \( newCaptureType) , " + ( 0 ..< arity) . map { " C \( $0) " } . joined ( separator: " , " ) + " ) "
534
+ ? " ( \( baseMatchTypeName ) , \( newCaptureType) ) "
535
+ : " ( \( baseMatchTypeName ) , \( newCaptureType) , " + ( 0 ..< arity) . map { " C \( $0) " } . joined ( separator: " , " ) + " ) "
537
536
}
538
537
let whereClause = " where R. \( matchAssociatedTypeName) == \( matchType) "
539
538
output ( """
540
539
// MARK: - Non-builder capture arity \( arity)
541
540
542
- public func capture< \( genericParams) >(_ component: R) -> \( regexTypeName) < \( newMatchType ( transformed : false ) ) > \( whereClause) {
541
+ public func capture< \( genericParams) >(_ component: R) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " W " ) ) > \( whereClause) {
543
542
.init(node: .group(.capture, component.regex.root))
544
543
}
545
544
546
545
public func capture< \( genericParams) , NewCapture>(
547
546
_ component: R, transform: @escaping (Substring) -> NewCapture
548
- ) -> \( regexTypeName) < \( newMatchType ( transformed : true ) ) > \( whereClause) {
547
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " NewCapture " ) ) > \( whereClause) {
549
548
.init(node: .groupTransform(
550
549
.capture,
551
550
component.regex.root,
@@ -556,7 +555,7 @@ struct VariadicsGenerator: ParsableCommand {
556
555
557
556
public func tryCapture< \( genericParams) , NewCapture>(
558
557
_ component: R, transform: @escaping (Substring) throws -> NewCapture
559
- ) -> \( regexTypeName) < \( newMatchType ( transformed : true ) ) > \( whereClause) {
558
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " NewCapture " ) ) > \( whereClause) {
560
559
.init(node: .groupTransform(
561
560
.capture,
562
561
component.regex.root,
@@ -567,7 +566,7 @@ struct VariadicsGenerator: ParsableCommand {
567
566
568
567
public func tryCapture< \( genericParams) , NewCapture>(
569
568
_ component: R, transform: @escaping (Substring) -> NewCapture?
570
- ) -> \( regexTypeName) < \( newMatchType ( transformed : true ) ) > \( whereClause) {
569
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " NewCapture " ) ) > \( whereClause) {
571
570
.init(node: .groupTransform(
572
571
.capture,
573
572
component.regex.root,
@@ -580,14 +579,14 @@ struct VariadicsGenerator: ParsableCommand {
580
579
581
580
public func capture< \( genericParams) >(
582
581
@RegexBuilder _ component: () -> R
583
- ) -> \( regexTypeName) < \( newMatchType ( transformed : false ) ) > \( whereClause) {
582
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " W " ) ) > \( whereClause) {
584
583
.init(node: .group(.capture, component().regex.root))
585
584
}
586
585
587
586
public func capture< \( genericParams) , NewCapture>(
588
587
@RegexBuilder _ component: () -> R,
589
588
transform: @escaping (Substring) -> NewCapture
590
- ) -> \( regexTypeName) < \( newMatchType ( transformed : true ) ) > \( whereClause) {
589
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " NewCapture " ) ) > \( whereClause) {
591
590
.init(node: .groupTransform(
592
591
.capture,
593
592
component().regex.root,
@@ -599,7 +598,7 @@ struct VariadicsGenerator: ParsableCommand {
599
598
public func tryCapture< \( genericParams) , NewCapture>(
600
599
@RegexBuilder _ component: () -> R,
601
600
transform: @escaping (Substring) throws -> NewCapture
602
- ) -> \( regexTypeName) < \( newMatchType ( transformed : true ) ) > \( whereClause) {
601
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " NewCapture " ) ) > \( whereClause) {
603
602
.init(node: .groupTransform(
604
603
.capture,
605
604
component().regex.root,
@@ -611,7 +610,7 @@ struct VariadicsGenerator: ParsableCommand {
611
610
public func tryCapture< \( genericParams) , NewCapture>(
612
611
@RegexBuilder _ component: () -> R,
613
612
transform: @escaping (Substring) -> NewCapture?
614
- ) -> \( regexTypeName) < \( newMatchType ( transformed : true ) ) > \( whereClause) {
613
+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType : " NewCapture " ) ) > \( whereClause) {
615
614
.init(node: .groupTransform(
616
615
.capture,
617
616
component().regex.root,
0 commit comments