Skip to content

Commit 48da128

Browse files
author
Devon Stewart
committed
Support newer versions of scala
1 parent adfc2a1 commit 48da128

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scalac-scoverage-plugin/src/main/scala/scoverage/CoverageFilter.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scoverage
22

33
import scala.collection.mutable
44
import scala.reflect.internal.util.{Position, SourceFile}
5+
import scala.util.matching.Regex
56

67
/**
78
* Methods related to filtering the instrumentation and coverage.
@@ -72,6 +73,12 @@ class RegexCoverageFilter(excludedPackages: Seq[String],
7273
excludedSymbolPatterns.isEmpty || !excludedSymbolPatterns.exists(_.matcher(symbolName).matches)
7374
}
7475

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+
7582
/**
7683
* Checks the given sourceFile for any magic comments which exclude lines
7784
* from coverage. Returns a list of Ranges of lines that should be excluded.
@@ -83,7 +90,7 @@ class RegexCoverageFilter(excludedPackages: Seq[String],
8390
linesExcludedByScoverageCommentsCache.get(sourceFile) match {
8491
case Some(lineNumbers) => lineNumbers
8592
case None =>
86-
val lineNumbers = scoverageExclusionCommentsRegex.findAllIn(sourceFile.content).matchData.map { m =>
93+
val lineNumbers = compatFindAllIn(scoverageExclusionCommentsRegex, sourceFile.content).matchData.map { m =>
8794
// Asking a SourceFile for the line number of the char after
8895
// the end of the file gives an exception
8996
val endChar = math.min(m.end(2), sourceFile.content.length - 1)

0 commit comments

Comments
 (0)