Beispiel #1
0
        public void display(string[] files, bool relationship)
        {
            Repository  rep   = Repository.getInstance();
            List <Elem> table = rep.locations;


            //DISPLAY FILES IN THE FILE SET
            Console.WriteLine("Files in fileset are \n");
            foreach (object file in files)
            {
                Console.WriteLine(file as string);
            }



            // COUNT FOR COMPLEXITY AND FUNCTION SIZES

            List <Elem> temp = rep.locations;

            foreach (Elem e in table)
            {
                if (e.type.Equals("namespace"))
                {
                    Console.WriteLine("\n{0,9},{1,10}, starts at line{2,5},end at line{3,5}", e.type, e.name, e.begin, e.end);
                }

                if (e.type.Equals("inheritance"))
                {
                    Console.WriteLine("\n{0,10},{1,10},starts at line{2,5},ends at line{3,5}", e.type, e.name, e.begin, e.end);
                }

                //search for the namespace for that particular class

                if (e.type.Equals("class"))
                {
                    foreach (Elem tt in temp)
                    {
                        if (tt.type.Equals("namespace"))
                        {
                            if ((tt.begin < e.begin) && (tt.end > e.end))
                            {
                                Console.WriteLine("\n{0,5},{1,10}.{2,5},starts at line{3,5},ends at line{4,5}", e.type, tt.name, e.name, e.begin, e.end);
                            }
                        }
                    }
                }
                if (e.type.Equals("function"))
                {
                    int size       = e.end - e.begin;
                    int complexity = 0;
                    foreach (Elem t in temp)
                    {
                        if (t.type.Equals("control") && (t.begin > e.begin) && (t.end < e.end))
                        {
                            complexity++;
                        }
                        if (t.type.Equals("braceless") && (t.begin > e.begin) && (t.end < e.end))
                        {
                            complexity++;
                        }
                    }

                    Console.WriteLine("\nFunction {0,10}, size={1,3} complexity={2,3}", e.name, size, complexity);
                }
            }

            //DISPLAY RELATIONSHIPS


            //Console.Write("\n\n  relationship table contains:");

            /*  List<RelElem> table2 = rep.inheritance;
             *
             * foreach (RelElem e in table2)
             * {
             *    Console.Write("\n  {0,10}, {1,25},{2,20}, {3,5}, {4,5}", e.type, e.name, e.withName, e.beginRel, e.endRel);
             * }
             * Console.WriteLine();
             * Console.Write("\n\n  That's all folks!\n\n");
             * Console.ReadLine(); */

            //DISPLAY FINAL RELATIONSHIPS
            if (relationship)
            {
                List <RelElem> table2 = rep.inheritance;

                List <RelElem> temp2 = rep.inheritance;

                foreach (Elem ee in table)
                {
                    if (ee.type.Equals("class"))
                    {
                        foreach (RelElem rr in table2)
                        {
                            if ((rr.beginRel >= ee.begin) && (rr.endRel <= ee.end) && (rr.type != "UsingTemp") && (rr.type != "UsingStr"))
                            {
                                Console.WriteLine("\nclass {0} has {1} relationship with {2} at line {3}", ee.name, rr.type, rr.withName, rr.beginRel);
                            }
                        }
                    }
                }
            }
        }