public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) { Contract.Requires(methodDeclaration != null); // Visit the body block statement of method declaration methodDeclaration.Body.AcceptVisitor(this, null); // Method cannot be the same var objMethod = new MethodStructure { Name = methodDeclaration.Name, StartLine = methodDeclaration.StartLocation.Line, EndLine = methodDeclaration.Body.EndLocation.Line }; // Get the class contains this method var objParent = (TypeDeclaration)methodDeclaration.Parent; // Get class instance var objClass = DictClass[objParent.Name]; objClass.Methods.Add(objMethod); return null; }
public MethodStructure BuildMethod(METHOD method) { var require = method.REQUIRES.FirstOrDefault(item => item.IDMethod == method.ID) != null ? method.REQUIRES.FirstOrDefault(item => item.IDMethod == method.ID).NoiDung : null; var ensure = method.REQUIRES.FirstOrDefault(item => item.IDMethod == method.ID) != null ? method.REQUIRES.FirstOrDefault(item => item.IDMethod == method.ID).NoiDung : null; var methodStr = new MethodStructure { Name = method.TenMethod, Require = require, Ensure = ensure, LstPreCondition = require != null ? MethodStructure.InitRequires(require) : null, LstPosCondition = ensure != null ? MethodStructure.InitEnsure(ensure) : null, StartLine = method.StartLine.Value, EndLine = method.EndLine.Value }; return methodStr; }
public string GetOriginMethod(string classPath, MethodStructure _method) { var result = ""; try { FileStream fs = new FileStream(classPath, FileMode.Open); StreamReader sr = new StreamReader(fs); string line = ""; int lineNo = 1; do { line = sr.ReadLine(); if (lineNo >= _method.StartLine) { result += (line + "\r\n"); } lineNo++; } while (lineNo <= _method.EndLine); sr.Close(); fs.Close(); } catch { result = ""; } return result; }
public string GeneratePosCondition(MethodStructure _method, ref string callMethod) { var result = ""; result += _method.GeneratePosCondition(ref callMethod); return result; }
public void Insert_Method(int idclass, MethodStructure methodStr) { var _method = InsertMETHODS(idclass, methodStr.Name, methodStr.StartLine, methodStr.EndLine); if (_method != null) { // Insert require if (methodStr.Require != null && methodStr.Require != "") { InsertREQUIRES(_method.ID, methodStr.Require); } // Insert ensure if (methodStr.Ensure != null && methodStr.Ensure != "") { InsertENSURES(_method.ID, methodStr.Ensure); } } }