@@ -24,74 +24,74 @@ trait SignatureBuilder extends ScalaSignatureUtils {
24
24
def memberName (name : String , dri : DRI ) = text(name)
25
25
26
26
def list [E ](
27
- elements : Seq [E ],
28
- prefix : String = " " ,
29
- suffix : String = " " ,
30
- separator : String = " , " ,
31
- )(
32
- elemOp : (SignatureBuilder , E ) => SignatureBuilder
33
- ): SignatureBuilder = elements match {
34
- case Nil => this
35
- case head :: tail =>
36
- tail.foldLeft(elemOp(text(prefix), head))((b, e) => elemOp(b.text(separator), e)).text(suffix)
37
- }
27
+ elements : Seq [E ],
28
+ prefix : String = " " ,
29
+ suffix : String = " " ,
30
+ separator : String = " , " ,
31
+ )(
32
+ elemOp : (SignatureBuilder , E ) => SignatureBuilder
33
+ ): SignatureBuilder = elements match {
34
+ case Nil => this
35
+ case head :: tail =>
36
+ tail.foldLeft(elemOp(text(prefix), head))((b, e) => elemOp(b.text(separator), e)).text(suffix)
37
+ }
38
38
39
39
def annotationsBlock (d : Member ): SignatureBuilder =
40
- d.annotations.foldLeft(this ){ (bdr, annotation) => bdr.buildAnnotation(annotation)}
41
-
42
- def annotationsInline (d : Parameter ): SignatureBuilder =
43
- d.annotations.foldLeft(this ){ (bdr, annotation) => bdr.buildAnnotation(annotation) }
40
+ d.annotations.foldLeft(this ){ (bdr, annotation) => bdr.buildAnnotation(annotation)}
44
41
45
- def annotationsInline (t : TypeParameter ): SignatureBuilder =
46
- t .annotations.foldLeft(this ){ (bdr, annotation) => bdr.buildAnnotation(annotation) }
42
+ def annotationsInline (d : Parameter ): SignatureBuilder =
43
+ d .annotations.foldLeft(this ){ (bdr, annotation) => bdr.buildAnnotation(annotation) }
47
44
48
- private def buildAnnotation ( a : Annotation ): SignatureBuilder =
49
- text( " @ " ).driLink(a.dri.location.split( '.' ).last, a.dri).buildAnnotationParams(a).text( " " )
45
+ def annotationsInline ( t : TypeParameter ): SignatureBuilder =
46
+ t.annotations.foldLeft( this ){ (bdr, annotation) => bdr.buildAnnotation(annotation) }
50
47
51
- private def buildAnnotationParams (a : Annotation ): SignatureBuilder =
52
- if ! a.params.isEmpty then
53
- val params = a.params.filterNot {
54
- case Annotation .LinkParameter (_, _, text) => text == " _"
55
- case _ => false
56
- }
57
- list(params, " (" , " )" , " , " ){ (bdr, param) => bdr.buildAnnotationParameter(param)}
58
- else this
48
+ private def buildAnnotation (a : Annotation ): SignatureBuilder =
49
+ text(" @" ).driLink(a.dri.location.split('.' ).last, a.dri).buildAnnotationParams(a).text(" " )
59
50
60
- private def addParameterName (txt : Option [String ]): SignatureBuilder = txt match {
61
- case Some (name) => this .text(s " $name = " )
62
- case _ => this
51
+ private def buildAnnotationParams (a : Annotation ): SignatureBuilder =
52
+ if ! a.params.isEmpty then
53
+ val params = a.params.filterNot {
54
+ case Annotation .LinkParameter (_, _, text) => text == " _"
55
+ case _ => false
63
56
}
57
+ list(params, " (" , " )" , " , " ){ (bdr, param) => bdr.buildAnnotationParameter(param)}
58
+ else this
64
59
65
- private def buildAnnotationParameter (a : Annotation .AnnotationParameter ): SignatureBuilder = a match {
66
- case Annotation .PrimitiveParameter (name, value) =>
67
- addParameterName(name).text(value)
68
- case Annotation .LinkParameter (name, dri, text) =>
69
- addParameterName(name).driLink(text, dri)
70
- case Annotation .UnresolvedParameter (name, value) =>
71
- addParameterName(name).text(value)
72
- }
60
+ private def addParameterName (txt : Option [String ]): SignatureBuilder = txt match {
61
+ case Some (name) => this .text(s " $name = " )
62
+ case _ => this
63
+ }
73
64
74
- def modifiersAndVisibility (t : Member , kind : String ) =
75
- val (prefixMods, suffixMods) = t.modifiers.partition(_.prefix)
76
- val all = prefixMods.map(_.name) ++ Seq (t.visibility.asSignature) ++ suffixMods.map(_.name)
65
+ private def buildAnnotationParameter (a : Annotation .AnnotationParameter ): SignatureBuilder = a match {
66
+ case Annotation .PrimitiveParameter (name, value) =>
67
+ addParameterName(name).text(value)
68
+ case Annotation .LinkParameter (name, dri, text) =>
69
+ addParameterName(name).driLink(text, dri)
70
+ case Annotation .UnresolvedParameter (name, value) =>
71
+ addParameterName(name).text(value)
72
+ }
77
73
78
- text(all.toSignatureString()).text(kind + " " )
74
+ def modifiersAndVisibility (t : Member , kind : String ) =
75
+ val (prefixMods, suffixMods) = t.modifiers.partition(_.prefix)
76
+ val all = prefixMods.map(_.name) ++ Seq (t.visibility.asSignature) ++ suffixMods.map(_.name)
79
77
80
- def generics (on : Seq [TypeParameter ]) = list(on.toList, " [" , " ]" ){ (bdr, e) =>
81
- bdr.annotationsInline(e).text(e.variance).memberName(e.name, e.dri).signature(e.signature)
82
- }
78
+ text(all.toSignatureString()).text(kind + " " )
83
79
84
- def functionParameters (params : Seq [ParametersList ]) =
85
- if params.isEmpty then this .text(" " )
86
- else if params.size == 1 && params(0 ).parameters == Nil then this .text(" ()" )
87
- else this .list(params, separator = " " ){ (bld, pList) =>
88
- bld.list(pList.parameters, s " ( ${pList.modifiers}" , " )" ){ (bld, p) =>
89
- val annotationsAndModifiers = bld.annotationsInline(p)
90
- .text(p.modifiers)
91
- val name = p.name.fold(annotationsAndModifiers)(annotationsAndModifiers.memberName(_, p.dri).text(" : " ))
92
- name.signature(p.signature)
93
- }
80
+ def generics (on : Seq [TypeParameter ]) = list(on.toList, " [" , " ]" ){ (bdr, e) =>
81
+ bdr.annotationsInline(e).text(e.variance).memberName(e.name, e.dri).signature(e.signature)
82
+ }
83
+
84
+ def functionParameters (params : Seq [ParametersList ]) =
85
+ if params.isEmpty then this .text(" " )
86
+ else if params.size == 1 && params(0 ).parameters == Nil then this .text(" ()" )
87
+ else this .list(params, separator = " " ){ (bld, pList) =>
88
+ bld.list(pList.parameters, s " ( ${pList.modifiers}" , " )" ){ (bld, p) =>
89
+ val annotationsAndModifiers = bld.annotationsInline(p)
90
+ .text(p.modifiers)
91
+ val name = p.name.fold(annotationsAndModifiers)(annotationsAndModifiers.memberName(_, p.dri).text(" : " ))
92
+ name.signature(p.signature)
94
93
}
94
+ }
95
95
}
96
96
97
97
trait ScalaSignatureUtils :
0 commit comments