SourcePosition (final SourcePosition original) { return ReadAction.compute(() -> { PsiFile file = original.getFile(); int line = original.getLine(); Document document = file.getViewProvider().getDocument(); if (document == null || line >= document.getLineCount()) { return original; } if (DebuggerUtilsEx.isLambdaName(myExpectedMethodName) && myLambdaOrdinal > -1) { List<PsiLambdaExpression> lambdas = DebuggerUtilsEx.collectLambdas(original, true); if (myLambdaOrdinal < lambdas.size()) { PsiElement firstElem = DebuggerUtilsEx.getFirstElementOnTheLine(lambdas.get(myLambdaOrdinal), document, line); if (firstElem != null) { return SourcePosition.createFromElement(firstElem); } } } else { // There may be more than one class/method code on the line, so we need to find out the correct place Ref<SourcePosition> res = Ref.create(); XDebuggerUtil.getInstance().iterateLine(file.getProject(), document, line, elem -> { PsiElement remappedElement = remapElement(elem); if (remappedElement != null) { if (remappedElement.getTextOffset() > original.getOffset()) { res.set(SourcePosition.createFromElement(remappedElement)); } return false; } return true; }); if (!res.isNull()) { return res.get(); } } return original; }); }