Revert "Fix performance issue for case when there are a lot of warnings in file"
This reverts commit 3d8e5c4f8e.
Temporarily reverting this commit due to new flaky tests
This commit is contained in:
@@ -336,9 +336,6 @@ private class LazyJvmDiagnostics(compute: () -> Diagnostics) : Diagnostics {
|
|||||||
|
|
||||||
override fun noSuppression() = delegate.noSuppression()
|
override fun noSuppression() = delegate.noSuppression()
|
||||||
|
|
||||||
override fun hasDiagnostic(diagnostic: Diagnostic) =
|
|
||||||
delegate.hasDiagnostic(diagnostic)
|
|
||||||
|
|
||||||
override fun iterator() = delegate.iterator()
|
override fun iterator() = delegate.iterator()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun BindingTrace.reportDiagnosticOnce(diagnostic: Diagnostic) {
|
fun BindingTrace.reportDiagnosticOnce(diagnostic: Diagnostic) {
|
||||||
if (!bindingContext.diagnostics.hasDiagnostic(diagnostic)) {
|
if (bindingContext.diagnostics.forElement(diagnostic.psiElement).any { it.factory == diagnostic.factory }) return
|
||||||
report(diagnostic)
|
|
||||||
}
|
report(diagnostic)
|
||||||
}
|
}
|
||||||
|
|
||||||
class TypeMismatchDueToTypeProjectionsData(
|
class TypeMismatchDueToTypeProjectionsData(
|
||||||
|
|||||||
@@ -93,9 +93,5 @@ class CompositeBindingContext private constructor(
|
|||||||
override fun noSuppression(): Diagnostics {
|
override fun noSuppression(): Diagnostics {
|
||||||
return CompositeDiagnostics(delegates.map { it.noSuppression() })
|
return CompositeDiagnostics(delegates.map { it.noSuppression() })
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hasDiagnostic(diagnostic: Diagnostic): Boolean {
|
|
||||||
return delegates.any { it.hasDiagnostic(diagnostic) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ interface Diagnostics : Iterable<Diagnostic> {
|
|||||||
|
|
||||||
fun noSuppression(): Diagnostics
|
fun noSuppression(): Diagnostics
|
||||||
|
|
||||||
@JvmDefault
|
|
||||||
fun hasDiagnostic(diagnostic: Diagnostic): Boolean =
|
|
||||||
forElement(diagnostic.psiElement).any { it.factory == diagnostic.factory }
|
|
||||||
|
|
||||||
override fun iterator() = all().iterator()
|
override fun iterator() = all().iterator()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -46,7 +42,6 @@ interface Diagnostics : Iterable<Diagnostic> {
|
|||||||
override val modificationTracker: ModificationTracker = ModificationTracker.NEVER_CHANGED
|
override val modificationTracker: ModificationTracker = ModificationTracker.NEVER_CHANGED
|
||||||
override fun all() = listOf<Diagnostic>()
|
override fun all() = listOf<Diagnostic>()
|
||||||
override fun forElement(psiElement: PsiElement) = listOf<Diagnostic>()
|
override fun forElement(psiElement: PsiElement) = listOf<Diagnostic>()
|
||||||
override fun hasDiagnostic(diagnostic: Diagnostic): Boolean = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-17
@@ -17,11 +17,11 @@
|
|||||||
package org.jetbrains.kotlin.resolve.diagnostics
|
package org.jetbrains.kotlin.resolve.diagnostics
|
||||||
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
|
import java.util.ArrayList
|
||||||
import com.intellij.openapi.util.CompositeModificationTracker
|
import com.intellij.openapi.util.CompositeModificationTracker
|
||||||
import com.intellij.util.CachedValueImpl
|
import com.intellij.util.CachedValueImpl
|
||||||
import com.intellij.psi.util.CachedValueProvider
|
import com.intellij.psi.util.CachedValueProvider
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.util.SmartList
|
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
|
||||||
@@ -29,12 +29,11 @@ class MutableDiagnosticsWithSuppression @JvmOverloads constructor(
|
|||||||
private val bindingContext: BindingContext,
|
private val bindingContext: BindingContext,
|
||||||
private val delegateDiagnostics: Diagnostics = Diagnostics.EMPTY
|
private val delegateDiagnostics: Diagnostics = Diagnostics.EMPTY
|
||||||
) : Diagnostics {
|
) : Diagnostics {
|
||||||
// Usually, we don't report on an element more than one diagnostic, so it's better to use SmartList here
|
private val diagnosticList = ArrayList<Diagnostic>()
|
||||||
private val diagnosticMap = HashMap<PsiElement, SmartList<Diagnostic>>()
|
|
||||||
|
|
||||||
//NOTE: CachedValuesManager is not used because it requires Project passed to this object
|
//NOTE: CachedValuesManager is not used because it requires Project passed to this object
|
||||||
private val cache = CachedValueImpl(CachedValueProvider {
|
private val cache = CachedValueImpl(CachedValueProvider {
|
||||||
val allDiagnostics = delegateDiagnostics.noSuppression().all() + getOwnDiagnostics()
|
val allDiagnostics = delegateDiagnostics.noSuppression().all() + diagnosticList
|
||||||
CachedValueProvider.Result(DiagnosticsWithSuppression(bindingContext, allDiagnostics), modificationTracker)
|
CachedValueProvider.Result(DiagnosticsWithSuppression(bindingContext, allDiagnostics), modificationTracker)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -48,29 +47,19 @@ class MutableDiagnosticsWithSuppression @JvmOverloads constructor(
|
|||||||
|
|
||||||
//essential that this list is readonly
|
//essential that this list is readonly
|
||||||
fun getOwnDiagnostics(): List<Diagnostic> {
|
fun getOwnDiagnostics(): List<Diagnostic> {
|
||||||
return diagnosticMap.values.flatten()
|
return diagnosticList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun report(diagnostic: Diagnostic) {
|
fun report(diagnostic: Diagnostic) {
|
||||||
diagnosticMap.getOrPut(diagnostic.psiElement, { SmartList() }).add(diagnostic)
|
diagnosticList.add(diagnostic)
|
||||||
modificationTracker.incModificationCount()
|
modificationTracker.incModificationCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clear() {
|
fun clear() {
|
||||||
diagnosticMap.clear()
|
diagnosticList.clear()
|
||||||
modificationTracker.incModificationCount()
|
modificationTracker.incModificationCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hasDiagnostic(diagnostic: Diagnostic): Boolean {
|
|
||||||
if (cache.hasUpToDateValue()) return cache.value.hasDiagnostic(diagnostic)
|
|
||||||
if (delegateDiagnostics.hasDiagnostic(diagnostic)) return true
|
|
||||||
|
|
||||||
// It's totally fine to check without any suppression logic as if passed diagnostic has the same factory & psiElement,
|
|
||||||
// then it has the same suppression logic, so it doesn't matter if we add it or not later
|
|
||||||
val list = diagnosticMap[diagnostic.psiElement] ?: return false
|
|
||||||
return list.any { it.factory == diagnostic.factory && it.psiElement == diagnostic.psiElement }
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
fun getReadonlyView(): DiagnosticsWithSuppression = readonlyView()
|
fun getReadonlyView(): DiagnosticsWithSuppression = readonlyView()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.diagnostics
|
package org.jetbrains.kotlin.resolve.diagnostics
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.Condition
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|||||||
Reference in New Issue
Block a user