ABB.Swum.FieldRule.ConstructSwum C# (CSharp) Method

ConstructSwum() public method

Constructs the Software Word Use Model on the given node, using this Rule.
public ConstructSwum ( ProgramElementNode node ) : void
node ABB.Swum.Nodes.ProgramElementNode The node to construct the SWUM on.
return void
        public override void ConstructSwum(ProgramElementNode node)
        {
            if (node is FieldDeclarationNode)
            {
                FieldDeclarationNode fdn = node as FieldDeclarationNode;
                fdn.Parse(this.Splitter);
                this.PosTagger.TagNounPhrase(fdn.ParsedName);
                fdn.AssignStructuralInformation(this.Splitter, this.PosTagger);
                //TODO: set fdn.Type.IsPrimitive
                fdn.SwumRuleUsed = this;
            }
            else
            {
                //TODO: return some sort of error indicator?
                Console.Error.WriteLine("FieldRule.ConstructSwum expected a FieldDeclarationNode, received a {0}", node.GetType());
            }
        }
    }

Usage Example

Example #1
0
        public void TestConstructSwum()
        {
            string testSrcML = "<class>class <name>foo</name> <block>{<private type=\"default\"><decl_stmt><decl><type><name>int</name></type> <name>a</name></decl>;</decl_stmt></private>}</block>;</class>";
            XElement xml = XElement.Parse(string.Format(srcMLFormat, testSrcML), LoadOptions.PreserveWhitespace);
            FieldContext fc = ContextBuilder.BuildFieldContext(xml.Descendants(SRC.Declaration).First());

            FieldDeclarationNode fdn = new FieldDeclarationNode("a", fc);
            FieldRule rule = new FieldRule(posData, tagger, splitter);
            rule.ConstructSwum(fdn);
            Console.WriteLine(fdn.ToString());
        }