Пример #1
0
        ///////////////////////////////////////////////////
        /// used to display types in XML format
        public XElement XMLType(XElement tt)
        {
            try
            {
                repo = Repository.getInstance();
                xdoc = new XDocument();
//                XElement tt = new XElement("Output");
                if (repo == null)
                    return tt;
                XElement tt1 = new XElement("TypeTable");
                foreach (Elem elem in repo.locations)
                {
                    if (elem.type == "function" || elem.type == "namespace")
                        continue;
                    XElement t = new XElement(elem.type);
                    XElement f = new XElement("FileName");
                    f.Value = elem.filename;
                    t.Add(f);
                    XElement n = new XElement("Name");
                    n.Value = elem.name;
                    t.Add(n);
                    XElement s = new XElement("StartLine");
                    s.Value = elem.begin.ToString();
                    t.Add(s);
                    XElement c = new XElement("EndLine");
                    c.Value = elem.end.ToString();
                    t.Add(c);
                    tt1.Add(t);
                }
                tt.Add(tt1);
                tt.Save("output.xml");
                return tt;
            }
            catch (Exception ex)
            {
                Console.Write("\n\n  {0}\n", ex.Message);
                return null;
            }

        }
 public Print(Repository repo)
 {
     repo_ = repo;
 }
 public PopStack(Repository repo)
 {
     repo_ = repo;
 }
 public SaveDeclar(Repository repo)
 {
     repo_ = repo;
 }
Пример #5
0
 public PushStack(Repository repo)
 {
     repo_ = repo;
 }
Пример #6
0
 public PushStackRelationship(Repository repo)
 {
     repo_ = repo;
 }
Пример #7
0
    private static void displayAnalysis(Repository rep)
    {
      string dispStr = "";

      foreach (string key in rep.LocationsTable.Keys)
      {
        dispStr = String.Format("\n  {0}", key);
        Display.displayString(dispStr);
        dispStr = String.Format(
            "\n    {0,25} {1,35} {2,5} {3,5} {4,5}",
            "category", "name", "bLine", "size", "cmplx"
        );
        Display.displayString(dispStr);
        dispStr = String.Format(
            "  {0,25} {1,35} {2,5} {3,5} {4,5}",
            "------------------", "-----------------------", "-----", "----", "-----"
        );
        Display.displayString(dispStr);

        foreach (Elem e in rep.LocationsTable[key])
        {
          if (e.type == "class" || e.type == "interface")
            Display.displayString("");
          dispStr = String.Format(
            "  {0,25} {1,35} {2,5} {3,5} {4,5}",
            e.type, e.name, e.beginLine,
            e.endLine - e.beginLine + 1, e.endScopeCount - e.beginScopeCount + 1
          );
          Display.displayString(dispStr);
        }
      }
    }
 public Repository()
 {
     instance = this;
 }
Пример #9
0
 public PushStackRelationship(Repository repo)
 {
     repo_ = repo;
 }
        //----< run Analyzer with error handling >-------------------------
        private static bool analyze(object path)
        {
            string url = "http://localhost:8080/FileService";

              IFileService fs = null;
              int count = 0;
              while (true)
              {
            try
            {
              fs = CreateChannelServer(url);
              break;
            }
            catch
            {
              Console.Write("\n  connection to service failed {0} times - trying again", ++count);
              Thread.Sleep(500);
              continue;
            }
              }
              Console.Write("\n  Connected to {0}\n", url);

              try
              {
            rep = fs.Analysis(path);
            return true;
              }
              catch (Exception exc)
              {
            Console.Write("\n  {0}\n\n", exc.Message);
            return false;
              }
        }
Пример #11
0
 public Print(Repository repo)
 {
     repo_ = repo;
 }
Пример #12
0
 public PrintFunction(Repository repo)
 {
     repo_ = repo;
 }
Пример #13
0
 public PopStack(Repository repo)
 {
     repo_ = repo;
 }
 public PrintFunction(Repository repo)
 {
     repo_ = repo;
 }
Пример #15
0
    private static void analysisSummary(Repository rep)
    {
      Console.Write("\n\n");
      Console.Write("\n  Analysis Summary - not counting braceless scopes yet");
      Console.Write("\n ======================================================");

      string dispStr;
      foreach (string key in rep.LocationsTable.Keys)
      {
        string filename = System.IO.Path.GetFileName(key);
        foreach (Elem e in rep.LocationsTable[key])
        {
          if (e.type.Contains("public"))
          {
            dispStr = String.Format("  {0,25}   {1}", filename, e.type);
            Display.displayString(dispStr);
          }
          if (e.type == "function")
          {
            int size = e.endLine - e.beginLine + 1;
            int complexity = e.endScopeCount - e.beginScopeCount + 1;
            if (size > 50 || complexity > 10)
            {
              dispStr = String.Format("  {0,25}   {1,-35} {2,5} {3,5}", filename, e.name, size, complexity);
              Display.displayString(dispStr);
            }
          }
        }
      }
      Console.Write("\n\n");
      //return dispStr;
    }
 public PushStack(Repository repo)
 {
     repo_ = repo;
 }
 public PushStack_relation(Repository repo)
 {
   repo_ = repo;
 }
Пример #18
0
 ///////////////////////////////////////////////////
 /// used to display relations in XML format
 public void XMLRelation(XElement tt)
 {
     try
     {
         repo = Repository.getInstance();
         xdoc = new XDocument();
         XElement tt3 = new XElement("RelationTable");
         if (repo == null)
             return;
         foreach (Elem_relation elem in repo.relations)
         {
             XElement t = new XElement(elem.relation);
             XElement f1 = new XElement("File1");
             f1.Value = elem.file1;
             t.Add(f1);
             XElement t1 = new XElement("Type1");
             t1.Value = elem.type1;
             t.Add(t1);
             XElement n1 = new XElement("Name1");
             n1.Value = elem.name1;
             t.Add(n1);
             XElement f2 = new XElement("File2");
             f2.Value = elem.file2;
             t.Add(f2);
             XElement t2 = new XElement("Type2");
             t2.Value = elem.type2;
             t.Add(t2);
             XElement n2 = new XElement("Name2");
             n2.Value = elem.name2;
             t.Add(n2);
             tt3.Add(t);
         }
         tt.Add(tt3);
         tt.Save("output.xml");
         return;
     }
     catch (Exception ex)
     {
         Console.Write("\n\n  {0}\n", ex.Message);
         return;
     }       
 }
Пример #19
0
 public Repository()
 {
     instance = this;
 }