private static List<PsiStatement> extractStatements(@NotNull ActionContext context) {
    PsiFile file = context.file();
    if (!(file instanceof PsiJavaFile)) return Collections.emptyList();
    TextRange selection = context.selection();
    if (selection.isEmpty()) {
      int offset = context.offset();
      PsiElement pos = file.findElementAt(offset);
      PsiStatement statement = PsiTreeUtil.getParentOfType(pos, PsiStatement.class, false, PsiMember.class, PsiCodeBlock.class);
      return ContainerUtil.createMaybeSingletonList(statement);
    }
    int startOffset = selection.getStartOffset();
    int endOffset = selection.getEndOffset();
    PsiElement[] elements = CodeInsightUtil.findStatementsInRange(file, startOffset, endOffset);
    return StreamEx.of(elements)
      .map(e -> tryCast(e, PsiStatement.class))
      .collect(MoreCollectors.ifAllMatch(Objects::nonNull, Collectors.toList()))
      .orElse(Collections.emptyList());
  }
private static List<PsiStatement> extractStatements(@NotNull ActionContext context)