Print all diagnostics if null diagnostic found (EA-79696)
Diagnostics collection shouldn't contain nulls, but may do so when there were unprotected simultaneous writes from several threads.
This commit is contained in:
+5
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.AtomicNotNullLazyValue;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.util.containers.ConcurrentMultiMap;
|
import com.intellij.util.containers.ConcurrentMultiMap;
|
||||||
import com.intellij.util.containers.MultiMap;
|
import com.intellij.util.containers.MultiMap;
|
||||||
|
import kotlin.collections.CollectionsKt;
|
||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||||
@@ -51,6 +52,10 @@ public class DiagnosticsElementsCache {
|
|||||||
private static MultiMap<PsiElement, Diagnostic> buildElementToDiagnosticCache(Diagnostics diagnostics, Function1<Diagnostic, Boolean> filter) {
|
private static MultiMap<PsiElement, Diagnostic> buildElementToDiagnosticCache(Diagnostics diagnostics, Function1<Diagnostic, Boolean> filter) {
|
||||||
MultiMap<PsiElement, Diagnostic> elementToDiagnostic = new ConcurrentMultiMap<>();
|
MultiMap<PsiElement, Diagnostic> elementToDiagnostic = new ConcurrentMultiMap<>();
|
||||||
for (Diagnostic diagnostic : diagnostics) {
|
for (Diagnostic diagnostic : diagnostics) {
|
||||||
|
if (diagnostic == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"There shouldn't be null diagnostics in the collection: " + CollectionsKt.toList(diagnostics));
|
||||||
|
}
|
||||||
if (filter.invoke(diagnostic)) {
|
if (filter.invoke(diagnostic)) {
|
||||||
elementToDiagnostic.putValue(diagnostic.getPsiElement(), diagnostic);
|
elementToDiagnostic.putValue(diagnostic.getPsiElement(), diagnostic);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user