public static boolean invoke(final PsiElement element, @Nullable Editor editor, final InlineHandler languageSpecific) {
    final PsiReference invocationReference = editor != null ? TargetElementUtil.findReference(editor) : null;
    final InlineHandler.Settings settings = languageSpecific.prepareInlineElement(element, editor, invocationReference != null);
    if (settings == null || settings == InlineHandler.Settings.CANNOT_INLINE_SETTINGS) {
      return settings != null;
    }

    Project project = element.getProject();

    final Collection<? extends PsiReference> allReferences;

    if (settings.isOnlyOneReferenceToInline()) {
      allReferences = Collections.singleton(invocationReference);
    }
    else {
      allReferences = ProgressManager.getInstance().runProcessWithProgressSynchronously(
        () -> ReferencesSearch.search(element).findAll(),
        FindBundle.message("find.usages.progress.title"), true, project);
    }

    final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
    final Map<Language, InlineHandler.Inliner> inliners = initializeInliners(element, settings, allReferences);

    for (PsiReference reference : allReferences) {
      collectConflicts(reference, element, inliners, conflicts);
    }

    if (!BaseRefactoringProcessor.processConflicts(project, conflicts)) return true;

    HashSet<PsiElement> elements = new HashSet<>();
    for (PsiReference reference : allReferences) {
      elements.add(reference.getElement());
    }
    if (!settings.isOnlyOneReferenceToInline()) {
      elements.add(element);
    }

    if (!CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, elements, true)) {
      return true;
    }
    String subj = element instanceof PsiNamedElement ? ((PsiNamedElement)element).getName() : "element";
    String commandName = RefactoringBundle.message("inline.command", StringUtil.notNullize(subj, "<nameless>"));
    WriteCommandAction.runWriteCommandAction(
      project, commandName, null, () -> {
        final PsiReference[] references = sortDepthFirstRightLeftOrder(allReferences);


        final UsageInfo[] usages = new UsageInfo[references.length];
        for (int i = 0; i < references.length; i++) {
          usages[i] = new UsageInfo(references[i]);
        }

        Consumer<ProgressIndicator> perform = indicator -> {
          indicator.setIndeterminate(false);
          for (int i = 0; i < usages.length; i++) {
            indicator.setFraction((double) i / usages.length);
            inlineReference(usages[i], element, inliners);
          }

          if (!settings.isOnlyOneReferenceToInline()) {
            languageSpecific.removeDefinition(element, settings);
          }
        };

        if (Registry.is("run.refactorings.under.progress")) {
          ((ApplicationImpl)ApplicationManager.getApplication())
            .runWriteActionWithNonCancellableProgressInDispatchThread(commandName, project, null, perform);
        }
        else {
          perform.accept(new EmptyProgressIndicator());
        }
      });
    return true;
  }
public static boolean invoke(final PsiElement element, @Nullable Editor editor, final InlineHandler languageSpecific)