public void analyze() { if (dirpath == null) { Console.Write("dirpath not set"); return; } buildTypeTable(); BuildDependencyParser builder = new BuildDependencyParser(); Parser parser = builder.build(); List <String> files = FileManger.ProcessDirtory(dirpath); foreach (String file in files) { // Console.Write("\n Dependency Analyzsis, Processing file {0}\n", System.IO.Path.GetFileName(file)); //print on the console which file is being processed ITokenCollection semi = Factory.create(); Repository.changeFileName(System.IO.Path.GetFileName(file)); //update the current file name Repository.emptyUsingList(); // empty the using namespace list whenever start parsing a new file Repository.resetAliasList(); if (!Repository.getInstance().dependencyTable.ContainsKey(System.IO.Path.GetFileName(file))) { Repository.getInstance().dependencyTable.Add(System.IO.Path.GetFileName(file), new HashSet <string>()); // create a dependency node for each file } //semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", file); continue; } // Console.Write("\n Type and Function Analysis"); // Console.Write("\n ----------------------------"); try { while (semi.get().Count > 0) { parser.parse(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } semi.close(); } Console.Write("\n\n"); DependencyTable = Repository.getInstance().dependencyTable; Repository.clear(); }
public static TypeTable buildTypeTable(String[] args) // the input should be the valid path and file names { //Console.Write("\n Demonstrating building typeTable"); //Console.Write("\n ======================\n") //ShowCommandLine(arg); TypeTable table = new TypeTable(); List <string> files = FileManger.ProcessDirtory(args); Repository r = new Repository(); foreach (string file in files) { if (System.IO.Path.GetFileName(file).Contains("AssemblyInfo.cs")) // ignore all the .cs file that are generated by visual studio { continue; } Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); //print on the console which file is being processed ITokenCollection semi = Factory.create(); BuildTpyeTablePareer builder = new BuildTpyeTablePareer(semi); Parser parser = builder.build(); Repository.changeFileName(System.IO.Path.GetFileName(file)); //update the current file name //semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", file); continue; } // Console.Write("\n Type and Function Analysis"); // Console.Write("\n ----------------------------"); try { while (semi.get().Count > 0) { parser.parse(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } semi.close(); } Console.Write("\n\n"); return(Repository.getInstance().table); }
} //change this field to your test cases public static void demoRequirement3() { Console.WriteLine("Now demostrating requirement 3, showing all the .cs package in the solution"); Console.WriteLine("--------------------------------------------------------------------------------------------------------------------------------------------------------------------"); List <String> files = FileManger.ProcessDirtory(path); foreach (String file in files) { if (file.Contains("AssemblyInfo.cs")) //discard all the amssemblyInfo.cs file which is generated by visual studio { continue; } Console.WriteLine(file); } Console.WriteLine("finish demostrating requirement3 "); Console.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n\n"); }