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