void () { setupLoadingFilter(); final GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(myModule); PsiClass enumClass = findClass("enums.OurEnumWithInitializedConstants"); assertTrue(enumClass.isEnum()); PsiField[] fields = enumClass.getFields(); assertEquals(3, fields.length); assertTrue(fields[0] instanceof PsiEnumConstant); assertTrue(fields[1] instanceof PsiEnumConstant); assertTrue(fields[2] instanceof PsiEnumConstant); PsiAnonymousClass initializingClass0 = ((PsiEnumConstant)fields[0]).getInitializingClass(); assertNotNull(initializingClass0); PsiClass baseClass0 = initializingClass0.getBaseClassType().resolve(); assertTrue(baseClass0 == enumClass); PsiAnonymousClass initializingClass1 = ((PsiEnumConstant)fields[1]).getInitializingClass(); assertNotNull(initializingClass1); PsiClass baseClass1 = initializingClass1.getBaseClassType().resolve(); assertTrue(baseClass1 == enumClass); PsiAnonymousClass initializingClass2 = ((PsiEnumConstant)fields[1]).getInitializingClass(); assertNotNull(initializingClass2); PsiClass baseClass2 = initializingClass2.getBaseClassType().resolve(); assertTrue(baseClass2 == enumClass); assertTrue(initializingClass0.isInheritor(enumClass, false)); assertTrue(initializingClass1.isInheritor(enumClass, false)); assertTrue(initializingClass2.isInheritor(enumClass, false)); final PsiClass[] enumInheritors = ClassInheritorsSearch.search(enumClass, moduleScope, false).toArray(PsiClass.EMPTY_ARRAY); assertEquals(3, enumInheritors.length); assertTrue(Arrays.asList(enumInheritors).contains(initializingClass0)); assertTrue(Arrays.asList(enumInheritors).contains(initializingClass1)); assertTrue(Arrays.asList(enumInheritors).contains(initializingClass2)); PsiMethod[] methods1 = initializingClass2.getMethods(); assertEquals(1, methods1.length); assertEquals("foo", methods1[0].getName()); final PsiClass baseInterfaceClass = findClass("enums.OurBaseInterface"); final PsiClass[] inheritors = ClassInheritorsSearch.search(baseInterfaceClass, moduleScope, false).toArray(PsiClass.EMPTY_ARRAY); assertEquals(1, inheritors.length); assertTrue(inheritors[0] instanceof PsiAnonymousClass); tearDownLoadingFilter(); assertTrue(inheritors[0].getParent().getParent() instanceof PsiExpressionList); assertTrue(inheritors[0].getParent().getParent().getParent() == fields[2]); final PsiExpressionList argumentList = ((PsiEnumConstant)fields[2]).getArgumentList(); assertNotNull(argumentList); final PsiExpression[] expressions2 = argumentList.getExpressions(); assertEquals(1, expressions2.length); assertTrue(expressions2[0] instanceof PsiNewExpression); final PsiAnonymousClass anonymousClass2 = ((PsiNewExpression)expressions2[0]).getAnonymousClass(); assertTrue(anonymousClass2 != null); assertTrue(anonymousClass2.isInheritor(baseInterfaceClass, false)); }