use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class CyclicDependenciesBuilder method analyze.
public void analyze() {
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(getProject()).getFileIndex();
getScope().accept(new PsiRecursiveElementVisitor() {
@Override
public void visitFile(PsiFile file) {
if (file instanceof PsiJavaFile) {
PsiJavaFile psiJavaFile = (PsiJavaFile) file;
if (getScope().contains(psiJavaFile)) {
final PsiPackage aPackage = findPackage(psiJavaFile.getPackageName());
if (aPackage != null) {
myPackages.put(psiJavaFile.getPackageName(), aPackage);
}
}
final Set<PsiPackage> packs = getPackageHierarhy(psiJavaFile.getPackageName());
final ForwardDependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), new AnalysisScope(psiJavaFile));
builder.setTotalFileCount(getScope().getFileCount());
builder.setInitialFileCount(++myFileCount);
builder.analyze();
final Set<PsiFile> psiFiles = builder.getDependencies().get(psiJavaFile);
if (psiFiles == null)
return;
for (PsiPackage pack : packs) {
Set<PsiPackage> pack2Packages = myPackageDependencies.get(pack);
if (pack2Packages == null) {
pack2Packages = new HashSet<>();
myPackageDependencies.put(pack, pack2Packages);
}
for (PsiFile psiFile : psiFiles) {
if (!(psiFile instanceof PsiJavaFile) || !projectFileIndex.isInSourceContent(psiFile.getVirtualFile()) || !getScope().contains(psiFile)) {
continue;
}
// construct dependent packages
final String packageName = ((PsiJavaFile) psiFile).getPackageName();
//do not depend on parent packages
if (packageName.startsWith(pack.getQualifiedName())) {
continue;
}
final PsiPackage depPackage = findPackage(packageName);
if (depPackage == null) {
//not from analyze scope
continue;
}
pack2Packages.add(depPackage);
constractFilesInDependenciesPackagesMap(pack, depPackage, psiFile, myFilesInDependentPackages);
constractFilesInDependenciesPackagesMap(depPackage, pack, psiJavaFile, myBackwardFilesInDependentPackages);
constractWholeDependenciesMap(psiJavaFile, psiFile);
}
}
}
}
});
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
if (indicator.isCanceled()) {
throw new ProcessCanceledException();
}
indicator.setText(AnalysisScopeBundle.message("cyclic.dependencies.progress.text"));
indicator.setText2("");
indicator.setIndeterminate(true);
}
myCyclicDependencies = getCycles(myPackages.values());
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class SliceForwardTest method dotest.
private void dotest() throws Exception {
configureByFile("/codeInsight/slice/forward/" + getTestName(false) + ".java");
Map<String, RangeMarker> sliceUsageName2Offset = SliceTestUtil.extractSliceOffsetsFromDocument(getEditor().getDocument());
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
PsiElement element = new SliceForwardHandler().getExpressionAtCaret(getEditor(), getFile());
assertNotNull(element);
SliceTestUtil.calcRealOffsets(element, sliceUsageName2Offset, myFlownOffsets);
Collection<HighlightInfo> errors = highlightErrors();
assertEmpty(errors);
SliceAnalysisParams params = new SliceAnalysisParams();
params.scope = new AnalysisScope(getProject());
params.dataFlowToThis = false;
SliceUsage usage = LanguageSlicing.getProvider(element).createRootUsage(element, params);
SliceTestUtil.checkUsages(usage, myFlownOffsets);
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class AnalyzeDependenciesOnSpecifiedTargetAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Module module = e.getData(LangDataKeys.MODULE_CONTEXT);
final GlobalSearchScope targetScope = e.getData(TARGET_SCOPE_KEY);
if (module == null || targetScope == null)
return;
new AnalyzeDependenciesOnSpecifiedTargetHandler(module.getProject(), new AnalysisScope(module), targetScope).analyze();
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class BackwardDependenciesAction method analyze.
@Override
protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) {
//find library usages in project
scope.setSearchInLibraries(true);
final SearchScope selectedScope = myPanel.myCombo.getSelectedScope();
new BackwardDependenciesHandler(project, scope, selectedScope != null ? new AnalysisScope(selectedScope, project) : new AnalysisScope(project)).analyze();
dispose();
}
use of com.intellij.analysis.AnalysisScope 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();
}
}
Aggregations