@@ -43,7 +43,7 @@ abstract class SignatureTest(
4343
4444 val unexpected = unexpectedFromSources.flatMap(actualSignatures.get).flatten
4545 val expectedButNotFound = expectedFromSources.flatMap {
46- case (k, v) => findMissingSingatures (v, actualSignatures.getOrElse(k, Nil ))
46+ case (k, v) => findMissingSignatures (v, actualSignatures.getOrElse(k, Nil ))
4747 }
4848
4949 val missingReport = Option .when(! ignoreMissingSignatures && ! expectedButNotFound.isEmpty)
@@ -75,26 +75,21 @@ abstract class SignatureTest(
7575 private val unexpectedRegex = raw " (.+)//unexpected " .r
7676 private val identifierRegex = raw " ^\s*(`.*`|(?:\w+)(?:_[^\[\(\s]+)|\w+|[^\[\(\s]+) " .r
7777
78- private def findMissingSingatures (expected : Seq [String ], actual : Seq [String ]): Set [String ] =
78+ private def findMissingSignatures (expected : Seq [String ], actual : Seq [String ]): Set [String ] =
7979 expected.toSet &~ actual.toSet
8080
8181 extension (s : String )
8282 private def startWithAnyOfThese (c : String * ) = c.exists(s.startsWith)
8383 private def compactWhitespaces = whitespaceRegex.replaceAllIn(s, " " )
8484
85- private var counter = 0
8685 private def findName (signature : String , kinds : Seq [String ]): Option [String ] =
8786 for
8887 kindMatch <- kinds.flatMap(k => s " \\ b $k\\ b " .r.findFirstMatchIn(signature)).headOption
88+ kind <- Option (kindMatch.group(0 )) // to filter out nulls
8989 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
9893
9994 private def signaturesFromSources (source : Source , kinds : Seq [String ]): Seq [SignatureRes ] =
10095 source.getLines.map(_.trim)
@@ -118,9 +113,7 @@ abstract class SignatureTest(
118113 def processFile (path : Path ): Unit = if filterFunc(path) then
119114 val document = Jsoup .parse(IO .read(path))
120115 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
124117 }
125118 val content = document.select(" .documentableElement" ).forEach { elem =>
126119 val annotations = elem.select(" .annotations" ).eachText.asScala.mkString(" " )
@@ -134,7 +127,6 @@ abstract class SignatureTest(
134127 val all = s " $annotations$other $sigPrefix$signature" .trim()
135128 signatures += all
136129 }
137- counter = 0
138130
139131 IO .foreachFileIn(output, processFile)
140132 signatures.result
0 commit comments