public void FillNodeList(IEnumerator nodeEnumerator, String coode) { AllCode = coode; while (nodeEnumerator.MoveNext()) { if (((TreeNode)nodeEnumerator.Current).Text.Contains("ClassType = Class")) { //Name = tryOrDont) if (((TreeNode)nodeEnumerator.Current).Text.Contains("Name = ")) { string s = ((TreeNode)nodeEnumerator.Current).Text; string toBeSearched = "Name = "; string code = s.Substring(s.IndexOf(toBeSearched) + toBeSearched.Length); string[] arr = code.Split(')'); ClassNames.Add(arr[0]); LastClassName = arr[0]; } foreach (var node in ((TreeNode)nodeEnumerator.Current).Nodes) { //"Identifier: if (((TreeNode)node).Text.Contains("BaseType: SimpleType (Identifier")) { string[] ArrToGetParent = ((TreeNode)node).Text.Split('='); string[] arr2 = ArrToGetParent[1].Split(')'); classParentNameForCurrentClass = arr2[0]; } if (((TreeNode)node).Text.Contains("FieldDeclaration")) { Modifier localModifier; if (((TreeNode)node).Text.Contains("Modifiers = Public")) { localModifier = Modifier.Public; TempclassData.ClassAttributesModifierTypes.Add(localModifier); } else if (((TreeNode)node).Text.Contains("Modifiers = Private")) { localModifier = Modifier.Private; TempclassData.ClassAttributesModifierTypes.Add(localModifier); } else if (((TreeNode)node).Text.Contains("Modifiers = Protected")) { localModifier = Modifier.Protected; TempclassData.ClassAttributesModifierTypes.Add(localModifier); } else { localModifier = Modifier.Private; TempclassData.ClassAttributesModifierTypes.Add(localModifier); } String tempString = ((TreeNode)node).Tag.ToString(); TempclassData.ClassAttributes.Add(tempString); ClassHasContent = true; } else if (((TreeNode)node).Text.Contains("SymbolKind = Constructor")) { HasConstractor = true; } if (((TreeNode)node).Text.Contains("Main")) { GetDataFromBody((TreeNode)node); } else if (((TreeNode)node).Text.Contains("SymbolKind = Method")) { GetDataFromBody((TreeNode)node); } } if (ClassHasContent == false) { c = new List <FunctionsInEachClass>(); TempclassData.ClassName = LastClassName; if (HasConstractor == true) { TempclassData.HasConstructor = true; HasConstractor = false; } CodeNodesForEachClass.Add(TempclassData, c); TempclassData = new ClassData(); } else { ClassHasContent = false; } } else if (((TreeNode)nodeEnumerator.Current).Text.Contains("NamespaceDeclaration")) { if (((TreeNode)nodeEnumerator.Current).Text.Contains("Name = ")) { string s = ((TreeNode)nodeEnumerator.Current).Text; string toBeSearched = "Name = "; string code = s.Substring(s.IndexOf(toBeSearched) + toBeSearched.Length); string[] arr = code.Split(')'); ClassNames.Add(arr[0]); LastClassName = arr[0]; } foreach (var node in ((TreeNode)nodeEnumerator.Current).Nodes) { if (((TreeNode)node).Text.Contains("ClassType = Class")) { foreach (var node2 in ((TreeNode)node).Nodes) { if (((TreeNode)node2).Text.Contains("Main")) { GetDataFromBody((TreeNode)node2); } else if ((((TreeNode)node2).Text.Contains("SymbolKind = Method")) || (((TreeNode)node2).Text.Contains("Main"))) { GetDataFromBody((TreeNode)node2); } } break; } } } } }
private void GetDataFromBody(TreeNode node) { c = new List <FunctionsInEachClass>(); FunctionsInEachClass dc = new FunctionsInEachClass(); foreach (TreeNode n in ((TreeNode)node).Nodes) { if (((TreeNode)n).Text.Contains("Parameter: ParameterDeclaration")) { dc.FunctionParameter = ((TreeNode)n).Tag.ToString(); } if (((TreeNode)node).Text.Contains("Modifiers = Public")) { dc.FunctionModifierType = Modifier.Public; } else if (((TreeNode)node).Text.Contains("Modifiers = Private")) { dc.FunctionModifierType = Modifier.Private; } else if (((TreeNode)node).Text.Contains("Modifiers = Protected")) { dc.FunctionModifierType = Modifier.Protected; } if (((TreeNode)n).Text.Contains("(Name = ")) { string s = ((TreeNode)n).Text; string toBeSearched = "Name = "; string code = s.Substring(s.IndexOf(toBeSearched) + toBeSearched.Length); string[] arr = code.Split(')'); string[] arr2 = arr[0].Split(','); FunctionNames.Add(arr2[0]); LastFunctionName = arr2[0]; } else if (((TreeNode)n).Text.Contains("Body: BlockStatement")) { bool ClassExist = false; BodyRec(n, CodeNodes); List <Node> temp = new List <Node>(); temp = new List <Node>(CodeNodes); dc.FunctionName = LastFunctionName; dc.nodesInEachFunction = temp; c.Add(dc); TempclassData.ClassName = LastClassName; if (classParentNameForCurrentClass != "") { TempclassData.ParentClassName = classParentNameForCurrentClass; classParentNameForCurrentClass = ""; } foreach (var i in CodeNodesForEachClass) { if (i.Key.ClassName == TempclassData.ClassName) { ClassExist = true; i.Value.Add(dc); } } if (ClassExist == false) { if (HasConstractor == true) { TempclassData.HasConstructor = true; HasConstractor = false; } CodeNodesForEachClass.Add(TempclassData, c); CodeNodes.Clear(); } else { ClassExist = false; } TempclassData = new ClassData(); } ((TreeNode)n).Tag.ToString(); String sgg = ((TreeNode)n).Text; } ClassHasContent = true; TempclassData = new ClassData(); }