diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java b/java/java-impl-refactorings/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java index c86d49fdfd41..6bd234a640cc 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java @@ -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; diff --git a/platform/refactoring/resources/messages/RefactoringBundle.properties b/platform/refactoring/resources/messages/RefactoringBundle.properties index 7ded3b553b00..020835e32720 100644 --- a/platform/refactoring/resources/messages/RefactoringBundle.properties +++ b/platform/refactoring/resources/messages/RefactoringBundle.properties @@ -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