コード例 #1
0
ファイル: IntegrationTests.cs プロジェクト: Tallmaris/ccm
        public void TestCStyleFuncDecl()
        {
            string filename = "cstylefuncs.c"; // this is deployed through local.testsettings
              SortedListener listener = new SortedListener(10, new List<string>());
              using (StreamReader stream = new StreamReader(filename))
              {
            FileAnalyzer analyzer = new FileAnalyzer(stream, listener, null, true, filename);
            analyzer.Analyze();

            Assert.AreEqual(3, listener.Metrics.Count);

            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "added"));
            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "new_cfg_record"));
            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "edit_cfg_record"));
              }
        }
コード例 #2
0
ファイル: ccmControl.cs プロジェクト: jonasblunck/ccm
        private void AnalyzeFileInBackgroundThread(object filename)
        {
            try
              {
            string file = (string)filename;

            using (System.IO.StreamReader reader = new System.IO.StreamReader(file))
            {
              FileAnalyzer analyzer = new FileAnalyzer(reader, this.listener, null, true, file);
              analyzer.Analyze();
            }
              }
              catch (Exception)
              {
              }
              finally
              {
            this.sempahore.Release();
              }
        }
コード例 #3
0
ファイル: Driver.cs プロジェクト: Tallmaris/ccm
        private void AnalyzeFilestream(object context)
        {
            AnalyzeThreadParameters parameters = (AnalyzeThreadParameters)context;

              try
              {
            FileAnalyzer analyzer =
              new FileAnalyzer(parameters.stream, this.listener, null, this.configFile.SuppressMethodSignatures,
            parameters.filename, this.configFile.SwitchStatementBehavior);

            analyzer.Analyze();
            parameters.stream.Close(); // free up the stream.
              }
              catch (UnknownStructureException error)
              {
            lock (this.mutex)
            {
              this.errors.Add(new ErrorInfo(parameters.filename, error.Message));
            }
              }
              catch (PreprocessorException)
              {
            lock (this.mutex)
            {
              this.errors.Add(new ErrorInfo(parameters.filename, "Error running pre-processor. Only basic support for #ifdefs."));
            }
              }
              catch (Exception)
              {
            lock (this.mutex)
            {
              this.errors.Add(new ErrorInfo(parameters.filename, "Unknown error parsing file."));
            }
              }

              this.threadSemaphore.Release();
        }
コード例 #4
0
ファイル: IntegrationTests.cs プロジェクト: Tallmaris/ccm
        public void TestFileWithTabAfterEndif()
        {
            string filename = "FileWithTabAfterEndIf.c"; // this is deployed through local.testsettings
              SortedListener listener = new SortedListener(10, new List<string>());
              using (StreamReader stream = new StreamReader(filename))
              {
            FileAnalyzer analyzer = new FileAnalyzer(stream, listener, null, true, filename);
            analyzer.Analyze();

            Assert.AreEqual(1, listener.Metrics.Count);

            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "Foo"));
              }
        }
コード例 #5
0
ファイル: IntegrationTests.cs プロジェクト: Tallmaris/ccm
        private static AnalyzerCollector Analyze(string filename, bool suppressMethodSignature)
        {
            //TODO: start using SortedListener instead of AnalyzerCollector (remove this one)
              AnalyzerCollector collector = new AnalyzerCollector();

              StreamReader stream = new StreamReader(filename);

              try
              {
            FileAnalyzer analyzer =
              new FileAnalyzer(stream, collector, null, suppressMethodSignature, filename);

            analyzer.Analyze();
              }
              finally
              {
            stream.Dispose();
              }

              return collector;
        }
コード例 #6
0
ファイル: IntegrationTests.cs プロジェクト: Tallmaris/ccm
        public void TestTypescriptFileIsCorrectlyParsed()
        {
            string filename = "TypeScript.ts"; // this is deployed through local.testsettings
              SortedListener listener = new SortedListener(10, new List<string>());
              using (StreamReader stream = new StreamReader(filename))
              {
            FileAnalyzer analyzer = new FileAnalyzer(stream, listener, null, false, filename);
            analyzer.Analyze();

            Assert.AreEqual(3, listener.Metrics.Count);

            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "Sayings::Greeter::greet()"));
            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "Sayings::Greeter::constructor(message:string)"));
            Assert.IsNotNull(IntegrationTests.GetByName(listener.Metrics, "button.onclick()"));
              }
        }
コード例 #7
0
ファイル: IntegrationTests.cs プロジェクト: Tallmaris/ccm
        public void TestJavascriptFileContainsAllFunctions()
        {
            string filename = "examples.js"; // this is deployed through local.testsettings
              SortedListener listener = new SortedListener(10, new List<string>());
              using (StreamReader stream = new StreamReader(filename))
              {
            FileAnalyzer analyzer = new FileAnalyzer(stream, listener, null, false, filename);
            analyzer.Analyze();

            Assert.AreEqual(10, listener.Metrics.Count);

            Assert.AreEqual(6, IntegrationTests.GetByName(listener.Metrics, "gcd(segmentA,segmentB)").CCM);
            Assert.AreEqual(2, IntegrationTests.GetByName(listener.Metrics, "function(monkey)").CCM);
            Assert.AreEqual(1, IntegrationTests.GetByName(listener.Metrics, "localFunction()").CCM);
            Assert.AreEqual(1, IntegrationTests.GetByName(listener.Metrics, "Some.Foo(args)").CCM);
            Assert.AreEqual(1, IntegrationTests.GetByName(listener.Metrics, "functionWithColon()").CCM);
            Assert.AreEqual(2, IntegrationTests.GetByName(listener.Metrics, "localFunction1()").CCM);
            Assert.AreEqual(4, IntegrationTests.GetByName(listener.Metrics, "outerFunction1()").CCM);
            Assert.AreEqual(1, IntegrationTests.GetByName(listener.Metrics, "localFunction2()").CCM);
            Assert.AreEqual(1, IntegrationTests.GetByName(listener.Metrics, "Monkey::feedMonkey()").CCM);
            Assert.AreEqual(1, IntegrationTests.GetByName(listener.Metrics, "afterMonkeyFeed()").CCM);

              }
        }