mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 10:51:25 +07:00
encapsulate fields: do not invoke refactoring on empty set of fields
This commit is contained in:
+5
@@ -457,6 +457,11 @@ public String getAccessorsVisibility() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getCheckedRows().length == 0) {
|
||||
CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, "Nothing found to encapsulate", HelpID.ENCAPSULATE_FIELDS, myProject);
|
||||
return;
|
||||
}
|
||||
|
||||
invokeRefactoring(new EncapsulateFieldsProcessor(myProject, this));
|
||||
JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
|
||||
settings.ENCAPSULATE_FIELDS_USE_ACCESSORS_WHEN_ACCESSIBLE = myCbUseAccessorsWhenAccessible.isSelected();
|
||||
|
||||
+5
@@ -106,6 +106,11 @@ public class EncapsulateFieldsHandler implements RefactoringActionHandler {
|
||||
}
|
||||
|
||||
LOG.assertTrue(aClass != null);
|
||||
final PsiField[] fields = aClass.getFields();
|
||||
if (fields.length == 0) {
|
||||
CommonRefactoringUtil.showErrorHint(project, PlatformDataKeys.EDITOR.getData(dataContext), "Class has no fields to encapsulate", REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aClass.isInterface()) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("encapsulate.fields.refactoring.cannot.be.applied.to.interface"));
|
||||
|
||||
Reference in New Issue
Block a user