//------------------<Build up dependency analyzer>---------------
 public BuildDependencyAnalyzer(Lexer.ITokenCollection semi,
                                string file)
 {
     repo.semi             = semi;
     file_                 = file;
     currentNode           = new CsNode <string, string>(file);
     currentNode.nodeValue = file;
     currentNode.name      = file;
 }
        //---------------<Save node to the table>---------------
        override public bool doNodeOp(CsNode <string, string> node)
        {
            if (depTable.ContainsKey(node.ToString()))
            {
                return(false);
            }
            List <string> temp = new List <string>();

            depTable.Add(node.ToString(), temp);
            return(true);
        }
        //----< build dependency graph from dependency table >-----------

        public CsGraph <string, string> buildDependencyGraph()
        {
            var repo = Repository.getInstance();

            var graph = new CsGraph <string, string>("deps");

            foreach (var item in repo.dependencyTable.dependencies)
            {
                var fileName = item.Key;
                fileName = Path.GetFileName(fileName);

                var node = new CsNode <string, string>(fileName);
                graph.addNode(node);
            }

            var dt = new DependencyTable();

            foreach (var item in repo.dependencyTable.dependencies)
            {
                var fileName = item.Key;
                fileName = Path.GetFileName(fileName);
                if (!dt.dependencies.ContainsKey(fileName))
                {
                    var deps = new List <string>();
                    dt.dependencies.Add(fileName, deps);
                }

                foreach (var elem in item.Value)
                {
                    var childFile = elem;
                    childFile = Path.GetFileName(childFile);
                    dt.dependencies[fileName].Add(childFile);
                }
            }

            foreach (var item in graph.adjList)
            {
                var node     = item;
                var children = dt.dependencies[node.name];
                foreach (var child in children)
                {
                    var index = graph.findNodeByName(child);
                    if (index != -1)
                    {
                        var dep = graph.adjList[index];
                        node.addChild(dep, "edge");
                    }
                }
            }

            return(graph);
        }
 //--------------------<Add dependecy based on the type retrieved>---------------
 public void AddDep(string type, ref CsNode <string, string> currentNode)
 {
     if (type == "Constructor")
     {
         return;
     }
     if (!typeTable.Contains(type))
     {
         return;
     }
     if (typeTable[type].Count == 1)
     {
         CsNode <string, string> child = new CsNode <string, string>(typeTable[type][0].file);
         child.nodeValue = child.name;
         if (child.name != currentNode.name && !currentNode.ContainsChild(child.name))
         {
             StringBuilder edge = new StringBuilder();
             edge.Append(currentNode.name).Append(" - ").Append(child.name);
             currentNode.addChild(child, edge.ToString());
             Console.WriteLine("{0} added child {1}", currentNode.name, child.name);
         }
     }
     else
     {
         foreach (TypeInfo ti in typeTable[type])
         {
             if (nameSpace[type].Contains(ti.nameSpace))
             {
                 CsNode <string, string> child = new CsNode <string, string>(typeTable[type][0].file);
                 child.nodeValue = child.name;
                 if (child.name != currentNode.name && !currentNode.ContainsChild(child.name))
                 {
                     StringBuilder edge = new StringBuilder();
                     edge.Append(currentNode.name).Append(" - ").Append(child.name);
                     currentNode.addChild(child, edge.ToString());
                     Console.WriteLine("{0} added child {1}", currentNode.name, child.name);
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
        static public void Graphs()
        {
            foreach (var depend in dependentFiles)
            {
                CsNode <string, string> node;
                if (ListOfNodes.ContainsKey(depend.Key))
                {
                    node = ListOfNodes[depend.Key];
                }
                else
                {
                    node = new CsNode <string, string>(depend.Key);
                    ListOfNodes.Add(depend.Key, node);
                }
                foreach (var child in depend.Value)
                {
                    CsNode <string, string> nodes;
                    if (ListOfNodes.ContainsKey(child))
                    {
                        nodes = ListOfNodes[child];
                    }
                    else
                    {
                        nodes = new CsNode <string, string>(child);
                        ListOfNodes.Add(child, nodes);
                    }
                    node.addChild(nodes, "edge");
                }
            }

            foreach (var node in ListOfNodes)
            {
                List <CsNode <string, string> > ListOfChild = new List <CsNode <string, string> >();
                CsNode <string, string>         ParentNode  = node.Value;
                foreach (var chidNode in node.Value.children)
                {
                    ListOfChild.Add(chidNode.targetNode);
                }
                allgraphs.Add(ParentNode, ListOfChild);    //-----<holds the ParentNode and List of Child Nodes------>
            }
        }
 public CollectNew(ref CsNode <string, string> node)
 {
     currentNode_ = node;
     repo_        = Repository.getInstance();
 }
 public CollectMember(ref CsNode <string, string> node)
 {
     repo_        = Repository.getInstance();
     currentNode_ = node;
 }
 public SaveAll(ref CsNode <string, string> node)
 {
     repo_        = Repository.getInstance();
     currentNode_ = node;
 }
 //-------------<Add node to the graph>-----------
 public void addNode(CsNode <string, string> node)
 {
     graph_.addNode(node);
 }
Ejemplo n.º 10
0
        //----< add child vertex and its associated edge value to vertex >-----

        public void addChild(CsNode <V, E> childNode, E edgeVal)
        {
            children.Add(new CsEdge <V, E>(childNode, edgeVal));
        }
Ejemplo n.º 11
0
 public CsEdge(CsNode <V, E> node, E value)
 {
     targetNode = node;
     edgeValue  = value;
 }