Location () { if (myContext == null) { throw new IllegalStateException("Context is not specified"); } return ReadAction.compute(() -> { int offset = myContext.getTextRange().getStartOffset(); PsiFile file = myContext.getContainingFile(); int lineNumber = StringUtil.offsetToLineNumber(file.getText(), offset); String name = file.getName(); PsiParameterListOwner psiMethod = PsiTreeUtil.getParentOfType(myContext, PsiMethod.class, PsiLambdaExpression.class); if (psiMethod == null) { UMethod uMethod = UastContextKt.getUastParentOfType(myContext, UMethod.class); if (uMethod != null) { psiMethod = uMethod.getJavaPsi(); } else { throw new IllegalStateException("Method/lambda not found"); } } Method method = psiMethod instanceof PsiMethod ? new MockPsiMethod(myVirtualMachine, (PsiMethod)psiMethod) : new MockPsiLambda(myVirtualMachine, (PsiLambdaExpression)psiMethod); return new MockLocation(lineNumber, 0, method, name, name); }); }