Search in sources :

Example 6 with DependenciesBuilder

use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.

the class AnalyzeDependenciesOnSpecifiedTargetHandler method shouldShowDependenciesPanel.

@Override
protected boolean shouldShowDependenciesPanel(List<DependenciesBuilder> builders) {
    for (DependenciesBuilder builder : builders) {
        for (Set<PsiFile> files : builder.getDependencies().values()) {
            if (!files.isEmpty()) {
                return true;
            }
        }
    }
    final String source = StringUtil.decapitalize(getForwardScope(builders).getDisplayName());
    final String target = StringUtil.decapitalize(myTargetScope.getDisplayName());
    String message = AnalysisScopeBundle.message("no.dependencies.found.message", source, target);
    if (DependencyVisitorFactory.VisitorOptions.fromSettings(myProject).skipImports()) {
        message += " ";
        message += AnalysisScopeBundle.message("dependencies.in.imports.message");
    }
    NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(myProject);
    return false;
}
Also used : DependenciesBuilder(com.intellij.packageDependencies.DependenciesBuilder) BackwardDependenciesBuilder(com.intellij.packageDependencies.BackwardDependenciesBuilder) PsiFile(com.intellij.psi.PsiFile)

Example 7 with DependenciesBuilder

use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.

the class DependenciesHandlerBase method perform.

private void perform(List<DependenciesBuilder> builders) {
    try {
        PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
        for (AnalysisScope scope : myScopes) {
            builders.add(createDependenciesBuilder(scope));
        }
        for (DependenciesBuilder builder : builders) {
            builder.analyze();
        }
        snapshot.logResponsivenessSinceCreation("Dependency analysis");
    } catch (IndexNotReadyException e) {
        DumbService.getInstance(myProject).showDumbModeNotification("Analyze dependencies is not available until indices are ready");
        throw new ProcessCanceledException();
    }
}
Also used : PerformanceWatcher(com.intellij.diagnostic.PerformanceWatcher) AnalysisScope(com.intellij.analysis.AnalysisScope) DependenciesBuilder(com.intellij.packageDependencies.DependenciesBuilder) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 8 with DependenciesBuilder

use of com.intellij.packageDependencies.DependenciesBuilder in project intellij-community by JetBrains.

the class UsagesInAnalyzingDependenciesTest method testForwardSimple.

@SuppressWarnings("ConstantConditions")
public void testForwardSimple() {
    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 bClass = myJavaFacade.findClass("B", GlobalSearchScope.allScope(myProject));
    searchFor.add(bClass.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 B myB = new B();", "2 B myB = new B();", "4 myB.bb();" }, psiUsages);
}
Also used : DependenciesBuilder(com.intellij.packageDependencies.DependenciesBuilder) ForwardDependenciesBuilder(com.intellij.packageDependencies.ForwardDependenciesBuilder) BackwardDependenciesBuilder(com.intellij.packageDependencies.BackwardDependenciesBuilder) PsiClass(com.intellij.psi.PsiClass) JavaAnalysisScope(com.intellij.analysis.JavaAnalysisScope) AnalysisScope(com.intellij.analysis.AnalysisScope) UsageInfo2UsageAdapter(com.intellij.usages.UsageInfo2UsageAdapter) PsiFile(com.intellij.psi.PsiFile) ForwardDependenciesBuilder(com.intellij.packageDependencies.ForwardDependenciesBuilder) UsageInfo(com.intellij.usageView.UsageInfo) HashSet(java.util.HashSet)

Aggregations

DependenciesBuilder (com.intellij.packageDependencies.DependenciesBuilder)8 BackwardDependenciesBuilder (com.intellij.packageDependencies.BackwardDependenciesBuilder)5 ForwardDependenciesBuilder (com.intellij.packageDependencies.ForwardDependenciesBuilder)5 PsiFile (com.intellij.psi.PsiFile)5 JavaAnalysisScope (com.intellij.analysis.JavaAnalysisScope)4 PsiClass (com.intellij.psi.PsiClass)4 UsageInfo (com.intellij.usageView.UsageInfo)4 UsageInfo2UsageAdapter (com.intellij.usages.UsageInfo2UsageAdapter)4 HashSet (java.util.HashSet)4 AnalysisScope (com.intellij.analysis.AnalysisScope)3 PsiPackage (com.intellij.psi.PsiPackage)2 PerformAnalysisInBackgroundOption (com.intellij.analysis.PerformAnalysisInBackgroundOption)1 PerformanceWatcher (com.intellij.diagnostic.PerformanceWatcher)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 DependenciesPanel (com.intellij.packageDependencies.ui.DependenciesPanel)1 ArrayList (java.util.ArrayList)1