[java, refactoring] disable extract delegate for unnamed class

GitOrigin-RevId: 96f06fcc32a75b5dae1003a8cfeabc78740228aa
This commit is contained in:
Roman Ivanov
2023-08-02 16:33:02 +02:00
committed by intellij-monorepo-bot
parent 3d7d9f8298
commit 2fcaa6fba7
2 changed files with 5 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ public class ExtractClassHandler implements ElementsHandler, ContextAwareActionH
CommonRefactoringUtil.showErrorHint(project, editor,
RefactorJBundle.message("cannot.perform.the.refactoring") + cannotRefactorMessage,
getRefactoringName(), HelpID.ExtractClass);
return;
}
new ExtractClassDialog(containingClass, new HashSet<>(elements)).show();
}
@@ -77,6 +78,9 @@ public class ExtractClassHandler implements ElementsHandler, ContextAwareActionH
if (!containingClass.getManager().isInProject(containingClass)) {
return RefactorJBundle.message("the.selected.class.should.belong.to.project.sources");
}
if (containingClass instanceof PsiUnnamedClass) {
return RefactorJBundle.message("refactoring.cannot.be.done.in.unnamed.class");
}
return null;
}

View File

@@ -18,6 +18,7 @@ the.selected.class.is.an.annotation.type=The selected class is an annotation int
the.refactoring.is.not.supported.on.non.static.inner.classes=The refactoring is not supported on non-static inner classes.
the.selected.class.has.no.members.to.extract=The selected class has no members to extract.
the.selected.class.should.belong.to.project.sources=The selected class should belong to project sources
refactoring.cannot.be.done.in.unnamed.class=Refactoring cannot be done in unnamed class
references.to.extract=References to extract ( {0, choice, 0#(Not found)|1#{0} reference|2#{0} references}{1, choice, 0#|1# in {1} file|2# in {1} files})
extract.class.as.enum.column.title=As Enum
extract.class.depends.on.0.from.1.tooltip=Depends on {0} from {1}