Ejemplo n.º 1
0
            static void Main(string[] args)
            {
                Console.Write("\n  Demonstrating DepAnalysis");
                Console.Write("\n ======================\n");

                TypeAnalysis typeanalysis = new TypeAnalysis();

                List <string> files = TestParser.ProcessCommandline(args);

                foreach (string file in files)
                {
                    // Console.Write("\n  Processing file {0}\n", System.IO.Path.GetFileName(file));

                    ITokenCollection semi = Factory.create();
                    //semi.displayNewLines = false;

                    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);
                    }
                    Repository  rep    = Repository.getInstance();
                    List <Elem> table  = rep.locations;
                    File        f      = file.Substring(file.LastIndexOf('\\') + 1);
                    string      namesp = "";
                    foreach (Elem ele in table)
                    {
                        if (ele.type == "namespace")
                        {
                            namesp = ele.name;
                        }
                        typeanalysis.add(f, ele, namesp);
                    }
                    Console.Write("\n");

                    semi.close();
                }
                //build the graph
                DepAnalys danalysis = new DepAnalys();

                danalysis.BuildGraph(files);

                foreach (string f in files)
                {
                    danalysis.ConnectNode(typeanalysis, f);
                }

                danalysis.showdep();
                Console.Write("\n\n");
            }