@@ -2,6 +2,7 @@ package scoverage
2
2
3
3
import scala .collection .mutable
4
4
import scala .reflect .internal .util .{Position , SourceFile }
5
+ import scala .util .matching .Regex
5
6
6
7
/**
7
8
* Methods related to filtering the instrumentation and coverage.
@@ -72,6 +73,12 @@ class RegexCoverageFilter(excludedPackages: Seq[String],
72
73
excludedSymbolPatterns.isEmpty || ! excludedSymbolPatterns.exists(_.matcher(symbolName).matches)
73
74
}
74
75
76
+ /**
77
+ * Provides overloads to paper over 2.12.13+ SourceFile incompatibility
78
+ */
79
+ def compatFindAllIn (regexp : Regex , pattern : Array [Char ]): Regex .MatchIterator = regexp.findAllIn(new String (pattern))
80
+ def compatFindAllIn (regexp : Regex , pattern : String ): Regex .MatchIterator = regexp.findAllIn(pattern)
81
+
75
82
/**
76
83
* Checks the given sourceFile for any magic comments which exclude lines
77
84
* from coverage. Returns a list of Ranges of lines that should be excluded.
@@ -83,7 +90,7 @@ class RegexCoverageFilter(excludedPackages: Seq[String],
83
90
linesExcludedByScoverageCommentsCache.get(sourceFile) match {
84
91
case Some (lineNumbers) => lineNumbers
85
92
case None =>
86
- val lineNumbers = scoverageExclusionCommentsRegex.findAllIn( sourceFile.content).matchData.map { m =>
93
+ val lineNumbers = compatFindAllIn(scoverageExclusionCommentsRegex, sourceFile.content).matchData.map { m =>
87
94
// Asking a SourceFile for the line number of the char after
88
95
// the end of the file gives an exception
89
96
val endChar = math.min(m.end(2 ), sourceFile.content.length - 1 )
0 commit comments