Search in sources :

Example 6 with CyclicDependenciesBuilder

use of com.intellij.cyclicDependencies.CyclicDependenciesBuilder 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);
}
Also used : JavaAnalysisScope(com.intellij.analysis.JavaAnalysisScope) CyclicDependenciesBuilder(com.intellij.cyclicDependencies.CyclicDependenciesBuilder) PsiPackage(com.intellij.psi.PsiPackage)

Example 7 with CyclicDependenciesBuilder

use of com.intellij.cyclicDependencies.CyclicDependenciesBuilder 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);
}
Also used : JavaAnalysisScope(com.intellij.analysis.JavaAnalysisScope) AnalysisScope(com.intellij.analysis.AnalysisScope) CyclicDependenciesBuilder(com.intellij.cyclicDependencies.CyclicDependenciesBuilder) PsiPackage(com.intellij.psi.PsiPackage)

Example 8 with CyclicDependenciesBuilder

use of com.intellij.cyclicDependencies.CyclicDependenciesBuilder 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);
}
Also used : JavaAnalysisScope(com.intellij.analysis.JavaAnalysisScope) CyclicDependenciesBuilder(com.intellij.cyclicDependencies.CyclicDependenciesBuilder) PsiPackage(com.intellij.psi.PsiPackage)

Example 9 with CyclicDependenciesBuilder

use of com.intellij.cyclicDependencies.CyclicDependenciesBuilder in project intellij-community by JetBrains.

the class CyclicDependenciesTest method testT5.

public void testT5() {
    //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.d", "com.b" }, { "com.c", "com.a", "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);
}
Also used : JavaAnalysisScope(com.intellij.analysis.JavaAnalysisScope) AnalysisScope(com.intellij.analysis.AnalysisScope) CyclicDependenciesBuilder(com.intellij.cyclicDependencies.CyclicDependenciesBuilder) PsiPackage(com.intellij.psi.PsiPackage)

Example 10 with CyclicDependenciesBuilder

use of com.intellij.cyclicDependencies.CyclicDependenciesBuilder in project intellij-community by JetBrains.

the class CyclicDependenciesHandler method analyze.

public void analyze() {
    final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, myScope);
    final Runnable process = () -> builder.analyze();
    final Runnable successRunnable = () -> SwingUtilities.invokeLater(() -> {
        CyclicDependenciesPanel panel = new CyclicDependenciesPanel(myProject, builder);
        Content content = ContentFactory.SERVICE.getInstance().createContent(panel, AnalysisScopeBundle.message("action.analyzing.cyclic.dependencies.in.scope", builder.getScope().getDisplayName()), false);
        content.setDisposer(panel);
        panel.setContent(content);
        DependenciesToolWindow.getInstance(myProject).addContent(content);
    });
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(myProject, AnalysisScopeBundle.message("package.dependencies.progress.title"), process, successRunnable, null, new PerformAnalysisInBackgroundOption(myProject));
}
Also used : CyclicDependenciesBuilder(com.intellij.cyclicDependencies.CyclicDependenciesBuilder) Content(com.intellij.ui.content.Content) CyclicDependenciesPanel(com.intellij.cyclicDependencies.ui.CyclicDependenciesPanel) PerformAnalysisInBackgroundOption(com.intellij.analysis.PerformAnalysisInBackgroundOption)

Aggregations

CyclicDependenciesBuilder (com.intellij.cyclicDependencies.CyclicDependenciesBuilder)10 JavaAnalysisScope (com.intellij.analysis.JavaAnalysisScope)9 PsiPackage (com.intellij.psi.PsiPackage)9 AnalysisScope (com.intellij.analysis.AnalysisScope)7 PerformAnalysisInBackgroundOption (com.intellij.analysis.PerformAnalysisInBackgroundOption)1 CyclicDependenciesPanel (com.intellij.cyclicDependencies.ui.CyclicDependenciesPanel)1 Content (com.intellij.ui.content.Content)1