Fix diagnostics calculations for incremental analysis

This commit is contained in:
Vladimir Dolzhenko
2019-11-23 23:36:49 +01:00
parent c7c512d55e
commit e321c9e4e7
@@ -261,9 +261,9 @@ private class StackedCompositeBindingContextTrace(
/**
* All diagnostics from parentContext apart those diagnostics those belongs to the element or its descendants
*/
val parentDiagnosticsApartElement: List<Diagnostic> = parentContext.diagnostics.all().filter { d ->
val parentDiagnosticsApartElement: Collection<Diagnostic> = parentContext.diagnostics.all().filter { d ->
d.psiElement.parentsWithSelf.none { it == element }
}.toList()
}
inner class StackedCompositeBindingContext : BindingContext {
var cachedDiagnostics: Diagnostics? = null
@@ -279,9 +279,12 @@ private class StackedCompositeBindingContextTrace(
override fun getDiagnostics(): Diagnostics {
if (cachedDiagnostics == null) {
val diagnosticList =
parentDiagnosticsApartElement + (this@StackedCompositeBindingContextTrace.mutableDiagnostics?.all() ?: emptyList())
cachedDiagnostics = MergedDiagnostics(diagnosticList, parentContext.diagnostics.modificationTracker)
val mergedDiagnostics = mutableSetOf<Diagnostic>()
mergedDiagnostics.addAll(parentDiagnosticsApartElement)
this@StackedCompositeBindingContextTrace.mutableDiagnostics?.all()?.let {
mergedDiagnostics.addAll(it)
}
cachedDiagnostics = MergedDiagnostics(mergedDiagnostics, parentContext.diagnostics.modificationTracker)
}
return cachedDiagnostics!!
}