Пример #1
0
        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());
        }
Пример #2
0
        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());
        }
 /// <summary>
 /// Constructs the SWUM for the given node, using this rule.
 /// </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;
         ParseBaseVerbName(mdn);
         mdn.AssignStructuralInformation(this.Splitter, this.PosTagger);
         DetermineMethodRole(mdn);
         SetDefaultActionAndTheme(mdn);
         mdn.SwumRuleUsed = this;
     }
 }
Пример #4
0
 /// <summary>
 /// Constructs the SWUM for the given node, using this rule.
 /// </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;
         //don't need to parse or tag, because there's no name
         //fill in SWUM
         mdn.AssignStructuralInformation(this.Splitter, this.PosTagger);
         mdn.Theme = mdn.Preamble;
         //TODO: from Emily, how to fill in Action?
         mdn.SwumRuleUsed = this;
     }
 }
Пример #5
0
        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);
        }
Пример #6
0
        /// <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?
            }
        }
 /// <summary>
 /// Determines whether the given MethodDeclarationNode meets the conditions for this rule.
 /// This method assumes that the name is parsed, preamble is stripped, and digits and prepositions are tagged.
 /// </summary>
 /// <param name="node">The MethodDeclarationNode to test.</param>
 /// <returns>True if the node meets the conditions for this rule, False otherwise.</returns>
 protected override bool MakeClassification(MethodDeclarationNode node)
 {
     node.AssignStructuralInformation(this.Splitter, this.PosTagger); //necessary to check event handler-ness
     return(IsEventHandler(node.FormalParameters));
 }
Пример #8
0
        public void TestAssignStructuralInformation_NullTagger()
        {
            MethodDeclarationNode mdn = new MethodDeclarationNode("MyMethod");

            mdn.AssignStructuralInformation(new NullSplitter(), null);
        }
 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());
 }
Пример #10
0
 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());
 }
Пример #11
0
 public void TestAssignStructuralInformation_NullTagger() {
     MethodDeclarationNode mdn = new MethodDeclarationNode("MyMethod");
     mdn.AssignStructuralInformation(new NullSplitter(), null);
 }
Пример #12
0
 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);
 }