示例#1
0
 // This method is called to display the type relationships(inheritance,aggregation,composition,using) in the input set
 public void displayRelationshipsDetails()
 {
     try
     {
         Repository rep = Repository.getInstance();
         Console.WriteLine("\n\n==================================\n");
         Console.WriteLine("RELATIONSHIP SUMMARY FOR THE FILES");
         Console.WriteLine("==================================\n \n");
         displayInheritanceTable(rep);
         displayAggergationTable(rep);
         displayCompositionTable(rep);
         displayUsingTable(rep);
         Console.WriteLine("\n\n\n====END OF ANALYSIS====\n \n");
     }
     catch (Exception)
     {
         Console.WriteLine("Error occurred while displaying relationships");
     }
 }
示例#2
0
            //Test Stub
            /// <summary>
            ///   If the package is run as stand alone application
            /// then add the default values for the member variables                 
            /// </summary>
            /// <param name="args"></param>
            public static void Main(String[] args)
            {
                XmlDisplay xmlDisplayForTestStub = new XmlDisplay();
                Repository rep = Repository.getInstance();

                try
                {
                    if (rep.locations.Count == 0)
                    {
                        Console.WriteLine("The repository is empty. Nothing to display");
                    }

                    xmlDisplayForTestStub.generateRelationshipsDetails();
                }
                catch
                {
                    Console.WriteLine("Error occured during xml generation. Check the input parameters");
                }
            }
示例#3
0
            //Test Stub
            public static void Main(String[] args)
            {
                XmlDisplay xmlDisplayForTestStub = new XmlDisplay();
                Repository rep = Repository.getInstance();
                /* If the package is run as stand alone application
                  * then add the default values for the member variables
                 */
                try
                {
                    if (rep.locations.Count == 0)
                    {
                        Console.WriteLine("The repository is empty. Nothing to display");
                    }

                    xmlDisplayForTestStub.generateXmlTypesDetails();
                    xmlDisplayForTestStub.generateXmlComplexityDetails();
                    xmlDisplayForTestStub.generateRelationshipsDetails();
                }
                catch
                {
                    Console.WriteLine("Error occured during xml generation. Check the input parameters");
                }
            }
示例#4
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();
            }
        }