PsiMethod (@NotNull DataContext context) { final Location<?> location = Location.DATA_KEY.getData(context); if (location != null) { UMethod method = UastContextKt.getUastParentOfType(location.getPsiElement(), UMethod.class, false); if (method != null) { return method.getJavaPsi(); } } final Editor editor = CommonDataKeys.EDITOR.getData(context); final PsiFile file = CommonDataKeys.PSI_FILE.getData(context); if (file != null && editor != null) { UMethod method = UastContextKt.findUElementAt(file, editor.getCaretModel().getOffset(), UMethod.class); return method != null ? method.getJavaPsi() : null; } return null; }