EA-214654: Add missing read action

This commit is contained in:
Yan Zhulanow
2020-01-15 19:17:40 +09:00
parent dc71ab5bb3
commit fabbfdc7f8
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.psi.*;
import java.util.Collections;
import java.util.List; import java.util.List;
import static org.jetbrains.kotlin.idea.debugger.breakpoints.BreakpointTypeUtilsKt.isBreakpointApplicable; import static org.jetbrains.kotlin.idea.debugger.breakpoints.BreakpointTypeUtilsKt.isBreakpointApplicable;
@@ -108,7 +109,14 @@ public class KotlinLineBreakpointType extends JavaLineBreakpointType implements
@Nullable @Nullable
private static KtFunction getLambdaByOrdinal(SourcePosition position, Integer ordinal) { private static KtFunction getLambdaByOrdinal(SourcePosition position, Integer ordinal) {
if (ordinal != null && ordinal >= 0) { if (ordinal != null && ordinal >= 0) {
List<KtFunction> lambdas = BreakpointTypeUtilsKt.getLambdasAtLineIfAny(position); List<KtFunction> lambdas = ReadAction.compute(() -> {
PsiElement targetElement = position.getElementAt();
if (targetElement == null || !targetElement.isValid()) {
return Collections.emptyList();
}
return BreakpointTypeUtilsKt.getLambdasAtLineIfAny(position);
});
if (lambdas.size() > ordinal) { if (lambdas.size() > ordinal) {
return lambdas.get(ordinal); return lambdas.get(ordinal);
} }