void () { PsiPackage bPackage = JavaPsiFacade.getInstance(getProject()).findPackage("com.b"); DependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), new JavaAnalysisScope(bPackage, null)); builder.analyze(); Set<PsiFile> searchFor = new HashSet<>(); searchFor.add(myFixture.findClass("com.a.A").getContainingFile()); Set<PsiFile> searchIn = new HashSet<>(); PsiClass bClass = myFixture.findClass("com.b.B"); searchIn.add(bClass.getContainingFile()); PsiClass cClass = myFixture.findClass("com.b.C"); searchIn.add(cClass.getContainingFile()); UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor); UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos); String[] psiUsages = new String[usagesInfos.length]; for (int i = 0; i < usagesInfos.length; i++) { psiUsages[i] = toString(usages[i]); } checkResult(new String[]{ "2 import com.a.A;", "4 A myA = new A();", "4 A myA = new A();", "6 myA.aa();", "2 import com.a.A;", "4 A myA = new A();", "4 A myA = new A();", "6 myA.aa();"}, psiUsages); }