static void Main(string[] args) { ShowCommandLine(args); //makes type table TypeTable tab = new TypeTable(); tab = makeTT(args); tab.show(); //makes types used table TypeTable tt = new TypeTable(); tt = makett(args); tt.show(); //Generating our adjacencry list AdjL e = new AdjL(); e = depAn(args); genStrongComp(args, e); Console.ReadKey(); }
//Helper function used for demonstrating the strong components found from the dependency analysis //by implmenting Tarjan's Algorithm for finding strongly connected components public static StringBuilder demoStrongComp(string[] args) { AdjL e = new AdjL(); e = depAn(args); return(genStrongComp(args, e)); }
public static StringBuilder demoStrongCompF(List <string> files) { AdjL e = new AdjL(); e = depAnF(files); return(genStrongCompF(files, e)); }
static AdjL depAnF(List <string> files) { //ShowCommandLine(args); //stores types and files they were used in //Depend depend = new Depend(); AdjL e = new AdjL(); // Storing edge list as list of tuples string,string //makes type table TypeTable tab = new TypeTable(); tab = makeTTF(files); //makes types used table TypeTable tt = new TypeTable(); tt = makettF(files); //We are gonna process and find namespaces we use in each file //Console.Write("\n Demonstrating NameSpace Finder"); //Console.Write("\n ===============================\n"); string[] toCheck = { "namespace", "class", "interface" }; foreach (var type in toCheck) { if (tab.table.ContainsKey(type)) { foreach (TypeItem val in tab.table[type]) // will have to do same for class { //Console.Write("\n [{0}, {1}]", val.namesp, val.file); foreach (var elem in tt.table) { foreach (var item in elem.Value) { //Console.Write("\n {0} [{1}, {2}]", elem.Key, item.namesp, item.file); if (val.namesp.Equals(item.namesp) && !val.file.Equals(item.file)) //checking if the current using is defined in some file { // important line=> //Console.Write("\n [{0} - USED IN - {1} - DEFINED IN - {2}]", item.namesp, item.file, val.file); e.Add(Tuple.Create(item.file, val.file)); } } } } } } Console.Write("\n"); //Console.ReadKey(); return(e); }
static StringBuilder genStrongCompF(List <string> filepaths, AdjL e) { StringBuilder msg = new StringBuilder(); msg.Append(Environment.NewLine + " Generating all the Components"); msg.Append(Environment.NewLine + " ======================="); var graph_nodes = new List <Vertex>(); var v = new List <Vertex>();; List <string> files = new List <string>(); //List<string> filepaths = ProcessCommandline(args); foreach (string file in filepaths) { string[] fullname = file.Split('\\'); files.Add(fullname[fullname.Length - 1]); } for (int i = 0; i < files.Count; i++) { Vertex ver = new Vertex() { Id = i, Name = files[i] }; v.Add(ver); } foreach (var node in v) // my nodes { foreach (var n in e) // the file name in tuple list { if (node.Name == n.Item1) //if node name == name in tuple { foreach (var targenode in v) // found the target node { if (targenode.Name == n.Item2) { if (!node.Dependencies.Any(child => child.Name == targenode.Name)) { node.Dependencies.Add(targenode); } } } } } } foreach (var node in v) // my nodes { graph_nodes.Add(node); } var tcd = new TarjanCycleDetectStack(); var cycle_list = tcd.DetectCycle(graph_nodes); msg.Append(Environment.NewLine + "Total number of components: " + cycle_list.Count + Environment.NewLine); foreach (var vertices in cycle_list) { //Console.WriteLine(v); foreach (var ver in vertices) { msg.Append(ver.ToString() + " "); // Console.WriteLine(string.Join(" ", v.Dependencies)); } msg.Append(Environment.NewLine); } //Console.ReadKey(); return(msg); }