public static void DepAnalyzer(Repository repo, List <string> files, string[] args)
        {
            BuildTypeAnalyzer builder    = new BuildTypeAnalyzer(repo);
            Parser            parser     = builder.build();
            BuildDepAnalyzer  depBuilder = new BuildDepAnalyzer(repo);
            Parser            depParser  = depBuilder.build();

            foreach (string file in files)
            {
                if (!repo.semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }

                try
                {
                    while (repo.semi.get().Count > 0)
                    {
                        parser.parse(repo.semi);
                        depParser.parse(repo.semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }

                repo.clearScopeStack();
                repo.semi.close();
            }
        }
Esempio n. 2
0
        public bool doTest()
        {
            Console.WriteLine();
            ReqDisplay.title("Req #6 - Find all strong components in the file collection");
            ReqDisplay.message("- In this program, Tarjan Algorithm is used to solve strong components.");

            string[] args = new string[] { "../../../DemoExecutive/Test/" };
            DemoExecutive.ShowCommandLine(args);
            List <string> files = DemoExecutive.ProcessCommandline(args);

            Repository repo = new Repository();

            repo.semi = Factory.create();

            BuildTypeAnalyzer builder = new BuildTypeAnalyzer(repo);
            Parser            parser  = builder.build();

            DemoExecutive.BuildTypeTable(args, files, repo);
            DemoExecutive.depAnalysis(args, files, repo);

            Console.Write("\n\nDependency Analysis:");
            Display.showDependency(repo.depGraph);

            Console.Write("\n");
            var strongComponents = TarjanSccSolver.DetectCycle(repo.depGraph);

            Display.showStrongComponents(strongComponents);

            return(true);
        }
Esempio n. 3
0
        //----< Test Stub >--------------------------------------------------

#if (TEST_TYPEANALYSIS)
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");

            ShowCommandLine(args);

            List <string> files = TestParser.ProcessCommandline(args);
            //Repository repo = Repository.getInstance();
            Repository repo = new Repository();

            repo.semi = Factory.create();

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

                //ITokenCollection semi = Factory.create();
                //semi.displayNewLines = false;
                if (!repo.semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }

                BuildTypeAnalyzer builder = new BuildTypeAnalyzer(repo);
                Parser            parser  = builder.build();
                try
                {
                    while (repo.semi.get().Count > 0)
                    {
                        parser.parse(repo.semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }

                repo.clearScopeStack();
                repo.semi.close();
            }

            Console.Write("\n\n  Type and Dependency Analysis");
            Console.Write("\n ----------------------------");

            TypeTable table = repo.typeTable;

            Display.showTypeTable(table);

            Console.Write("\n");
            Console.Write("\n\n");
        }
        //---------< Build Type Table >------------------------------------------------------
        public static void BuildTypeTable(string[] args, List <string> files, Repository repo)
        {
            BuildTypeAnalyzer builder = new BuildTypeAnalyzer(repo);
            Parser            parser  = builder.build();

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

                if (!repo.semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }


                try
                {
                    while (repo.semi.get().Count > 0)
                    {
                        parser.parse(repo.semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }

                repo.clearScopeStack();
                repo.semi.close();

                CsNode <FileNode, string> fileNode = new CsNode <FileNode, string>(repo.semi.filePath);
                fileNode.nodeValue = new FileNode(repo.semi.filePath);
                repo.nodeTable.Add(repo.semi.filePath, fileNode);
                repo.depGraph.addNode(repo.nodeTable[repo.semi.filePath]);
            }
        }
        //---------< conduct dependency analysis >-----------------------------------------
        public static void depAnalysis(string[] args, List <string> files, Repository repo)
        {
            BuildTypeAnalyzer builder = new BuildTypeAnalyzer(repo);
            Parser            parser  = builder.build();

            BuildDepAnalyzer depBuilder = new BuildDepAnalyzer(repo);
            Parser           depParser  = depBuilder.build();

            foreach (string file in files)
            {
                if (file.Contains("TemporaryGeneratedFile") || file.Contains("AssemblyInfo"))
                {
                    continue;
                }

                if (!repo.semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }

                try
                {
                    while (repo.semi.get().Count > 0)
                    {
                        parser.parse(repo.semi);
                        depParser.parse(repo.semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }

                repo.clearScopeStack();
                repo.semi.close();
            }
        }