public void TestToPlainString_NotParsed() { var formals = new FormalParameterRecord[] { new FormalParameterRecord("SGVData*", false, "p"), new FormalParameterRecord("ASSchedule*", false, "p2") }; MethodContext mc = new MethodContext("int", true, "MyClass", formals, true, false, false); MethodDeclarationNode mdn = new MethodDeclarationNode("CalcNewValue", mc); Assert.AreEqual("CalcNewValue", mdn.ToPlainString()); }
public void TestToPlainString_DefaultContext() { var mdn = new MethodDeclarationNode("MyMethod", new MethodContext()); var splitter = new ConservativeIdSplitter(); mdn.Parse(splitter); mdn.AssignStructuralInformation(splitter, new UnigramTagger()); Assert.AreEqual("My Method", mdn.ToPlainString()); }
public void TestToPlainString_Context() { var formals = new FormalParameterRecord[] { new FormalParameterRecord("SGVData*", false, "p"), new FormalParameterRecord("ASSchedule*", false, "p2") }; MethodContext mc = new MethodContext("int", true, "MyClass", formals, true, false, false); MethodDeclarationNode mdn = new MethodDeclarationNode("CalcNewValue", mc); var splitter = new ConservativeIdSplitter(); mdn.Parse(splitter); mdn.AssignStructuralInformation(splitter, new UnigramTagger()); Assert.AreEqual("Calc New Value", mdn.ToPlainString()); }
public void TestToPlainString_NotParsed() { var formals = new FormalParameterRecord[] { new FormalParameterRecord("SGVData*", false, "p"), new FormalParameterRecord("ASSchedule*", false, "p2") }; MethodContext mc = new MethodContext("int", true, "MyClass", formals, true, false, false); MethodDeclarationNode mdn = new MethodDeclarationNode("CalcNewValue", mc); Assert.AreEqual("CalcNewValue", mdn.ToPlainString()); }
public void TestToPlainString_Context() { var formals = new FormalParameterRecord[] { new FormalParameterRecord("SGVData*", false, "p"), new FormalParameterRecord("ASSchedule*", false, "p2") }; MethodContext mc = new MethodContext("int", true, "MyClass", formals, true, false, false); MethodDeclarationNode mdn = new MethodDeclarationNode("CalcNewValue", mc); var splitter = new ConservativeIdSplitter(); mdn.Parse(splitter); mdn.AssignStructuralInformation(splitter, new UnigramTagger()); Assert.AreEqual("Calc New Value", mdn.ToPlainString()); }
public void TestToPlainString_DefaultContext() { var mdn = new MethodDeclarationNode("MyMethod", new MethodContext()); var splitter = new ConservativeIdSplitter(); mdn.Parse(splitter); mdn.AssignStructuralInformation(splitter, new UnigramTagger()); Assert.AreEqual("My Method", mdn.ToPlainString()); }
private static SUnit TranslateAssignment(Statement statement) { // action = "Assign" // define left-hand-side (lhs) // theme = right hand side var fieldRule = SetupFieldRule(); // var equalsSign = statement.GetDescendants<OperatorUse>() // .Where(o => o.Text.Equals("=")).First(); // var lhs = equalsSign.GetSiblingsBeforeSelf<VariableUse>().First(); var assignExpression = (VariableDeclaration)statement.GetExpressions().First(); var lhs = assignExpression.Name; var lhsFieldContext = new FieldContext(assignExpression.VariableType.ToString(), false, ""); var lhsDecNode = new FieldDeclarationNode(lhs.ToString(), lhsFieldContext); fieldRule.InClass(lhsDecNode); fieldRule.ConstructSwum(lhsDecNode); var rhsString = ""; var rhsAction = ""; var rhsTheme = ""; Expression rhs = new Expression(); if (assignExpression.Initializer != null) { rhs = assignExpression.Initializer; } if (rhs is VariableUse) { var rhsFieldContext = new FieldContext(rhs.ResolveType().First().ToString(), false, ""); var rhsDecNode = new FieldDeclarationNode(rhs.ToString(), lhsFieldContext); fieldRule.InClass(rhsDecNode); fieldRule.ConstructSwum(rhsDecNode); rhsAction = "Assign"; rhsString = rhsDecNode.ToPlainString(); } else if (rhs is MethodCall) { string type = rhs.ResolveType().ToString(); MethodContext mc = new MethodContext(type); MethodDeclarationNode mdn = new MethodDeclarationNode(rhs.ToString(), mc); var swumRule = SetupBaseVerbRule(); swumRule.InClass(mdn); swumRule.ConstructSwum(mdn); rhsAction = mdn.Action.ToPlainString(); rhsTheme = mdn.Action.ToPlainString(); rhsString = mdn.ToPlainString(); } else { rhsString = rhs.ToString(); } var sunit = new SUnit(); sunit.type = SUnitType.Assignment; sunit.action = rhsString; //sunit.lhs = lhsDecNode.ToPlainString(); sunit.lhs = lhs.ToString(); sunit.theme = rhsString; return(sunit); }