@Override protected boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) { final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>(); myExtractEnumProcessor.findEnumConstantConflicts(refUsages); if (!DestinationFolderComboBox.isAccessible( myProject, sourceClass.getContainingFile().getVirtualFile(), myClass.getContainingFile().getContainingDirectory().getVirtualFile())) { conflicts.putValue( sourceClass, "Extracted class won't be accessible in " + RefactoringUIUtil.getDescription(sourceClass, true)); } ApplicationManager.getApplication() .runWriteAction( new Runnable() { public void run() { myClass.delete(); } }); final Project project = sourceClass.getProject(); final GlobalSearchScope scope = GlobalSearchScope.allScope(project); final PsiClass existingClass = JavaPsiFacade.getInstance(project).findClass(getQualifiedName(), scope); if (existingClass != null) { conflicts.putValue( existingClass, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("there.already.exists.a.class.with.the.chosen.name")); } if (!myGenerateAccessors) { calculateInitializersConflicts(conflicts); final NecessaryAccessorsVisitor visitor = checkNecessaryGettersSetters4ExtractedClass(); final NecessaryAccessorsVisitor srcVisitor = checkNecessaryGettersSetters4SourceClass(); final Set<PsiField> fieldsNeedingGetter = new LinkedHashSet<PsiField>(); fieldsNeedingGetter.addAll(visitor.getFieldsNeedingGetter()); fieldsNeedingGetter.addAll(srcVisitor.getFieldsNeedingGetter()); for (PsiField field : fieldsNeedingGetter) { conflicts.putValue(field, "Field \'" + field.getName() + "\' needs getter"); } final Set<PsiField> fieldsNeedingSetter = new LinkedHashSet<PsiField>(); fieldsNeedingSetter.addAll(visitor.getFieldsNeedingSetter()); fieldsNeedingSetter.addAll(srcVisitor.getFieldsNeedingSetter()); for (PsiField field : fieldsNeedingSetter) { conflicts.putValue(field, "Field \'" + field.getName() + "\' needs setter"); } } checkConflicts(refUsages, conflicts); return showConflicts(conflicts, refUsages.get()); }
protected String getCommandName() { final PsiClass containingClass = method.getContainingClass(); return RefactorJBundle.message( "introduced.parameter.class.command.name", className, containingClass.getName(), method.getName()); }
@Override public String getConflictMessage() { if (!myGenerateAccessors && (!paramsNeedingSetters.isEmpty() || !paramsNeedingGetters.isEmpty())) { final StringBuffer buf = new StringBuffer(); appendConflicts(buf, paramsNeedingGetters); appendConflicts(buf, paramsNeedingSetters); return RefactorJBundle.message("cannot.perform.the.refactoring") + buf.toString(); } return null; }
@Override protected boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) { MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>(); if (myUseExistingClass) { if (existingClass == null) { conflicts.putValue( null, RefactorJBundle.message("cannot.perform.the.refactoring") + "Could not find the selected class"); } if (myExistingClassCompatibleConstructor == null) { conflicts.putValue( existingClass, RefactorJBundle.message("cannot.perform.the.refactoring") + "Selected class has no compatible constructors"); } } else { if (existingClass != null) { conflicts.putValue( existingClass, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("there.already.exists.a.class.with.the.chosen.name")); } if (myMoveDestination != null) { if (!myMoveDestination.isTargetAccessible( myProject, method.getContainingFile().getVirtualFile())) { conflicts.putValue(method, "Created class won't be accessible"); } } } for (UsageInfo usageInfo : refUsages.get()) { if (usageInfo instanceof FixableUsageInfo) { final String conflictMessage = ((FixableUsageInfo) usageInfo).getConflictMessage(); if (conflictMessage != null) { conflicts.putValue(usageInfo.getElement(), conflictMessage); } } } return showConflicts(conflicts, refUsages.get()); }
protected String getCommandName() { return RefactorJBundle.message( "exposed.delegation.command.name", containingClass.getName(), '.', field.getName()); }
protected String getCommandName() { return RefactorJBundle.message("extracted.class.command.name", newClassName); }