public bool IsMeaningfull() { bool checker = true; this.csharpTreeView = new System.Windows.Forms.TreeView(); SyntaxTree syntaxTree = new CSharpParser().Parse(richTextBoxUseCase.Text.ToString()); csharpTreeView.Nodes.Clear(); foreach (var element in syntaxTree.Children) { csharpTreeView.Nodes.Add(MakeTreeNode(element)); nodeEnumerator = csharpTreeView.Nodes.GetEnumerator(); } SelectCurrentNode(csharpTreeView.Nodes); parserHelper.FillNodeList(nodeEnumerator, richTextBoxUseCase.Text); FunctionsInEachClass tempf = new FunctionsInEachClass(); foreach (var el in parserHelper.CodeNodesForEachClass) { for (int i = 0; i < el.Value.Count; i++) { //FunctionsInEachClass tempf = new FunctionsInEachClass(); tempf = el.Value[i]; /*gogo.declerations_collector(tempf.nodesInEachFunction); * gogo.detect_wrong(); * gogo.coloring_wrong(richTextBoxUseCase); * if (gogo.wrong_names.Count !=0) { * checker = false; * }*/ } } //return checker; return(true); }
/////////////////////////////////////////////////////////////////////////// public bool IsMeaningfull() { this.csharpTreeView = new System.Windows.Forms.TreeView(); SyntaxTree syntaxTree = new CSharpParser().Parse(richTextBox1.Text.ToString()); csharpTreeView.Nodes.Clear(); foreach (var element in syntaxTree.Children) { csharpTreeView.Nodes.Add(MakeTreeNode(element)); nodeEnumerator = csharpTreeView.Nodes.GetEnumerator(); } SelectCurrentNode(csharpTreeView.Nodes); parserHelper.FillNodeList(nodeEnumerator, richTextBox1.Text); FunctionsInEachClass tempf = new FunctionsInEachClass(); foreach (var el in parserHelper.CodeNodesForEachClass) { for (int i = 0; i < el.Value.Count; i++) { if (el.Value[i].FunctionName == "Main") { //FunctionsInEachClass tempf = new FunctionsInEachClass(); tempf = el.Value[i]; } } } gogo.declerations_collector(tempf.nodesInEachFunction); gogo.detect_wrong(); gogo.coloring_wrong(richTextBox1); return(gogo.wrong_names.Count == 0); }
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(); }
private void btn_Check_Click(object sender, EventArgs e) { StringAccessors accessor = StringAccessors.Instance; accessor.setCode(richTextBox1.Text.ToString()); //--------------------------------------------------------------------------------------- this.csharpTreeView = new System.Windows.Forms.TreeView(); SyntaxTree syntaxTree = new CSharpParser().Parse(richTextBox1.Text.ToString()); csharpTreeView.Nodes.Clear(); foreach (var element in syntaxTree.Children) { csharpTreeView.Nodes.Add(MakeTreeNode(element)); nodeEnumerator = csharpTreeView.Nodes.GetEnumerator(); } SelectCurrentNode(csharpTreeView.Nodes); parserHelper.FillNodeList(nodeEnumerator, richTextBox1.Text); List <FunctionsInEachClass> tempf = new List <FunctionsInEachClass>(); foreach (var el in parserHelper.CodeNodesForEachClass) { FunctionsInEachClass f = new FunctionsInEachClass(); if (el.Key.ClassAttributes.Count() != 0) { for (int l = 0; l < el.Key.ClassAttributes.Count(); l++) { Node ss = new Node(); ss.CodeLine = el.Key.ClassAttributes[l]; ss.Type = StatementTypes.VariableDeclaration; f.nodesInEachFunction.Add(ss); tempf.Add(f); } } for (int i = 0; i < el.Value.Count; i++) { //FunctionsInEachClass tempf = new FunctionsInEachClass(); tempf.Add(el.Value[i]); } } gogo.aval_words(); for (int h = 0; h < tempf.Count(); h++) { gogo.declerations_collector(tempf[h].nodesInEachFunction); } gogo.detect_wrong(); CommentCode(); gogo.coloring_wrong(richTextBox1); //-------------------------------------------------------------------------------------- parserHelper.CodeNodes.Clear(); tempf.Clear(); }