void () { PsiClass aClass = myFixture.addClass("class Foo {}"); myFixture.addFileToProject("Bar.groovy", "class Bar { void m() { new Foo(); }}"); Project project = myFixture.getProject(); GlobalInspectionContext context = InspectionManager.getInstance(project).createNewGlobalContext(); ((GlobalInspectionContextBase)context).initializeTools(new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); RefManagerImpl refManager = new RefManagerImpl(project, new AnalysisScope(project), context); refManager.findAllDeclarations(); RefElement refClass = refManager.getReference(aClass); Collection<RefElement> fileReferences = ContainerUtil.filter(refClass.getInReferences(), x -> x instanceof RefFile); RefElement referent = assertOneElement(fileReferences); RefFile groovyFile = assertInstanceOf(referent, RefFile.class); assertEquals("Bar.groovy", groovyFile.getName()); }