Implement source sections compiler plugin

allows to compile only parts of the source files, denoted by top-level
"sections" (function with lambda param calls), but preserving original
file line/column numbers for easier diagnostics. Allow e.g. to compile
gradle "buildscript" section without preprocessing original file in
advance. See tests for examples.
This commit is contained in:
Ilya Chernikov
2017-03-10 16:15:11 +01:00
parent 63c276d444
commit 4b430b49a7
17 changed files with 708 additions and 4 deletions
@@ -118,6 +118,14 @@ inline fun <T, R : Any> Iterable<T>.firstNotNullResult(transform: (T) -> R?): R?
return null
}
inline fun <T, R : Any> Array<T>.firstNotNullResult(transform: (T) -> R?): R? {
for (element in this) {
val result = transform(element)
if (result != null) return result
}
return null
}
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
var sum: Long = 0
for (element in this) {