Exemplo n.º 1
0
        /// <summary>
        /// This method is used for the second round of analysis.
        /// Since there are multiple servers, we need to merge the partial type
        /// table of each of the server to find the depenendency across various
        /// servers. Once the first parse is done, the client sends the type table
        /// of all other servers. At this point, we will merge the existing type
        /// table with other server type table and then use this updated table
        /// to find the final dependeny results.
        /// </summary>
        public void analyzeSecondParse()
        {
            CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
            semi.displayNewLines = false;

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

                    BuildCodeAnalyzerForRelationshipTypes builderreln = new BuildCodeAnalyzerForRelationshipTypes(semi);
                    CodeAnalysis.Parser parser = builderreln.build();

                    try
                    {
                        while (semi.getSemi())
                        {
                            parser.parse(semi);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write("\n\n  {0}\n", ex.Message);
                    }
                    semi.close();
                }
            }
            catch (Exception ex)
            {
                Console.Write("\n\n Error in the input data. Exception {0}. Please check the input data\n", ex.Message);
            }
        }
Exemplo n.º 2
0
        /* This method is used to call the relationship and complexity analysis
         * for each file in the input set
         */
        public void analyze()
        {
            CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
            semi.displayNewLines = false;

            /* These are the supported file formats in this tool. If input file is not in this format,
             * then analysis will not be done*/
            string[] supportedFileFormatList = { ".cs", ".c", ".cpp", ".java", ".txt", ".bat" };

            foreach (object file in files)
            {
                string fileExtension       = Path.GetExtension(file.ToString());
                bool   supportedFileFormat = false;

                foreach (string currentFileExtension in supportedFileFormatList)
                {
                    if (fileExtension == currentFileExtension)
                    {
                        supportedFileFormat = true;
                    }
                }

                if (!supportedFileFormat)
                {
                    Console.WriteLine("\nThe file {0} is of unsupported format", file.ToString());
                    continue;
                }
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                    return;
                }

                BuildCodeAnalyzer   builder = new BuildCodeAnalyzer(semi);
                CodeAnalysis.Parser parser  = builder.build();

                Repository repo = Repository.getInstance();
                Elem       elem = getDefaultElemData(file.ToString());
                repo.locations.Add(elem);

                try
                {
                    while (semi.getSemi())
                    {
                        parser.parse(semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                semi.close();

                //Only when the user specifies the /R option, we do relationship analysis
                if (findRelationship)
                {
                    semi = new CSsemi.CSemiExp();
                    semi.displayNewLines = false;
                    if (!semi.open(file as string))
                    {
                        Console.Write("\n  Can't open {0}\n\n", file);
                        return;
                    }

                    BuildCodeAnalyzerForRelationshipTypes builderreln = new BuildCodeAnalyzerForRelationshipTypes(semi);
                    parser = builderreln.build();

                    try
                    {
                        while (semi.getSemi())
                        {
                            parser.parse(semi);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write("\n\n  {0}\n", ex.Message);
                    }
                }
                semi.close();
            }
        }