mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
devkit: fix incorrect warn about unregistered application component
This commit is contained in:
@@ -132,23 +132,26 @@ public class ComponentNotRegisteredInspection extends DevKitJvmInspection {
|
||||
}
|
||||
|
||||
for (ComponentType componentType : ComponentType.values()) {
|
||||
if (!InheritanceUtil.isInheritor(checkedClass, componentType.myClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (findRegistrationType(checkedClass, COMPONENT_TYPE_TO_REGISTRATION_TYPE.get(componentType)) != null) {
|
||||
if (InheritanceUtil.isInheritor(checkedClass, componentType.myClassName) && checkComponentRegistration(checkedClass, sink, componentType)) {
|
||||
return;
|
||||
}
|
||||
if (!canFix(checkedClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalQuickFix fix = new RegisterComponentFix(componentType, org.jetbrains.idea.devkit.util.PsiUtil.createPointer(checkedClass));
|
||||
sink.highlight(DevKitBundle.message("inspections.component.not.registered.message",
|
||||
DevKitBundle.message(componentType.myPropertyKey)), fix);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkComponentRegistration(@NotNull PsiClass checkedClass, @NotNull HighlightSink sink, @NotNull ComponentType componentType) {
|
||||
if (findRegistrationType(checkedClass, COMPONENT_TYPE_TO_REGISTRATION_TYPE.get(componentType)) != null) {
|
||||
return true;
|
||||
}
|
||||
if (!canFix(checkedClass)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LocalQuickFix fix = new RegisterComponentFix(componentType, org.jetbrains.idea.devkit.util.PsiUtil.createPointer(checkedClass));
|
||||
sink.highlight(DevKitBundle.message("inspections.component.not.registered.message",
|
||||
DevKitBundle.message(componentType.myPropertyKey)), fix);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static PsiClass findRegistrationType(@NotNull PsiClass checkedClass, @NotNull RegistrationCheckerUtil.RegistrationType type) {
|
||||
final Set<PsiClass> types = RegistrationCheckerUtil.getRegistrationTypes(checkedClass, type);
|
||||
return ContainerUtil.getFirstItem(types);
|
||||
|
||||
@@ -14,9 +14,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
public enum ComponentType {
|
||||
APPLICATION(BaseComponent.class, "application-components", "new.menu.application.component.text"),
|
||||
MODULE(ModuleComponent.class, "module-components", "new.menu.module.component.text"),
|
||||
PROJECT(ProjectComponent.class, "project-components", "new.menu.project.component.text"),
|
||||
MODULE(ModuleComponent.class, "module-components", "new.menu.module.component.text");
|
||||
APPLICATION(BaseComponent.class, "application-components", "new.menu.application.component.text");
|
||||
|
||||
public final String myClassName;
|
||||
public final String myPropertyKey;
|
||||
|
||||
Reference in New Issue
Block a user