DataContext (Component contextComponent, String newName, PsiElement newElementToRename) { DataContext context = DataManager.getInstance().getDataContext(contextComponent); if (newName == null && newElementToRename == null) return context; return SimpleDataContext.builder() .setParent(context) .add(PsiElementRenameHandler.DEFAULT_NAME, newName) .add(LangDataKeys.PSI_ELEMENT_ARRAY, newElementToRename == null ? null : new PsiElement[]{newElementToRename}) .build(); }