@@ -43,7 +43,7 @@ abstract class SignatureTest(
43
43
44
44
val unexpected = unexpectedFromSources.flatMap(actualSignatures.get).flatten
45
45
val expectedButNotFound = expectedFromSources.flatMap {
46
- case (k, v) => findMissingSingatures (v, actualSignatures.getOrElse(k, Nil ))
46
+ case (k, v) => findMissingSignatures (v, actualSignatures.getOrElse(k, Nil ))
47
47
}
48
48
49
49
val missingReport = Option .when(! ignoreMissingSignatures && ! expectedButNotFound.isEmpty)
@@ -75,26 +75,21 @@ abstract class SignatureTest(
75
75
private val unexpectedRegex = raw " (.+)//unexpected " .r
76
76
private val identifierRegex = raw " ^\s*(`.*`|(?:\w+)(?:_[^\[\(\s]+)|\w+|[^\[\(\s]+) " .r
77
77
78
- private def findMissingSingatures (expected : Seq [String ], actual : Seq [String ]): Set [String ] =
78
+ private def findMissingSignatures (expected : Seq [String ], actual : Seq [String ]): Set [String ] =
79
79
expected.toSet &~ actual.toSet
80
80
81
81
extension (s : String )
82
82
private def startWithAnyOfThese (c : String * ) = c.exists(s.startsWith)
83
83
private def compactWhitespaces = whitespaceRegex.replaceAllIn(s, " " )
84
84
85
- private var counter = 0
86
85
private def findName (signature : String , kinds : Seq [String ]): Option [String ] =
87
86
for
88
87
kindMatch <- kinds.flatMap(k => s " \\ b $k\\ b " .r.findFirstMatchIn(signature)).headOption
88
+ kind <- Option (kindMatch.group(0 )) // to filter out nulls
89
89
afterKind <- Option (kindMatch.after(0 )) // to filter out nulls
90
- nameMatch <- identifierRegex.findFirstMatchIn(
91
- if kindMatch.group(0 ).contains(" extension" )
92
- then
93
- signature
94
- else
95
- afterKind
96
- )
97
- yield nameMatch.group(1 )
90
+ name <- if kind.contains(" extension" ) then Some (signature) // The name of an extension will always be the signature itself
91
+ else identifierRegex.findFirstMatchIn(afterKind).map(_.group(1 ))
92
+ yield name
98
93
99
94
private def signaturesFromSources (source : Source , kinds : Seq [String ]): Seq [SignatureRes ] =
100
95
source.getLines.map(_.trim)
@@ -118,9 +113,7 @@ abstract class SignatureTest(
118
113
def processFile (path : Path ): Unit = if filterFunc(path) then
119
114
val document = Jsoup .parse(IO .read(path))
120
115
val documentable = document.select(" .groupHeader" ).forEach { element =>
121
- val signature = element.select(" .groupHeader" ).eachText.asScala.mkString(" " )
122
- val all = s " $signature"
123
- signatures += all
116
+ signatures += element.text
124
117
}
125
118
val content = document.select(" .documentableElement" ).forEach { elem =>
126
119
val annotations = elem.select(" .annotations" ).eachText.asScala.mkString(" " )
@@ -134,7 +127,6 @@ abstract class SignatureTest(
134
127
val all = s " $annotations$other $sigPrefix$signature" .trim()
135
128
signatures += all
136
129
}
137
- counter = 0
138
130
139
131
IO .foreachFileIn(output, processFile)
140
132
signatures.result
0 commit comments