private static @Nullable PsiMethod findMethod(@Nullable PsiParameter parameter, @NotNull ActionContext context) {
    if (parameter == null) {
      PsiElement elementAt = context.findLeaf();
      if (elementAt instanceof PsiIdentifier) {
        PsiElement parent = elementAt.getParent();
        if (parent instanceof PsiMethod method) {
          return method;
        }
      }
    }
    else {
      PsiElement declarationScope = parameter.getDeclarationScope();
      if (declarationScope instanceof PsiMethod method) {
        return method;
      }
    }

    return null;
  }
private static @Nullable PsiMethod findMethod(@Nullable PsiParameter parameter, @NotNull ActionContext context)