[java, refactoring] disable extract interface for unnamed class

GitOrigin-RevId: 97ceafc6e1da2b8aefa921e94bfd30bd90c0808d
This commit is contained in:
Roman Ivanov
2023-08-27 21:23:58 +00:00
committed by intellij-monorepo-bot
parent 9d7ae8bcae
commit 3d7d9f8298
2 changed files with 8 additions and 4 deletions
@@ -29,10 +29,7 @@ import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
public class ExtractInterfaceHandler implements ElementsHandler, ContextAwareActionHandler {
@@ -74,6 +71,12 @@ public class ExtractInterfaceHandler implements ElementsHandler, ContextAwareAct
return;
}
if (myClass instanceof PsiUnnamedClass) {
String message = RefactoringBundle.message("error.interface.cannot.be.extracted.from.unnamed.class");
CommonRefactoringUtil.showErrorHint(project, null, message, getRefactoringName(), HelpID.EXTRACT_INTERFACE);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, myClass)) return;
final Set<PsiElement> selectedMembers = new HashSet<>();
@@ -10,6 +10,7 @@ error.wrong.caret.position.method.or.class.name=Caret should be positioned at th
error.wrong.caret.position.method.or.variable.name=Caret should be positioned at the name of method or variable to be refactored
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.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