Beispiel #1
0
        private static void testAnalyzer(string[] args)
        {
            Console.Out.WriteLine("Analyzer Test!!");
            CMDConsole cmd      = new CMDConsole(args);
            Analyzer   analyzer = new Analyzer(grammarLoader, cmd);

            analyzer.start();
        }
Beispiel #2
0
 private static void testCMDConsole(string[] args)
 {
     Console.Out.WriteLine("Command Line Console Test!!");
     try {
         CMDConsole cmd = new CMDConsole(args);
         Console.Out.WriteLine(cmd.commands);
         Console.Out.WriteLine((cmd[CMDConsole.targetPathCMD] as List <string>)[0]);
     }
     catch (Exception e) {
         Console.Out.WriteLine(e.Message);
     }
 }
Beispiel #3
0
        public Analyzer(CMDConsole cmds)
        {
            fm        = new FileManager();
            this.cmds = cmds;
            // get file that going to be processed
            fList =
                fm.listCodeFile(
                    cmds[CMDConsole.targetPathCMD] as List <string>,
                    cmds[CMDConsole.excludedPathCMD] as List <string>,
                    ((bool)cmds[CMDConsole.noSubDirectoryCMD]),
                    cmds[CMDConsole.wildcardSearchCMD] as List <string>
                    );
            int threadNum = 10; // 10 worker threads by default

            if (cmds[CMDConsole.threadNumberCMD] != null)
            {
                threadNum = Int32.Parse(cmds[CMDConsole.threadNumberCMD] as string);
            }
            tm = new TaskManager(threadNum);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            CMDConsole cmd = new CMDConsole();

            try {
                cmd.readCommands(args);
            }
            catch (Exception e) {
                Logger.error(e.Message);
                while (true)
                {
                    ;
                }
            }

            if ((bool)cmd[CMDConsole.helpCMD])
            {
                Logger.info(CMDConsole.helpMessage);
                Logger.info("Press ENTER to continue other commands.");
                while ((char)Console.In.Read() != '\r')
                {
                    ;
                }
            }

            string path = cmd[CMDConsole.redirectInfoCMD] as string;

            if (path != null)
            {
                Logger.info("Log file will be saved to {0}", path);
                Logger._info.output = Logger.Redierction.File;
                Logger._info.saveTo = path;
            }

            Analyzer analyzer = new Analyzer(cmd);

            try {
                if (!(bool)cmd[CMDConsole.disableAnalyzeCMD])
                {
                    analyzer.analyze();
                }

                if ((bool)cmd[CMDConsole.distanceCMD] || (bool)cmd[CMDConsole.allDistanceCMD])
                {
                    analyzer.computeFileDistance();
                }
            }
            catch (Exception e) {
                Console.Out.WriteLine(e.Message);
            }
            while ((char)Console.In.Read() != '\r')
            {
                ;
            }


#if (TEST_SIMPLEPARSER)
            testSimpleParser(args);
#endif

#if (TEST_TOKENIZER)
            testTokenizer(args);
#endif

#if (TEST_ANALYZER)
            testAnalyzer(new string[] { "-t", @"X:\Code Analyzer", @"c:\www.aa", "-e", @"D:\Dropbox\Projects\CSharp\Parser" });
#endif

#if (TEST_FILEMANAGER)
            testFileManager();
#endif

#if (TEST_CMDCONSOLE)
            testCMDConsole(new string[] { "-t", @"C:\w\s", @"c:\www.aa\2", "-p" });
#endif
        }