Esempio n. 1
0
 //This method is used to handle a new SQL statements "opt" that we found in the method "m". The instruction could be "direct","follow" and "final" so we could relatively insert the method into three lists of methods.
 public void insertMethod(desMethod m, string opt, string instruction)
 {
     if (instruction == "direct")
     {
         if (this.directMethods.Find(x => x.name == m.name) == null)
         {
             this.directMethods.Add(m);
         }
         insertRelationships(m.name, opt);
         return;
     }
     if (instruction == "follow")
     {
         if (this.followMehtods.Find(x => x.name == m.name) == null)
         {
             this.followMehtods.Add(m);
         }
         insertRelationships(m.name, opt);
         return;
     }
     if (instruction == "final")
     {
         if (this.finalMethods.Find(x => x.name == m.name) == null)
         {
             this.finalMethods.Add(m);
         }
         insertRelationships(m.name, opt);
         return;
     }
     return;
 }
Esempio n. 2
0
        //This method would extract all the ids contain in one sql statement. These ids might be table name, column name or just some id useless. Then, we would check how many table name and column name are contained in the sql statement "p1". Finally, we would connect each table and column in the id list with this method "m".
        public void updateConnection(sqlStmtParser p1, desMethod m, string opt)
        {
            //This means all the component id in one sql statement. This id might be table name, column name or just some id useless.
            List<string> idList = p1.getAllIds();
            if (idList== null) return;
            List<dbTable> tableIds = new List<dbTable>();
            List<dbColumn> columnIds = new List<dbColumn>();

            //We check how many table name the id list contains and how many columns id it contians.
            foreach (var id in idList)
            {
                if (id != null)
                {
                    if (tablesInfo.Find(x => x.name.Equals(id, StringComparison.OrdinalIgnoreCase)) != null)
                    {
                        var tempTable = tablesInfo.Find(x => x.name.Equals(id, StringComparison.OrdinalIgnoreCase));
                        tableIds.Add(tempTable);
                        foreach (var col in tempTable.columns)
                        {
                            if (idList.Find(x => x.Equals(col.name, StringComparison.OrdinalIgnoreCase)) != null) columnIds.Add(col);
                        }
                    }
                }
            }

            //We connect each table id in the id list with this method "m".
            for (int i = 0; i < tablesInfo.Count; i++)
            {
                if (tableIds.Find(x => x == tablesInfo[i]) != null)
                {
                    tablesInfo[i].insertMethod(m, opt, "direct");
                    foreach (var mm in m.followmethods)
                    {
                        var tempMeDes = extractor.getMethodInfo(mm);
                        tablesInfo[i].insertMethod(tempMeDes, opt, "follow");
                    }
                    foreach (var mm in m.finalmethods)
                    {
                        var tempMeDes = extractor.getMethodInfo(mm);
                        tablesInfo[i].insertMethod(tempMeDes, opt, "final");
                    }
                }
            }
            if (columnIds.Count == 0) return;

            //we connect all the column id in the id list with the method m.
            for (int i=0; i < tablesInfo.Count; i++)
            {
                for (int j=0; j<tablesInfo[i].columns.Count; j++)
                {
                    if (columnIds.Find(x => x == tablesInfo[i].columns[j]) != null)
                    {
                        tablesInfo[i].columns[j].insertMethod(m, opt, "direct");
                        foreach (var mm in m.followmethods)
                        {
                            var tempMeDes = extractor.getMethodInfo(mm);
                            tablesInfo[i].columns[j].insertMethod(tempMeDes, opt, "follow");
                        }
                        foreach (var mm in m.finalmethods)
                        {
                            var tempMeDes = extractor.getMethodInfo(mm);
                            tablesInfo[i].columns[j].insertMethod(tempMeDes, opt, "final");
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 //When the list "methodsInfo" does not contain the information of a method "m", we could generate a new "desMethod" class for "m" and save the new class into lists.
 public desMethod newMethodInfo(MethodDefinition m)
 {
     desMethod typeM;
     SwumSummary swumSummary = new SwumSummary(m);
     swumSummary.BasicSummary();
     List<MethodDefinition> followers = new List<MethodDefinition>();
     List<MethodDefinition> finals = new List<MethodDefinition>();
     string desc = swumSummary.Describe();
     InvokeCallGraphGenerator tracer = new InvokeCallGraphGenerator(m, cgm);
     followers = tracer.traceToMethod();
     finals = tracer.traceToLastMethod();
     typeM = new desMethod(m, desc, followers, finals);
     methodsInfo.Add(typeM);
     return typeM;
 }