public boolean performInplaceRefactoring(@Nullable LinkedHashSet<String> nameSuggestions) {
    if (myEditor instanceof ImaginaryEditor && myEditor.getUserData(INPLACE_RENAME_ALLOWED) != Boolean.TRUE) return false;
    myNameSuggestions = nameSuggestions;
    if (InjectedLanguageUtil.isInInjectedLanguagePrefixSuffix(myElementToRename)) {
      return false;
    }

    FileViewProvider fileViewProvider = myElementToRename.getContainingFile().getViewProvider();
    VirtualFile file = getTopLevelVirtualFile(fileViewProvider);

    SearchScope referencesSearchScope = getReferencesSearchScope(file);

    Collection<PsiReference> references = ProgressManager.getInstance().runProcessWithProgressSynchronously(() ->
      ReadAction.compute(() -> {
        Collection<PsiReference> refs = collectRefs(referencesSearchScope);

        addReferenceAtCaret(refs);
        return refs;
      })
    , RefactoringBundle.message("progress.title.collecting.references"), true, myProject);

    if (references == null) return false;

    for (PsiReference ref : references) {
      PsiFile containingFile = ref.getElement().getContainingFile();

      if (notSameFile(file, containingFile)) {
        return false;
      }
    }

    PsiElement scope = checkLocalScope();

    if (scope == null) {
      return false; // Should have valid local search scope for inplace rename
    }

    PsiFile containingFile = scope.getContainingFile();
    if (containingFile == null) {
      return false; // Should have valid local search scope for inplace rename
    }
    //no need to process further when file is read-only
    if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, containingFile)) return true;

    myEditor.putUserData(INPLACE_RENAMER, this);

    List<Pair<PsiElement, TextRange>> stringUsages = new NotNullList<>();
    collectAdditionalElementsToRename(stringUsages);
    try {
      return buildTemplateAndStart(references, stringUsages, scope, containingFile);
    }
    catch (Throwable e) {
      myEditor.putUserData(INPLACE_RENAMER, null);
      FinishMarkAction.finish(myProject, myEditor, myMarkAction);
      throw e;
    }
  }
public boolean performInplaceRefactoring(@Nullable LinkedHashSet<String> nameSuggestions)