public static void invokeOnElements(@NotNull Project project, final Editor editor, PsiFile file, PsiElement @NotNull [] elements) {
    TextRange selection = ExtractMethodHelper.findEditorSelection(editor);
    if (selection == null && elements.length == 1) selection = elements[0].getTextRange();
    if (selection != null) new MethodExtractor().doExtract(file, selection);
  }
public static void invokeOnElements(@NotNull Project project, final Editor editor, PsiFile file, PsiElement @NotNull [] elements)