private static @NotNull ModCommand inlinePattern(@NotNull ActionContext context,
                                                   @NotNull PsiPatternVariable pattern,
                                                   @Nullable PsiReferenceExpression refExpr,
                                                   @NotNull List<PsiReferenceExpression> allRefs,
                                                   @NotNull InlineMode mode) {
    String initializerText = JavaPsiPatternUtil.getEffectiveInitializerText(pattern);
    if (initializerText == null) {
      return ModCommand.error(JavaRefactoringBundle.message("tooltip.cannot.inline.pattern.variable"));
    }
    Project project = context.project();
    if (mode == InlineMode.CHECK_CONFLICTS || mode == InlineMode.ASK) {
      if (refExpr == null || allRefs.size() == 1 || !EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog()) {
        mode = InlineMode.INLINE_ALL_AND_DELETE;
      } else {
        return createChooser(pattern, refExpr, allRefs);
      }
    }
    final PsiElement[] refsToInline = PsiUtilCore.toPsiElementArray(allRefs);
    PsiExpression defToInline = JavaPsiFacade.getElementFactory(project).createExpressionFromText(initializerText, pattern);

    boolean inlineAll = mode == InlineMode.INLINE_ALL_AND_DELETE;
    return ModCommand.psiUpdate(context, updater -> {
      PsiPatternVariable writablePattern = updater.getWritable(pattern);
      List<SmartPsiElementPointer<PsiExpression>> pointers = inlineOccurrences(project, writablePattern, defToInline,
                                                                               ContainerUtil.map(refsToInline, updater::getWritable));
      if (inlineAll) {
        writablePattern.delete();
      }
      highlightOccurrences(updater, pointers);
    });
  }
private static @NotNull ModCommand inlinePattern(@NotNull ActionContext context,
                                                   @NotNull PsiPatternVariable pattern,
                                                   @Nullable PsiReferenceExpression refExpr,
                                                   @NotNull List<PsiReferenceExpression> allRefs,
                                                   @NotNull InlineMode mode)