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()); }
/// <summary> /// Determines whether the given node satisfies this rule. /// /// ** Note that calling this method has the effect of stripping any preamble from the given node, and tagging any digits and prepositions. ** /// </summary> /// <param name="node">The node to test.</param> /// <returns>True if the node matches this rule, False otherwise.</returns> public override bool InClass(ProgramElementNode node) { if (node is MethodDeclarationNode) { MethodDeclarationNode mdn = (MethodDeclarationNode)node; mdn.Parse(this.Splitter); this.PosTagger.PreTag(mdn); return(MakeClassification(mdn)); } return(false); }
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 TestAssignStructuralInformation() { 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("MyMethod", mc); mdn.Parse(new NullSplitter()); mdn.AssignStructuralInformation(new NullSplitter(), new NullTagger()); Assert.AreEqual(Location.Name, mdn.ParsedName.Location); Assert.AreEqual("int", mdn.ReturnType.Name); Assert.IsTrue(mdn.ReturnType.IsPrimitive); Assert.AreEqual("MyClass", mdn.DeclaringClass.Name); Assert.AreEqual(2, mdn.FormalParameters.Count); Assert.AreEqual("SGVData*", mdn.FormalParameters[0].Type.Name); Assert.AreEqual("p", mdn.FormalParameters[0].Name); Assert.AreEqual("ASSchedule*", mdn.FormalParameters[1].Type.Name); Assert.AreEqual("p2", mdn.FormalParameters[1].Name); }
/// <summary> /// Constructs the Software Word Use Model for the given node. /// This method assumes that the node has already been tested to satisfy this Rule, using the InClass method. /// </summary> /// <param name="node">The node to construct SWUM for.</param> public override void ConstructSwum(ProgramElementNode node) { if (node is MethodDeclarationNode) { MethodDeclarationNode mdn = (MethodDeclarationNode)node; mdn.Parse(this.Splitter); this.PosTagger.TagNounPhrase(mdn.ParsedName); mdn.AssignStructuralInformation(this.Splitter, this.PosTagger); mdn.Theme = mdn.ParsedName; mdn.AddUnknownArguments(mdn.FormalParameters); //TODO: from Emily, how to fill in Action? mdn.IsDestructor = true; mdn.SwumRuleUsed = this; } else { //TODO: return error? } }
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()); }
public void TestAssignStructuralInformation() { 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("MyMethod", mc); mdn.Parse(new NullSplitter()); mdn.AssignStructuralInformation(new NullSplitter(), new NullTagger()); Assert.AreEqual(Location.Name, mdn.ParsedName.Location); Assert.AreEqual("int", mdn.ReturnType.Name); Assert.IsTrue(mdn.ReturnType.IsPrimitive); Assert.AreEqual("MyClass", mdn.DeclaringClass.Name); Assert.AreEqual(2, mdn.FormalParameters.Count); Assert.AreEqual("SGVData*", mdn.FormalParameters[0].Type.Name); Assert.AreEqual("p", mdn.FormalParameters[0].Name); Assert.AreEqual("ASSchedule*", mdn.FormalParameters[1].Type.Name); Assert.AreEqual("p2", mdn.FormalParameters[1].Name); }