void (String targetClassName) { if (targetClassName != null) { UiInterceptors.register(new ChooserInterceptor(null, Pattern.quote(targetClassName))); } ReplaceConstructorWithFactoryAction action = new ReplaceConstructorWithFactoryAction(); ActionContext context = ActionContext.from(getEditor(), getFile()); Presentation presentation = action.getPresentation(context); assertNotNull(presentation); ModCommand command = action.perform(context); ModCommandExecutor.getInstance().executeInteractively(context, command, getEditor()); IdeEventQueue.getInstance().flushQueue(); }