use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.
the class DependenciesPanelTest method doTestDependenciesTrees.
private void doTestDependenciesTrees(AnalysisScope scope, String expectedLeftTree, String expectedRightTree) {
DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, scope);
builder.analyze();
DependenciesPanel dependenciesPanel = new DependenciesPanel(myProject, builder);
try {
JTree leftTree = dependenciesPanel.getLeftTree();
TreeUtil.expandAll(leftTree);
PlatformTestUtil.assertTreeEqual(leftTree, expectedLeftTree, true);
JTree rightTree = dependenciesPanel.getRightTree();
TreeUtil.expandAll(rightTree);
PlatformTestUtil.assertTreeEqual(rightTree, expectedRightTree, true);
} finally {
Disposer.dispose(dependenciesPanel);
}
}
use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.
the class UsagesInAnalyzingDependenciesTest method testForwardPackageScope.
@SuppressWarnings("ConstantConditions")
public void testForwardPackageScope() {
PsiPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.b");
DependenciesBuilder builder = new ForwardDependenciesBuilder(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.b.C", GlobalSearchScope.allScope(myProject));
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);
}
use of com.intellij.packageDependencies.DependenciesBuilder 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);
}
use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.
the class UsagesInAnalyzingDependenciesTest method testForwardJdkClasses.
@SuppressWarnings("ConstantConditions")
public void testForwardJdkClasses() {
DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new AnalysisScope(myProject));
builder.analyze();
Set<PsiFile> searchIn = new HashSet<>();
PsiClass aClass = myJavaFacade.findClass("A", GlobalSearchScope.allScope(myProject));
searchIn.add(aClass.getContainingFile());
Set<PsiFile> searchFor = new HashSet<>();
PsiClass stringClass = myJavaFacade.findClass("java.lang.String", GlobalSearchScope.allScope(myProject));
searchFor.add((PsiFile) stringClass.getContainingFile().getNavigationElement());
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 String myName;" }, psiUsages);
}
use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.
the class DependenciesHandlerBase method analyze.
public void analyze() {
final List<DependenciesBuilder> builders = new ArrayList<>();
final Task task;
if (canStartInBackground()) {
task = new Task.Backgroundable(myProject, getProgressTitle(), true, new PerformAnalysisInBackgroundOption(myProject)) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
perform(builders);
}
@Override
public void onSuccess() {
DependenciesHandlerBase.this.onSuccess(builders);
}
};
} else {
task = new Task.Modal(myProject, getProgressTitle(), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
perform(builders);
}
@Override
public void onSuccess() {
DependenciesHandlerBase.this.onSuccess(builders);
}
};
}
ProgressManager.getInstance().run(task);
}
Aggregations