protected static void ensureName(IntroduceOperation operation) { if (operation.getName() == null) { final Collection<String> suggestedNames = operation.getSuggestedNames(); if (suggestedNames.size() > 0) { operation.setName(suggestedNames.iterator().next()); } else { operation.setName("x"); } } }
protected void performIntroduceWithDialog(IntroduceOperation operation) { final Project project = operation.getProject(); if (operation.getName() == null) { PyIntroduceDialog dialog = new PyIntroduceDialog(project, myDialogTitle, myValidator, getHelpId(), operation); dialog.show(); if (!dialog.isOK()) { return; } operation.setName(dialog.getName()); operation.setReplaceAll(dialog.doReplaceAllOccurrences()); operation.setInitPlace(dialog.getInitPlace()); } PsiElement declaration = performRefactoring(operation); final Editor editor = operation.getEditor(); editor.getCaretModel().moveToOffset(declaration.getTextRange().getEndOffset()); editor.getSelectionModel().removeSelection(); }