[java, refactoring] disable extract superclass for unnamed class

GitOrigin-RevId: 376d8944f5b8fa29a97e17b51d02f46c452c2483
This commit is contained in:
Roman Ivanov
2023-08-27 21:24:01 +00:00
committed by intellij-monorepo-bot
parent 2fcaa6fba7
commit c18e77260a
2 changed files with 7 additions and 0 deletions
@@ -70,6 +70,12 @@ public class ExtractSuperclassHandler implements ElementsHandler, ExtractSupercl
return;
}
if (mySubclass instanceof PsiUnnamedClass) {
String message = RefactoringBundle.message("error.superclass.cannot.be.extracted.from.unnamed.class");
CommonRefactoringUtil.showErrorHint(project, null, message, getRefactoringName(), HelpID.EXTRACT_SUPERCLASS);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, mySubclass)) return;
Editor editor = dataContext != null ? CommonDataKeys.EDITOR.getData(dataContext) : null;
@@ -11,6 +11,7 @@ error.wrong.caret.position.method.or.variable.name=Caret should be positioned at
error.wrong.caret.position.class=Caret should be positioned inside class to be refactored
error.select.class.to.be.refactored=Cannot perform the refactoring.\nThe refactoring should be invoked on the class or members to be refactored.
error.interface.cannot.be.extracted.from.unnamed.class=Cannot perform the refactoring.\nCannot extract interface from unnamed class
error.superclass.cannot.be.extracted.from.unnamed.class=Cannot perform the refactoring.\nCannot extract superclass from unnamed class
error.wrong.caret.position.method.or.local.name=Caret should be positioned at the name of element to be refactored
error.wrong.caret.position.symbol.to.rename=Caret should be positioned at symbol to be renamed
error.wrong.caret.position.symbol.to.refactor=Caret should be positioned at symbol to be refactored