//----<set of actions if there is inheritance between two types>----------------
 public void doActionInheritance(CSsemi.CSemiExp semi, string file, ElemRelation elem)
 {
     if (semi[0].Equals("Inheritance"))
     {
         elem.fromClass    = semi[1];
         elem.toClass      = semi[2];
         elem.relationType = semi[0];
         elem.fileName     = file;
         RelationshipRepository.relationship_.Add(elem);
     }
 }
 //----<detects if it is a class and pushes onto the stack to check for last pushed class >-----
 public void doActionClass(CSsemi.CSemiExp semi, string file, ElemRelation elem)
 {
     if (semi[0].Equals("class"))
     {
         Elem elemcl = new Elem();
         elemcl.type     = semi[0]; // expects type
         elemcl.name     = semi[1]; // expects name
         elemcl.begin    = repo_.semi.lineCount - 1;
         elemcl.end      = 0;
         elemcl.fileName = file;
         repo_.stack.push(elemcl);
         repo_.locations.Add(elemcl);
     }
 }
 //----------<set of actions if there is using relation between two types>---------------
 public void doActionUsing(CSsemi.CSemiExp semi, string file, ElemRelation elem)
 {
     if (semi[0].Equals("Using"))
     {
         int i = repo_.locations.Count;
         if (!semi[1].Equals(repo_.locations[i - 1].name))
         {
             elem.fromClass    = repo_.locations[i - 1].name;
             elem.toClass      = semi[1];
             elem.relationType = semi[0];
             elem.fileName     = file;
             RelationshipRepository.relationship_.Add(elem);
         }
     }
 }
Beispiel #4
0
        //--------------------------<Test Stub for Display>------------------------

#if (TEST_DISPLAY)
        static void Main(string[] args)
        {
            string path = "../../";

            string[]      arg      = { "../../", "*.cs" };
            List <string> patterns = new List <string>();

            patterns.Add("*.cs");
            List <string> options = new List <string>();

            string[] files = getFiles(path, patterns);

            foreach (string f in files)                  //to populate element Relation
            {
                ElemRelation e = new ElemRelation();
                e.fromClass    = "Derived";
                e.toClass      = "Original";
                e.relationType = "Inheritance";
                e.fileName     = f;
                RelationshipRepository.relationship_.Add(e);
            }
            foreach (string f1 in files)         //to populate types
            {
                Elem elem = new Elem();
                elem.fileName           = f1;
                elem.type               = "function";
                elem.name               = "Derived";
                elem.begin              = 1;
                elem.end                = 10;
                elem.functionComplexity = 2;
                OutputRepository.output_.Add(elem);
            }

            options.Add("/S");
            patterns.Add("*.cs");
            Display d = new Display();

            d.display(files, path, patterns, options);
            d.displaySummary(files);
            d.displayFunctionComplexity(files);
            d.displayRelation(files);
        }
        //-----------<doAction after the rules are Detected for elationship Analysis>------------
        public override void doAction(CSsemi.CSemiExp semi, string file)
        {
            ElemRelation elem = new ElemRelation();

            doActionClass(semi, file, elem);
            doActionInheritance(semi, file, elem);
            doActionAggregation(semi, file, elem);
            doActionComposition(semi, file, elem);
            doActionUsing(semi, file, elem);

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi); // defined in abstract action
            }
            if (AAction.displayStack)
            {
                repo_.stack.display();
            }
        }
Beispiel #6
0
        // ------------------------<TestStub for XML Output>-------------------------
#if (TEST_XMLOUTPUT)
        static void Main(string[] args)
        {
            ElemRelation e = new ElemRelation();

            e.fromClass    = "Derived";
            e.toClass      = "Original";
            e.relationType = "Inheritance";

            RelationshipRepository.relationship_.Add(e);

            Elem elem = new Elem();

            elem.type  = "function";
            elem.name  = "Derived";
            elem.begin = 1;
            elem.end   = 10;
            elem.functionComplexity = 2;
            OutputRepository.output_.Add(elem);
            XMLOutput xml = new XMLOutput();

            xml.displaySummary();
            xml.displayFunctionAnalysis();
            xml.displayRelation();
        }
Beispiel #7
0
        //--------------------------<Test Stub for Display>------------------------

#if(TEST_DISPLAY)

        static void Main(string[] args)
        {
            string path = "../../";
            string[] arg = { "../../", "*.cs" };
            List<string> patterns = new List<string>();
            patterns.Add("*.cs");
            List<string> options = new List<string>();
            string[] files = getFiles(path, patterns);

            foreach (string f in files)                  //to populate element Relation
            {
                ElemRelation e = new ElemRelation();
                e.fromClass = "Derived";
                e.toClass = "Original";
                e.relationType = "Inheritance";
                e.fileName = f;
                RelationshipRepository.relationship_.Add(e);
            }
            foreach (string f1 in files)         //to populate types
            {
                Elem elem = new Elem();
                elem.fileName = f1;
                elem.type = "function";
                elem.name = "Derived";
                elem.begin = 1;
                elem.end = 10;
                elem.functionComplexity = 2;
                OutputRepository.output_.Add(elem);
            }

            options.Add("/S");
            patterns.Add("*.cs");
            Display d = new Display();
            d.display(files, path, patterns, options);
            d.displaySummary(files);
            d.displayFunctionComplexity(files);
            d.displayRelation(files);
        }
Beispiel #8
0
        // ------------------------<TestStub for XML Output>-------------------------
#if(TEST_XMLOUTPUT)

        static void Main(string[] args)
        {

            ElemRelation e = new ElemRelation();
            e.fromClass = "Derived";
            e.toClass = "Original";
            e.relationType = "Inheritance";

            RelationshipRepository.relationship_.Add(e);

            Elem elem = new Elem();
            elem.type = "function";
            elem.name = "Derived";
            elem.begin = 1;
            elem.end = 10;
            elem.functionComplexity = 2;
            OutputRepository.output_.Add(elem);
            XMLOutput xml = new XMLOutput();
            xml.displaySummary();
            xml.displayFunctionAnalysis();
            xml.displayRelation();
        }
Beispiel #9
0
 //----<detects if it is a class and pushes onto the stack to check for last pushed class >-----
 public void doActionClass(CSsemi.CSemiExp semi, string file, ElemRelation elem)
 {
     if (semi[0].Equals("class"))
     {
         Elem elemcl = new Elem();
         elemcl.type = semi[0];  // expects type
         elemcl.name = semi[1];  // expects name
         elemcl.begin = repo_.semi.lineCount - 1;
         elemcl.end = 0;
         elemcl.fileName = file;
         repo_.stack.push(elemcl);
         repo_.locations.Add(elemcl);
     }
 }
Beispiel #10
0
        //------<set of actions if there is aggregation between two types>---------------
        public void doActionAggregation(CSsemi.CSemiExp semi, string file, ElemRelation elem)
        {
            if (semi[0].Equals("Aggregation"))
            {
                int i = repo_.locations.Count;
                if (!semi[1].Equals(repo_.locations[i - 1].name))
                {

                    elem.fromClass = repo_.locations[i - 1].name;
                    elem.toClass = semi[1];
                    elem.relationType = semi[0];
                    elem.fileName = file;
                    RelationshipRepository.relationship_.Add(elem);

                }
            }
        }
Beispiel #11
0
        //-----------<doAction after the rules are Detected for elationship Analysis>------------
        public override void doAction(CSsemi.CSemiExp semi, string file)
        {
            ElemRelation elem = new ElemRelation();

            doActionClass(semi, file, elem);
            doActionInheritance(semi, file, elem);
            doActionAggregation(semi, file, elem);
            doActionComposition(semi, file, elem);
            doActionUsing(semi, file, elem);

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi); // defined in abstract action
            }
            if (AAction.displayStack)
                repo_.stack.display();
        }
Beispiel #12
0
        //----<set of actions if there is inheritance between two types>----------------
        public void doActionInheritance(CSsemi.CSemiExp semi, string file, ElemRelation elem)
        {
            if (semi[0].Equals("Inheritance"))
            {
                elem.fromClass = semi[1];
                elem.toClass = semi[2];
                elem.relationType = semi[0];
                elem.fileName = file;
                RelationshipRepository.relationship_.Add(elem);

            }
        }