-
Notifications
You must be signed in to change notification settings - Fork 47
/
Reports.kt
34 lines (27 loc) · 1018 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
28
29
30
31
32
33
34
package kotlinx.kover.engines.commons
import java.io.*
internal class Report(
val files: List<File>,
val projects: List<ProjectInfo>,
val includes: List<String> = emptyList(),
val excludes: List<String> = emptyList()
)
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()
}
internal val ONE_HUNDRED = 100.toBigDecimal()