use of com.intellij.packageDependencies.BackwardDependenciesBuilder in project intellij-community by JetBrains.
the class UsagesInAnalyzingDependenciesTest method testBackwardPackageScope.
@SuppressWarnings("ConstantConditions")
public void testBackwardPackageScope() {
PsiPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.a");
DependenciesBuilder builder = new BackwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
builder.analyze();
Set<PsiFile> searchFor = new HashSet<>();
searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
Set<PsiFile> searchIn = new HashSet<>();
PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
searchIn.add(bClass.getContainingFile());
PsiClass cClass = myJavaFacade.findClass("com.a.C", GlobalSearchScope.allScope(myProject));
searchFor.add(cClass.getContainingFile());
UsageInfo[] usagesInfos = FindDependencyUtil.findBackwardDependencies(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[] { "4 A myA = new A();", "4 A myA = new A();", "5 C myC = new C();", "5 C myC = new C();", "7 myA.aa();", "8 myC.cc();" }, psiUsages);
}
Aggregations