package jetbrains.mps.ide.platform.actions; /*Generated by MPS */ import jetbrains.mps.ide.findusages.model.SearchResults; import org.jetbrains.mps.openapi.module.SModule; import com.intellij.openapi.project.Project; import jetbrains.mps.project.MPSProject; import jetbrains.mps.ide.platform.dependencyViewer.DependencyViewerScope; import jetbrains.mps.ide.platform.dependencyViewer.DependenciesPanel; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.internal.collections.runtime.IVisitor; public class DependenciesUtil { public DependenciesUtil() { } /** * * @deprecated FIXME both idea and mps project as arguments, really? introduce new one, with MPSProject only */ @Deprecated public static SearchResults analyzeDependencies(SModule from, SModule to, Project project, MPSProject mpsProject, boolean isMeta, boolean openTool) { DependencyViewerScope fromScope = new DependencyViewerScope(mpsProject.getRepository()); fromScope.add(from); DependencyViewerScope toScope = new DependencyViewerScope(mpsProject.getRepository()); toScope.add(to); AnalyzeDependenciesViewTool tool = project.getComponent(AnalyzeDependenciesViewTool.class); DependenciesPanel panel = as_ehks51_a0a6a1(tool.getComponent(), DependenciesPanel.class); panel.resetContent(fromScope, isMeta); panel.selectInTargetsView(to); if (openTool) { tool.openToolLater(true); } return panel.updateReferencesView(toScope); } public static SearchResults analyzeDependencies(Iterable<SModule> from, Iterable<SModule> to, Project project, MPSProject mpsProject, boolean isMeta) { final DependencyViewerScope fromScope = new DependencyViewerScope(mpsProject.getRepository()); final DependencyViewerScope toScope = new DependencyViewerScope(mpsProject.getRepository()); Sequence.fromIterable(from).visitAll(new IVisitor<SModule>() { public void visit(SModule it) { fromScope.add(it); } }); Sequence.fromIterable(to).visitAll(new IVisitor<SModule>() { public void visit(SModule it) { toScope.add(it); } }); AnalyzeDependenciesViewTool tool = project.getComponent(AnalyzeDependenciesViewTool.class); DependenciesPanel panel = as_ehks51_a0a6a2(tool.getComponent(), DependenciesPanel.class); panel.resetContent(fromScope, isMeta); panel.selectInTargetsView(Sequence.fromIterable(to).first()); tool.openToolLater(true); return panel.updateReferencesView(toScope); } public static void openDependenciesTool(Project ideaProject, DependencyViewerScope scope, boolean setActive) { AnalyzeDependenciesViewTool tool = ideaProject.getComponent(AnalyzeDependenciesViewTool.class); if (scope != null) { tool.setContent(scope); } tool.openToolLater(setActive); } private static <T> T as_ehks51_a0a6a1(Object o, Class<T> type) { return (type.isInstance(o) ? (T) o : null); } private static <T> T as_ehks51_a0a6a2(Object o, Class<T> type) { return (type.isInstance(o) ? (T) o : null); } }