public void testAnnotationIndex() throws Exception {
    getJavaFacade()
        .setAssertOnFileLoadingFilter(
            new VirtualFileFilter() {
              @Override
              public boolean accept(final VirtualFile file) {
                return !"package-info.java".equals(file.getName());
              }
            });

    final PsiClass annotationTypeClass =
        myJavaFacade.findClass(
            "annotations.AnnotationType", GlobalSearchScope.moduleScope(myModule));
    assertNotNull(annotationTypeClass);
    assertTrue(annotationTypeClass.isAnnotationType());

    final Collection<PsiMember> all =
        AnnotatedMembersSearch.search(annotationTypeClass, GlobalSearchScope.moduleScope(myModule))
            .findAll();

    assertEquals(2, all.size());
    Set<String> correctNames =
        new HashSet<String>(Arrays.asList("AnnotatedClass", "correctMethod"));
    for (PsiMember member : all) {
      assertTrue(correctNames.contains(member.getName()));
    }

    final Collection<PsiPackage> packages =
        AnnotatedPackagesSearch.search(annotationTypeClass, GlobalSearchScope.moduleScope(myModule))
            .findAll();
    assertEquals(1, packages.size());
    assertEquals("annotated", packages.iterator().next().getQualifiedName());

    teardownLoadingFilter();
  }
 private void doTest() throws IOException {
   myFixture.configureByFile(getFileName());
   List<String> directives =
       InTextDirectivesUtils.findListWithPrefixes(
           FileUtil.loadFile(new File(getPathToFile())), "// ANNOTATION: ");
   assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty());
   String annotationClassName = directives.get(0);
   PsiClass psiClass = getPsiClass(annotationClassName);
   checkResult(AnnotatedMembersSearch.search(psiClass, getProjectScope()));
 }