@Override
  public void inlineElement(Project project, Editor editor, PsiElement element) {
    final PsiElement navigationElement = element.getNavigationElement();
    final PsiField field = (PsiField)(navigationElement instanceof PsiField ? navigationElement : element);

    PsiExpression initializer = getInitializer(field);
    if (initializer == null) {
      String message = JavaRefactoringBundle.message("no.initializer.present.for.the.field");
      CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.INLINE_FIELD);
      return;
    }

    if (field instanceof PsiEnumConstant) {
      String message = JavaRefactoringBundle.message("inline.constant.field.not.supported.for.enum.constants", getRefactoringName());
      CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.INLINE_FIELD);
      return;
    }

    if (ReferencesSearch.search(field, ProjectScope.getProjectScope(project), false).findFirst() == null) {
      String message = JavaRefactoringBundle.message("field.0.is.never.used", field.getName());
      CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.INLINE_FIELD);
      return;
    }

    if (!field.hasModifierProperty(PsiModifier.FINAL)) {
      final Ref<Boolean> hasWriteUsages = new Ref<>(false);
      if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> {
        for (PsiReference reference : ReferencesSearch.search(field)) {
          if (isAccessedForWriting(reference.getElement())) {
            hasWriteUsages.set(true);
            break;
          }
        }
      }), JavaRefactoringBundle.message("inline.conflicts.progress"), true, project)) {
        return;
      }
      if (hasWriteUsages.get()) {
        String message = JavaRefactoringBundle.message("0.refactoring.is.supported.only.for.final.fields", getRefactoringName());
        CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.INLINE_FIELD);
        return;
      }
    }

    PsiReference reference = editor != null ? TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset()) : null;
    if (reference != null) {
      final PsiElement resolve = reference.resolve();
      if (resolve != null && !field.equals(resolve.getNavigationElement())) {
        reference = null;
      }
    }

    if ((!(element instanceof PsiCompiledElement) || reference == null) && !CommonRefactoringUtil.checkReadOnlyStatus(project, field)) return;

    MultiMap<PsiElement, String> conflicts = new MultiMap<>();
    InlineUtil.checkChangedBeforeLastAccessConflicts(conflicts, initializer, field);

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

    PsiElement referenceElement = reference != null ? reference.getElement() : null;
    if (referenceElement != null && 
        referenceElement.getLanguage() == JavaLanguage.INSTANCE &&
        !(referenceElement instanceof PsiReferenceExpression)) {
      referenceElement = null; 
    }
    InlineFieldDialog dialog = new InlineFieldDialog(project, field, referenceElement);
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      try {
        dialog.doAction();
      } finally {
        dialog.close(DialogWrapper.OK_EXIT_CODE, true);
      }
    }
    else {
      dialog.show();
    }
  }
@Override
  public void inlineElement(Project project, Editor editor, PsiElement element)