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 * 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 } d.psiElement.parentsWithSelf.none { it == element }
}.toList() }
inner class StackedCompositeBindingContext : BindingContext { inner class StackedCompositeBindingContext : BindingContext {
var cachedDiagnostics: Diagnostics? = null var cachedDiagnostics: Diagnostics? = null
@@ -279,9 +279,12 @@ private class StackedCompositeBindingContextTrace(
override fun getDiagnostics(): Diagnostics { override fun getDiagnostics(): Diagnostics {
if (cachedDiagnostics == null) { if (cachedDiagnostics == null) {
val diagnosticList = val mergedDiagnostics = mutableSetOf<Diagnostic>()
parentDiagnosticsApartElement + (this@StackedCompositeBindingContextTrace.mutableDiagnostics?.all() ?: emptyList()) mergedDiagnostics.addAll(parentDiagnosticsApartElement)
cachedDiagnostics = MergedDiagnostics(diagnosticList, parentContext.diagnostics.modificationTracker) this@StackedCompositeBindingContextTrace.mutableDiagnostics?.all()?.let {
mergedDiagnostics.addAll(it)
}
cachedDiagnostics = MergedDiagnostics(mergedDiagnostics, parentContext.diagnostics.modificationTracker)
} }
return cachedDiagnostics!! return cachedDiagnostics!!
} }