From 55cfa89a4933f2452f12b37bda9cf4d983aa6ea8 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sun, 19 Jul 2020 16:47:32 +0200 Subject: [PATCH] fix assert if CompilerReferenceService is not enabled GitOrigin-RevId: fd2817b301958615f93a6d296ff91c7f53adf51d --- .../FrequentlyUsedInheritorInspection.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/inspection/FrequentlyUsedInheritorInspection.java b/java/compiler/impl/src/com/intellij/compiler/inspection/FrequentlyUsedInheritorInspection.java index f2a173264772..050a208c6fa1 100644 --- a/java/compiler/impl/src/com/intellij/compiler/inspection/FrequentlyUsedInheritorInspection.java +++ b/java/compiler/impl/src/com/intellij/compiler/inspection/FrequentlyUsedInheritorInspection.java @@ -111,18 +111,21 @@ public final class FrequentlyUsedInheritorInspection extends AbstractBaseJavaLoc } } - @NotNull - private static List getTopInheritorsUsingCompilerIndices(@NotNull PsiClass aClass, - @NotNull GlobalSearchScope searchScope, - @NotNull PsiElement place) { + private static @NotNull List getTopInheritorsUsingCompilerIndices(@NotNull PsiClass aClass, + @NotNull GlobalSearchScope searchScope, + @NotNull PsiElement place) { String qName = aClass.getQualifiedName(); - if (qName == null) return Collections.emptyList(); + if (qName == null) { + return Collections.emptyList(); + } - final Project project = aClass.getProject(); - CompilerReferenceServiceEx compilerRefService = (CompilerReferenceServiceEx)CompilerReferenceService.getInstance(project); + Project project = aClass.getProject(); + CompilerReferenceServiceEx compilerRefService = (CompilerReferenceServiceEx)CompilerReferenceService.getInstanceIfEnabled(project); try { - int id = compilerRefService.getNameId(qName); - if (id == 0) return Collections.emptyList(); + int id = compilerRefService == null ? 0 : compilerRefService.getNameId(qName); + if (id == 0) { + return Collections.emptyList(); + } return findInheritors(aClass, new CompilerRef.JavaCompilerClassRef(id), searchScope, place, -1, project, compilerRefService); } catch (ReferenceIndexUnavailableException e) { @@ -131,7 +134,7 @@ public final class FrequentlyUsedInheritorInspection extends AbstractBaseJavaLoc } private static List findInheritors(@NotNull PsiClass aClass, - @NotNull CompilerRef.JavaCompilerClassRef classAsCompilerRef, + @NotNull CompilerRef.CompilerClassHierarchyElementDef classAsCompilerRef, @NotNull GlobalSearchScope searchScope, @NotNull PsiElement place, int hierarchyCardinality, @@ -194,7 +197,7 @@ public final class FrequentlyUsedInheritorInspection extends AbstractBaseJavaLoc CompilerReferenceServiceEx compilerRefService) { if (classAndInheritorCount.psi.isInterface()) { return findInheritors(classAndInheritorCount.psi, - (CompilerRef.JavaCompilerClassRef)classAndInheritorCount.descriptor, + classAndInheritorCount.descriptor, searchScope, place, hierarchyCardinality,