-
Notifications
You must be signed in to change notification settings - Fork 47
/
Reports.kt
27 lines (21 loc) · 869 Bytes
/
Reports.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package kotlinx.kover.engines.commons
import java.io.*
internal class Report(val files: List<File>, val projects: List<ProjectInfo>)
internal class ProjectInfo(val sources: Iterable<File>, val outputs: Iterable<File>)
private val regexMetacharactersSet = "<([{\\^-=$!|]})+.>".toSet()
/**
* Replaces characters `*` or `.` to `.*` and `.` regexp characters.
*/
internal fun String.wildcardsToRegex(): String {
// in most cases, the characters `*` or `.` will be present therefore, we increase the capacity in advance
val builder = StringBuilder(length * 2)
forEach { char ->
when (char) {
in regexMetacharactersSet -> builder.append('\\').append(char)
'*' -> builder.append('.').append("*")
'?' -> builder.append('.')
else -> builder.append(char)
}
}
return builder.toString()
}