use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class CyclicDependenciesTest method testT1.
public void testT1() {
// com.a<->com.b
final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, new AnalysisScope(myProject));
builder.analyze();
final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
HashMap<String, String[][]> expected = new HashMap<>();
expected.put("com.b", new String[][] { { "com.a", "com.b" } });
expected.put("com.a", new String[][] { { "com.b", "com.a" } });
checkResult(expected, cyclicDependencies);
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class CyclicDependenciesTest method testPackageScope2.
public void testPackageScope2() {
//com.b<->com.a - find
//com.c<->com.d - not in scope
final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, new JavaAnalysisScope(JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.subscope1"), null));
builder.analyze();
final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
HashMap<String, String[][]> expected = new HashMap<>();
expected.put("com.subscope1.b", new String[][] { { "com.subscope1.a", "com.subscope1.b" } });
expected.put("com.subscope1.a", new String[][] { { "com.subscope1.b", "com.subscope1.a" } });
checkResult(expected, cyclicDependencies);
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class CyclicDependenciesTest method testT3.
public void testT3() {
//com.b<->com.d
//com.b->com.a->com.c->com.b
final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, new AnalysisScope(myProject));
builder.analyze();
final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
HashMap<String, String[][]> expected = new HashMap<>();
expected.put("com.b", new String[][] { { "com.c", "com.a", "com.b" }, { "com.d", "com.b" } });
expected.put("com.d", new String[][] { { "com.b", "com.d" } });
expected.put("com.c", new String[][] { { "com.a", "com.b", "com.c" } });
expected.put("com.a", new String[][] { { "com.b", "com.c", "com.a" } });
checkResult(expected, cyclicDependencies, true);
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class CyclicDependenciesTest method checkResult.
private static void checkResult(HashMap<String, String[][]> expected, HashMap<PsiPackage, Set<List<PsiPackage>>> cycles, boolean forceContains) {
assertEquals(expected.size(), cycles.size());
for (final PsiPackage psiPackage : cycles.keySet()) {
assertTrue(expected.containsKey(psiPackage.getQualifiedName()));
final String packs = psiPackage.getQualifiedName();
if (forceContains) {
assertEquals(expected.get(packs).length, cycles.get(psiPackage).size());
}
for (final List<PsiPackage> cycle : cycles.get(psiPackage)) {
final String[][] expectedCycles = expected.get(packs);
final String[] string = new String[cycle.size()];
int i = 0;
for (final PsiPackage packageInCycle : cycle) {
string[i++] = packageInCycle.getQualifiedName();
}
assertTrue(findInMatrix(expectedCycles, string) > -1);
}
}
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class CyclicDependenciesTest method testPackageScope1.
public void testPackageScope1() {
// com.a<->com.b
final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, new JavaAnalysisScope(JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com"), null));
builder.analyze();
final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
HashMap<String, String[][]> expected = new HashMap<>();
expected.put("com.b", new String[][] { { "com.a", "com.b" } });
expected.put("com.a", new String[][] { { "com.b", "com.a" } });
checkResult(expected, cyclicDependencies);
}
Aggregations