protected override void InternalHandle(Output result, string args, DependencyGraph graph) { var projectsFiltered = new HashSet<Library>(FilterLibs(graph, args)); var projs = graph.Edges.Where(e => e.Source.Equals(e.Target)) .Select(e => e.Source) .Where(projectsFiltered.Contains) .ToList(); if (!projs.Any()) { result.AppendLine("No project/library that depends on itself found"); } else { projs.ForEach(lib => { var proj = lib as Project; if (proj != null) result.AppendLine("{0} (project path: {1})", GetName(proj), proj.ProjectPath); else result.AppendLine(GetName(lib)); }); } }
private void OutputInfo(Output result, Library lib) { result.AppendLine(GetName(lib) + ":"); result.IncreaseIndent(); var proj = lib as Project; if (proj != null) { WriteProperty(result, "Type", "Project"); WriteProperty(result, "Project name", proj.ProjectName); WriteProperty(result, "Library name", proj.LibraryName); WriteProperty(result, "Project path", proj.ProjectPath); WriteProperty(result, "GUID", proj.Guid != null ? proj.Guid.ToString() : "missing"); } else { WriteProperty(result, "Type", "Library"); WriteProperty(result, "Library name", lib.LibraryName); } if (lib.GroupElement != null) WriteProperty(result, "Group", lib.GroupElement.Name); lib.Languages.ForEach(p => WriteProperty(result, "Language", p)); var projectPath = (lib is Project ? ((Project) lib).ProjectPath : null); lib.Paths.Where(p => p != projectPath) .ForEach(p => WriteProperty(result, "Path", p)); result.DecreaseIndent(); result.AppendLine(); }
private bool OutputPath(Output result, DependencyGraph graph, Library source, Library target) { var tryGetPaths = graph.ShortestPathsDijkstra(e => 1, source); IEnumerable<Dependency> path; if (!tryGetPaths(target, out path)) return false; try { result.AppendLine("Path between {0} and {1}:", GetName(source), GetName(target)); result.IncreaseIndent(); Output.LineOutput line = result.StartLine(); line.Append(GetName(source)); foreach (Dependency edge in path) line.Append(" -> ") .Append(GetName(edge.Target)); line.EndLine(); } finally { result.DecreaseIndent(); result.AppendLine(); } return true; }
private void OutputReferences(Output result, DependencyGraph graph, Library lib, string type) { result.AppendLine(GetName(lib) + ":"); var directDeps = new HashSet<Library>(graph.OutEdges(lib) .Select(d => d.Target)); result.IncreaseIndent(); result.AppendLine("Direct " + type + ":"); result.IncreaseIndent(); Output(result, directDeps); result.DecreaseIndent(); result.DecreaseIndent(); if (directDeps.Any()) { var indirectDeps = ComputeIndirectDeps(graph, lib) .Where(d => !directDeps.Contains(d)) // ReSharper disable once PossibleUnintendedReferenceComparison .Where(d => d != lib); result.IncreaseIndent(); result.AppendLine("Indirect " + type + ":"); result.IncreaseIndent(); Output(result, indirectDeps); result.DecreaseIndent(); result.DecreaseIndent(); } result.AppendLine(); }
protected override void InternalHandle(Output result, string args, DependencyGraph graph) { var libs = FilterLibs(graph, args); if (!libs.Any()) result.AppendLine("No libraries found"); else libs.SortBy(Library.NaturalOrdering) .ForEach(l => result.AppendLine(GetName(l))); }
protected override void InternalHandle(Output result, string args, DependencyGraph graph) { if (args == "") { result.AppendLine("You need to specify a filter for the libraries"); return; } OutputReferences(result, args, graph, "references"); }
protected void OutputReferences(Output result, string args, DependencyGraph graph, string type) { var libs = FilterLibs(graph, args); if (!libs.Any()) result.AppendLine("No libraries found"); else libs.SortBy(Library.NaturalOrdering) .ForEach(l => OutputReferences(result, graph, l, type)); }
private void Output(Output result, IEnumerable<Library> depsList) { var deps = depsList as IList<Library> ?? depsList.ToList(); if (!deps.Any()) result.AppendLine("none found"); else deps.SortBy(Library.NaturalOrdering) .ForEach(l => result.AppendLine(GetName(l))); }
public bool Handle(string line, DependencyGraph graph) { if (!line.StartsWith(Name)) return false; var result = new Output(" "); InternalHandle(result, new ConfigParser().ParseLines("-", new[] { line }), graph); result.ToConsole(); return true; }
public bool Handle(string line, DependencyGraph graph) { if (!IsCommandOrShortcut(line, Name)) return false; var args = RemoveCommand(line, Name); var result = new Output(" "); InternalHandle(result, args, graph); result.ToConsole(); return true; }
protected override void InternalHandle(Output result, string args, DependencyGraph graph) { if (args == "") { result.AppendLine("You need to specify a filter for the libraries"); return; } var libs = FilterLibs(graph, args); if (!libs.Any()) result.AppendLine("No libraries found"); else libs.SortBy(Library.NaturalOrdering) .ForEach(l => OutputInfo(result, l)); }
private static void DumpGroups(IEnumerable<Library> projects, List<string> filenames) { if (!filenames.Any()) return; var result = new Output(" - "); ConsoleOutputer.GroupsToConsole(result, projects); string text = result.ToString(); foreach (string filename in filenames) { // ReSharper disable once AssignNullToNotNullAttribute Directory.CreateDirectory(Path.GetDirectoryName(filename)); File.WriteAllText(filename, text); } }
protected override void InternalHandle(Output result, string args, DependencyGraph graph) { var projctsFiltered = FilterLibs(graph, args); IDictionary<Library, int> components; graph.StronglyConnectedComponents(out components); var circularDependencies = components.Select(c => new { Proj = c.Key, Group = c.Value }) .GroupBy(c => c.Group) .Where(g => g.Count() > 1); bool found = false; foreach (var g in circularDependencies) { var libs = g.Select(i => i.Proj) .ToList(); var projsSet = new HashSet<Library>(libs); if (!projsSet.Intersect(projctsFiltered) .Any()) continue; found = true; libs.Sort(Library.NaturalOrdering); result.AppendLine("Circular dependency:"); result.IncreaseIndent(); foreach (var lib in libs) { var proj = lib as Project; if (proj != null) result.AppendLine("{0} (project path: {1})", GetName(proj), proj.ProjectPath); else result.AppendLine(GetName(lib)); } result.DecreaseIndent(); result.AppendLine(); } if (!found) result.AppendLine("No circular dependency found"); }
protected override void InternalHandle(Output result, Config config, DependencyGraph graph) { var matches = RulesMatcher.Match(graph, config.Rules); if (!matches.Any()) { result.AppendLine("No matches found"); return; } foreach (var m in matches) { ConsoleEntryOutputer.ToConsole(m, false) .Split('\n') .ForEach(l => result.AppendLine(l)); result.AppendLine(); } }
public static string GroupsToConsole(Output result, IEnumerable<Library> projects) { var groups = projects.GroupBy(p => p.GroupElement) .ToList(); groups.Sort((e1, e2) => { GroupElement g1 = e1.Key; GroupElement g2 = e2.Key; if (Equals(g1, g2)) return 0; if (g1 == null) return 1; if (g2 == null) return -1; return string.Compare(g1.Name, g2.Name, StringComparison.CurrentCultureIgnoreCase); }); groups.ForEach(g => { result.AppendLine((g.Key != null ? g.Key.Name : "Without a group") + ":"); result.IncreaseIndent(); List<Library> projs = g.ToList(); projs.Sort(Library.NaturalOrdering); projs.ForEach(p => result.AppendLine(ProjectGlance(p))); result.DecreaseIndent(); result.AppendLine(); }); return result.ToString(); }
protected override void InternalHandle(Output result, string anArgs, DependencyGraph graph) { List<string> args = anArgs.Split(new[] { "->" }, StringSplitOptions.None) .Select(e => e.Trim()) .ToList(); if (args.Count != 2) { result.AppendLine("You must specify 2 libraries, separated by ->"); return; } List<Library> libs0 = FilterLibs(graph, args[0]); List<Library> libs1 = FilterLibs(graph, args[1]); if (!libs0.Any() || !libs1.Any()) { if (!libs0.Any()) result.AppendLine("No projects found matching {0}", args[0]); if (!libs1.Any()) result.AppendLine("No projects found matching {0}", args[1]); return; } bool found = false; foreach (Library source in libs0) { foreach (Library target in libs1) { found = OutputPath(result, graph, source, target) || found; found = OutputPath(result, graph, target, source) || found; } } if (!found) result.AppendLine("No path found"); }
private void WriteProperty(Output result, string name, string value) { result.AppendLine(name + ": " + value); }
protected override void InternalHandle(Output result, string args, DependencyGraph graph) { throw new QuitException(); }
protected abstract void InternalHandle(Output result, Config config, DependencyGraph graph);
protected override void InternalHandle(Output result, string args, DependencyGraph graph) { List<Library> libs = FilterLibs(graph, args); ConsoleOutputer.GroupsToConsole(result, libs); }
protected abstract void InternalHandle(Output result, string args, DependencyGraph graph);