private static void invoke(@NotNull PsiElement element,
                             @NotNull Project project,
                             PsiElement nameSuggestionContext,
                             @NotNull List<String> suggestedNames,
                             @Nullable Editor editor,
                             boolean checkInProject) {
    if (!canRename(project, editor, element)) {
      return;
    }

    VirtualFile contextFile = PsiUtilCore.getVirtualFile(nameSuggestionContext);

    if (checkInProject && nameSuggestionContext != null &&
        nameSuggestionContext.isPhysical() &&
        (contextFile == null || !ScratchUtil.isScratch(contextFile)) &&
        !PsiManager.getInstance(project).isInProject(nameSuggestionContext)) {
      final String message = RefactoringBundle.message("dialog.message.selected.element.used.from.non.project.files");
      if (ApplicationManager.getApplication().isUnitTestMode()) throw new CommonRefactoringUtil.RefactoringErrorHintException(message);
      if (!MessageDialogBuilder.yesNo(RefactoringBundle.getCannotRefactorMessage(null), message, UIUtil.getWarningIcon()).ask(project)) {
        return;
      }
    }

    var processor = RenamePsiElementProcessorBase.forPsiElement(element);
    rename(element, project, nameSuggestionContext, suggestedNames, editor, null, processor);
  }
private static void invoke(@NotNull PsiElement element,
                             @NotNull Project project,
                             PsiElement nameSuggestionContext,
                             @NotNull List<String> suggestedNames,
                             @Nullable Editor editor,
                             boolean checkInProject)