Scripting: ignore some diags if artefact is resolved
The failure diagnostics from resolvers are ignored now if followed by a successful result from a following resolver. #KT-63352 fixed the commit is idirectly tested by the test MainKtsIT.testUseSlf4j from the followin commit "Scripting: ignore some diags if artefact is resolved", namely without these changes, additional two warnings are reported in this test.
This commit is contained in:
committed by
Space Team
parent
fa9c620261
commit
e927ac5fc3
@@ -310,12 +310,15 @@ fun <R> ResultWithDiagnostics<R>.valueOrThrow(): R = valueOr {
|
||||
|
||||
class IterableResultsCollector<T> {
|
||||
private val diagnostics = mutableListOf<ScriptDiagnostic>()
|
||||
private val failureResults = mutableListOf<ResultWithDiagnostics<Iterable<T>>>()
|
||||
private val values = mutableListOf<T>()
|
||||
|
||||
fun add(result: ResultWithDiagnostics<Iterable<T>>) {
|
||||
diagnostics.addAll(result.reports)
|
||||
if (result is ResultWithDiagnostics.Success) {
|
||||
diagnostics.addAll(result.reports)
|
||||
values.addAll(result.value)
|
||||
} else {
|
||||
failureResults.add(result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +332,7 @@ class IterableResultsCollector<T> {
|
||||
|
||||
fun getResult(): ResultWithDiagnostics<List<T>> {
|
||||
return if (values.isEmpty()) {
|
||||
ResultWithDiagnostics.Failure(diagnostics)
|
||||
ResultWithDiagnostics.Failure(diagnostics + failureResults.flatMap { it.reports })
|
||||
} else {
|
||||
ResultWithDiagnostics.Success(values, diagnostics)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user