//To Display DepAnalysis between files public void DisplayDep(String DepFile, String ProcessFile) { // String ReceivedFile = null; // String ProFile = null; if (ReceivedFile != DepFile && ProFile != ProcessFile) { ReceivedFile = DepFile; ProFile = ProcessFile; Console.WriteLine("\nIndex " + i + ":"); Console.Write("\n Filename :" + System.IO.Path.GetFileName(ProcessFile)); string parent_file = System.IO.Path.GetFileName(ProcessFile); if (DepResult.ContainsKey(parent_file)) { DepResult[parent_file].Add(ReceivedFile); } else { List <string> temp = new List <string>(); temp.Add(DepFile); DepResult.Add(parent_file, temp); } Console.Write("\n\t Dependency:" + DepFile); //Passing Value to find strong Component int parent, child; FileNames.TryGetValue(DepFile, out child); FileNames.TryGetValue(ProcessFile, out parent); StrongComp.setDependency(parent, child); } }
public void Requirement6() { Console.Write("\n\t \tOutput of Requirement6\n"); Console.Write("-----------------------------------------------------------------------------\n"); Console.Write(" This Project3 finds all strong components, if any, in the file collection, based on the DependendAnalysis\n"); StrongComp.displayStrongComponent(); }
public void Requirement6() { Console.Write("\n\t \tOutput of Requirement6\n"); Console.Write("-----------------------------------------------------------------------------\n"); Console.Write(" This Project3 finds all strong components, if any, in the file collection, based on the DependendAnalysis\n"); Console.Write(" and according to Tarjan Algorithm any node having dependency on itself is a strong component\n"); StrongComp.displayStrongComponent(); }
public void Requirement4_5(string[] args) { Console.Write("\n\t \tOutput of Requirement4\n"); Console.Write("-----------------------------------------------------------------------------\n"); Console.Write("This Project3 implements packages that evaluate all the dependencies between files in a specified file set"); ShowCommandLine(args); List <string> files = ProcessCommandline(args); Executive test = new Executive(); test.Execute_Parser(files); test.Execute_TypeAnalyzer(); DepAnalysis.DepAnalysis dep = new DepAnalysis.DepAnalysis(); StrongComp.filesGraphs = files; StrongComp.filenumber = files.Count(); StrongComp.setGraph(); DepAnalysis.DepAnalysis.filesDepAnalysis = files; StrongComp.filesGraph = files; DepAnalysis.DepAnalysis.setDictionary(); StrongComp.setGraphDictionary(); Console.Write("\nDemonstrating Output Of Dependency Analysis"); Console.Write("\n =========================================="); foreach (string file in files) { ITokenCollection semi = Factory.create(); if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", files[0]); return; } try { while (semi.get().Count > 0) { dep.HoldUsingValue(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } semi.close(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", files[0]); return; } try { while (semi.get().Count > 0) { dep.analyze(semi, file); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } StrongComp.addGraph(); semi.close(); } Console.Write("\n\n"); }
//----< Test Stub >-------------------------------------------------- static void Main(string[] args) { Console.Write("\n Demonstrating StrongComponent"); Console.Write("\n ===================================="); ShowCommandLine(args); List <string> files = TestParser.ProcessCommandline(args); StrongComp.filesGraph = files; StrongComp.filesGraphs = files; StrongComp.filenumber = files.Count(); StrongComp.setGraph(); StrongComp.filesGraph = files; StrongComp.setGraphDictionary(); foreach (string file in files) { StrongComp.addGraph(); } Console.Write("\n\n"); }
/*----< define how each message will be processed >------------*/ void initializeDispatcher() { Func <CommMessage, CommMessage> getTopFiles = (CommMessage msg) => { localFileMgr.currentPath = ""; CommMessage reply = new CommMessage(CommMessage.MessageType.reply); reply.to = msg.from; reply.from = msg.to; reply.command = "getTopFiles"; reply.arguments = localFileMgr.getFiles().ToList <string>(); return(reply); }; messageDispatcher["getTopFiles"] = getTopFiles; Func <CommMessage, CommMessage> getTopDirs = (CommMessage msg) => { localFileMgr.currentPath = ""; CommMessage reply = new CommMessage(CommMessage.MessageType.reply); reply.to = msg.from; reply.from = msg.to; reply.command = "getTopDirs"; reply.arguments = localFileMgr.getDirs().ToList <string>(); return(reply); }; messageDispatcher["getTopDirs"] = getTopDirs; Func <CommMessage, CommMessage> moveIntoFolderFiles = (CommMessage msg) => { if (msg.arguments.Count() == 1) { localFileMgr.currentPath = msg.arguments[0]; } CommMessage reply = new CommMessage(CommMessage.MessageType.reply); reply.to = msg.from; reply.from = msg.to; reply.command = "moveIntoFolderFiles"; reply.arguments = localFileMgr.getFiles().ToList <string>(); return(reply); }; messageDispatcher["moveIntoFolderFiles"] = moveIntoFolderFiles; Func <CommMessage, CommMessage> moveIntoFolderDirs = (CommMessage msg) => { if (msg.arguments.Count() == 1) { localFileMgr.currentPath = msg.arguments[0]; } CommMessage reply = new CommMessage(CommMessage.MessageType.reply); reply.to = msg.from; reply.from = msg.to; reply.command = "moveIntoFolderDirs"; reply.arguments = localFileMgr.getDirs().ToList <string>(); return(reply); }; messageDispatcher["moveIntoFolderDirs"] = moveIntoFolderDirs; Func <CommMessage, CommMessage> analyzeFiles = (CommMessage msg) => { CommMessage reply = new CommMessage(CommMessage.MessageType.reply); reply.to = msg.from; reply.from = msg.to; reply.command = "analyzeFiles"; TypeAnalysis typeana = new TypeAnalysis(); DepAnalys depana = new DepAnalys(); StrongComp strongcomp = new StrongComp(); List <Elem> table = new List <Elem>(); foreach (string file in msg.arguments) { ITokenCollection semi = Factory.create(); if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", file); return(null); } BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi); Parser parser = builder.build(); try { while (semi.get().Count > 0) { parser.parse(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); table = rep.locations; File f = file.Substring(file.LastIndexOf('\\') + 1); string namesp = ""; foreach (Elem ele in table) { if (ele.type == "namespace") { namesp = ele.name; } typeana.add(f, ele, namesp); } semi.close(); } depana.BuildGraph(msg.arguments); foreach (string f in msg.arguments) { depana.ConnectNode(typeana, f); } //move to reply.arguments[0]; foreach (CsNode <string, string> node in depana.csgraph.adjList) { StringBuilder temp = new StringBuilder(); temp.Append(node.name.Substring(node.name.LastIndexOf('/') + 1)); temp.Append(" \n Dependency : ["); foreach (CsEdge <string, string> edge in node.children) { temp.Append(edge.targetNode.name.Substring(edge.targetNode.name.LastIndexOf('/') + 1)); temp.Append(" "); } temp.Append(" ] \n"); reply.arguments.Add(temp.ToString()); } strongcomp.FindConnect(depana.csgraph); //move to reply.arguments[1]; int i = 1; foreach (List <CsNode <string, string> > nodes in strongcomp.result) { StringBuilder temp = new StringBuilder(); temp.Append("Components " + i.ToString() + ": "); foreach (CsNode <string, string> node in nodes) { temp.Append(node.name.Substring(node.name.LastIndexOf('/') + 1) + " "); } temp.Append("\n"); i++; reply.arguments.Add(temp.ToString()); } return(reply); }; messageDispatcher["analyzeFiles"] = analyzeFiles; Func <CommMessage, CommMessage> demo456 = (CommMessage msg) => { CommMessage reply = new CommMessage(CommMessage.MessageType.reply); reply.to = msg.from; reply.from = msg.to; reply.command = "demo456"; reply.arguments.Add(""); return(reply); }; messageDispatcher["demo456"] = demo456; }
public void Requirement4_5(string[] args) { Console.Write("\n\t \tOutput of Requirement4\n"); Console.Write("-----------------------------------------------------------------------------\n"); Console.Write("This Project3 implements packages that evaluate all the dependencies between files in a specified file set \n"); ShowCommandLine(args); List<string> files = ProcessCommandline(args); foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); ITokenCollection semi = Factory.create(); if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi); Parser parser = builder.build(); try { while (semi.get().Count > 0) parser.parse(semi); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Console.Write("\n"); semi.close(); } DepAnalysis.DepAnalysis dep = new DepAnalysis.DepAnalysis(); StrongComp.filesGraph = files; StrongComp.filesGraphs = files; StrongComp.filenumber = files.Count(); StrongComp.setGraph(); StrongComp.filesGraph = files; StrongComp.setGraphDictionary(); DepAnalysis.DepAnalysis.filesDepAnalysis = files; DepAnalysis.DepAnalysis.setDictionary(); foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); ITokenCollection semi = Factory.create(); if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } try { while (semi.get().Count > 0) dep.HoldUsingValue(semi); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } semi.close(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } try { while (semi.get().Count > 0) dep.analyze(semi, file); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } semi.close(); StrongComp.addGraph(); } Console.Write("\n\n"); }