示例#1
0
        private void createContent(String varName, Object objectToPass, StringReader reader, String outputFileName)
        {
            Dictionary<String, Object> map = new Dictionary<String, Object>();
            map.Add(varName, objectToPass);

            String outputContent = null;
            StringTemplateGroup group = new StringTemplateGroup(reader);
            var contentTemplate = group.GetInstanceOf("Content");
            contentTemplate.Attributes = map;
            outputContent = contentTemplate.ToString();
            //StringBuilder sb = new StringBuilder(outputContent);
            StringWriter writer = new StringWriter(new StringBuilder(outputContent));
            writer.Flush();
            StreamWriter fileWriter = null;
            try
            {
                fileWriter = new StreamWriter(outputFileName + "/report.html.data");
                fileWriter.Write(writer.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            writer.Close();
            fileWriter.Close();
        }
示例#2
0
 public string EvaluateFile(string fileName, IDictionary<string, object> context)
 {
     var stringTemplateGroup = new StringTemplateGroup("group", AppDomain.CurrentDomain.BaseDirectory);
     stringTemplateGroup.ErrorListener = new StringTemplateErrorListener();
     StringTemplate stringTemplate = stringTemplateGroup.GetInstanceOf(fileName, context);
     return stringTemplate.ToString();
 }
示例#3
0
        //This function is used to generate the summary of whole target projet. The summary is showed in the left part of our report, the details is defined in the two HashSet above.
        public void GenerateSummary(string stsum)
        {
            Console.WriteLine("Now let's generate summary..");
            foreach(var table in db.tablesInfo)
            {
                table.generateDescription(db);
                if (table.directMethods.Count>0 || table.columns.Find(x => x.directMethods.Count>0)!=null)
                {
                    SingleSummary tcSummary = new SingleSummary(table.title, table.attribute, table.methodsDes,table.name,table.generateLeftIndex());
                    AllTableSummary.Add(tcSummary);
                }
                foreach(var column in table.columns)
                {
                    column.generateDescription(db);
                    if (column.directMethods.Count == 0) continue;
                    SingleSummary tcSummary = new SingleSummary(column.title, column.attribute, column.methodsDes,table.name,"");
                    AllColumnSummary.Add(tcSummary);
                }
            }

            //generating Javascript for webpage
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate st = group.GetInstanceOf("GenerateScript");
            foreach(var me in extractor.methodsInfo)
            {
                st.SetAttribute("FunctionName",TakePointOff(me.name));
                st.SetAttribute("MethodFullName",me.name);
                st.SetAttribute("MethodName", me.methodself.Name);
            }
            FinalGenerator homePageGenerator = new FinalGenerator(this.AllTableSummary, this.AllColumnSummary,st.ToString(),stsum);
            homePageGenerator.Generate(outputLoc);
        }
示例#4
0
        public void Generate(string path)
        {
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate st = group.GetInstanceOf("CourseHome");
            int ID = 1;
            st.SetAttribute("Function", AllShiftFunction);
            st.SetAttribute("ProjectSum", projectSum);
            foreach (var testSummary in AllTableSummary) {
                st.SetAttribute("IDNum", ID++);
                st.SetAttribute("Title", testSummary.title);
                st.SetAttribute("Content", testSummary.attributions + "</p>" + testSummary.methodInfo);
                st.SetAttribute("Index", testSummary.tableIndex);
                foreach (var subSummary in AllColumnSummary)
                {
                    if (subSummary.tableName != testSummary.tableName) continue;
                    st.SetAttribute("IDNum", ID++);
                    st.SetAttribute("Title", subSummary.title);
                    st.SetAttribute("Content", subSummary.attributions + "</p>" + subSummary.methodInfo);
                }

            }

            String result = st.ToString();
            StreamWriter writetext = new StreamWriter(path);
            writetext.WriteLine(result);
            writetext.Close();
        }
示例#5
0
        public string RenderTemplate(string groupName, string groupPath, string templateName, IEnumerable<KeyValuePair<string, object>> templateData)
        {
            var templateGroup = new StringTemplateGroup(groupName, groupPath);
            var template = templateGroup.GetInstanceOf(templateName);

            foreach(var d in templateData)
            {
                template.SetAttribute(d.Key, d.Value);
            }

            template.RegisterRenderer(typeof(DateTime), new DateRenderer());
            template.RegisterRenderer(typeof(String), new BasicFormatRenderer());

            return template.ToString();
        }
示例#6
0
        //This method would generate the summary for the project and prepare all the other data for final report.
        public void run()
        {
            Console.WriteLine("Starting collecting data for reporter");

            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate stsum = group.GetInstanceOf("ProjectSummary");
            int tableCount = 0;
            int totalCount = 0;
            foreach (var tempT in db.tablesInfo)
            {
                if (tempT.directMethods.Count > 0) { tableCount++; totalCount++; }
                foreach (var tempC in tempT.columns)
                {
                    if (tempC.directMethods.Count > 0) totalCount++;
                }
            }
            stsum.SetAttribute("TableNumber", tableCount);
            stsum.SetAttribute("AllNumber", totalCount);
            stsum.SetAttribute("MethodNumber", extractor.allDirectMethods.Count);
            GenerateSummary(stsum.ToString());
        }
示例#7
0
 //This method would generate the description of this method and we could show the description in the final report.
 public string getHtmlDescribe(List<string> allSql, string TorC, string optType)
 {
     string htmlText = "";
     StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
     StringTemplate st = group.GetInstanceOf("MethodDes");
     st.SetAttribute("FunctionName", TakePointOff(name));
     st.SetAttribute("MethodFullName", name);
     st.SetAttribute("MethodName", methodself.Name);
     st.SetAttribute("MethodSum", swumsummary);
     if (allSql != null)
     {
         foreach (var singleSql in allSql)
         {
             var tempText = translateStmt(singleSql, TorC, optType);
             if (tempText == "") continue;
             st.SetAttribute("SQLs", translateStmt(singleSql, TorC, optType));
         }
     }
     htmlText = st.ToString();
     return htmlText;
 }
示例#8
0
        public void TestGroupTrailingSemiColon()
        {
            //try {
                string templates =
                        "group test;" + newline +
                        "t1()::=\"R1\"; " + newline +
                        "t2() ::= \"R2\"" + newline
                        ;
                StringTemplateGroup group =
                        new StringTemplateGroup( new StringReader( templates ) );

                StringTemplate st = group.GetInstanceOf( "t1" );
                Assert.AreEqual( "R1", st.ToString() );

                st = group.GetInstanceOf( "t2" );
                Assert.AreEqual( "R2", st.ToString() );

                Assert.Fail( "A parse error should have been generated" );
            //} catch (ParseError??) {
            //}
        }
示例#9
0
 public void TestComplicatedIndirectTemplateApplication()
 {
     string templates =
             "group Java;" + newline +
             "" + newline +
             "file(variables) ::= <<" +
             "<variables:{ v | <v.decl:(v.format)()>}; separator=\"\\n\">" + newline +
             ">>" + newline +
             "intdecl(decl) ::= \"int <decl.name> = 0;\"" + newline +
             "intarray(decl) ::= \"int[] <decl.name> = null;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate f = group.GetInstanceOf( "file" );
     f.SetAttribute( "variables.{decl,format}", new Decl( "i", "int" ), "intdecl" );
     f.SetAttribute( "variables.{decl,format}", new Decl( "a", "int-array" ), "intarray" );
     //System.out.println("f='"+f+"'");
     string expecting = "int i = 0;" + newline +
             "int[] a = null;";
     Assert.AreEqual( expecting, f.ToString() );
 }
示例#10
0
 public void TestArgumentsAsTemplatesDefaultDelimiters()
 {
     string templates =
             "group test;" + newline +
             "method(name,size) ::= <<" + newline +
             "$stat(value={$size$})$" + newline +
             ">>" + newline +
             "stat(value) ::= \"x=$value$;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     typeof( DefaultTemplateLexer ) );
     StringTemplate b = group.GetInstanceOf( "method" );
     b.SetAttribute( "name", "foo" );
     b.SetAttribute( "size", "34" );
     string expecting = "x=34;";
     string result = b.ToString();
     Assert.AreEqual( expecting, result );
 }
示例#11
0
 public void TestRepeatedRestOpAsArg()
 {
     String templates =
             "group test;" + newline +
             "root(names) ::= \"$other(rest(names))$\"" + newline +
             "other(x) ::= \"$x$, $x$\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     typeof( DefaultTemplateLexer ) );
     StringTemplate e = group.GetInstanceOf( "root" );
     e.SetAttribute( "names", "Ter" );
     e.SetAttribute( "names", "Tom" );
     String expecting = "Tom, Tom";
     Assert.AreEqual( expecting, e.ToString() );
 }
示例#12
0
 public void TestWhiteSpaceAtEndOfTemplate()
 {
     StringTemplateGroup group = new StringTemplateGroup( "group", System.Reflection.Assembly.GetExecutingAssembly() );
     StringTemplate pageST = group.GetInstanceOf( "AntlrUnitTests/page" );
     StringTemplate listST = group.GetInstanceOf( "AntlrUnitTests/users_list" );
     // users.list references row.st which has a single blank line at the end.
     // I.e., there are 2 \n in a row at the end
     // ST should eat all whitespace at end
     listST.SetAttribute( "users", new Connector() );
     listST.SetAttribute( "users", new Connector2() );
     pageST.SetAttribute( "title", "some title" );
     pageST.SetAttribute( "body", listST );
     string expecting = "some title" + newline +
         "Terence [email protected] [email protected]";
     string result = pageST.ToString();
     //System.out.println("'"+result+"'");
     Assert.AreEqual( expecting, result );
 }
示例#13
0
 public void TestArgumentsAsTemplates()
 {
     string templates =
             "group test;" + newline +
             "method(name,size) ::= <<" + newline +
             "<stat(value={<size>})>" + newline +
             ">>" + newline +
             "stat(value) ::= \"x=<value>;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate b = group.GetInstanceOf( "method" );
     b.SetAttribute( "name", "foo" );
     b.SetAttribute( "size", "34" );
     string expecting = "x=34;";
     string result = b.ToString();
     Assert.AreEqual( expecting, result );
 }
示例#14
0
 public string GetTemplate(string groupName, string groupPath, string templateName)
 {
     var templateGroup = new StringTemplateGroup(groupName, groupPath);
     return templateGroup.GetInstanceOf(templateName).Template;
 }
示例#15
0
 public void TestTemplateArgumentEvaluatedInSurroundingContext()
 {
     string templates =
             "group test;" + newline +
             "file(m,size) ::= \"<m>\"" + newline +
             "method(name) ::= <<" + newline +
             "<stat(value={<size>.0})>" + newline +
             ">>" + newline +
             "stat(value) ::= \"x=<value>;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate f = group.GetInstanceOf( "file" );
     f.SetAttribute( "size", "34" );
     StringTemplate m = group.GetInstanceOf( "method" );
     m.SetAttribute( "name", "foo" );
     f.SetAttribute( "m", m );
     string expecting = "x=34.0;";
     string result = m.ToString();
     Assert.AreEqual( expecting, result );
 }
示例#16
0
 public void TestTemplatePolymorphism()
 {
     StringTemplateGroup group = new StringTemplateGroup( "super" );
     StringTemplateGroup subGroup = new StringTemplateGroup( "sub" );
     subGroup.SuperGroup = group;
     // bold is defined in both super and sub
     // if you create an instance of page via the subgroup,
     // then bold() should evaluate to the subgroup not the super
     // even though page is defined in the super.  Just like polymorphism.
     group.DefineTemplate( "bold", "<b>$it$</b>" );
     group.DefineTemplate( "page", "$name:bold()$" );
     subGroup.DefineTemplate( "bold", "<strong>$it$</strong>" );
     StringTemplate st = subGroup.GetInstanceOf( "page" );
     st.SetAttribute( "name", "Ter" );
     string expecting =
             "<strong>Ter</strong>";
     Assert.AreEqual( expecting, st.ToString() );
 }
示例#17
0
 //This method is used to generate the index of this table and the index is put in the left side of the report. With this index we could put the table and the columns belong to this table together.
 public string generateLeftIndex()
 {
     StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
     StringTemplate st = group.GetInstanceOf("TableLeft");
     string finalstring = "";
     finalstring += "<a href=\"#" + this.title +"\">" + this.title +"</a><br>";
     foreach (var col in this.columns)
     {
         if (col.directMethods.Count==0) continue;
         st.SetAttribute("Columns", "Column:"+col.name);
         st.SetAttribute("Links", col.title);
     }
     finalstring += st.ToString();
     return finalstring;
 }
示例#18
0
        public void TestTemplateParameterDecls()
        {
            string templates =
                    "group test;" + newline +
                    "t() ::= \"no args but ref $foo$\"" + newline +
                    "t2(item) ::= \"decl but not used is ok\"" + newline +
                    "t3(a,b,c,d) ::= <<$a$ $d$>>" + newline +
                    "t4(a,b,c,d) ::= <<$a$ $b$ $c$ $d$>>" + newline
                    ;
            StringTemplateGroup group =
                    new StringTemplateGroup( new StringReader( templates ),
                                            typeof( DefaultTemplateLexer ) );

            // check setting unknown arg in empty formal list
            StringTemplate a = group.GetInstanceOf( "t" );
            string error = null;
            try
            {
                a.SetAttribute( "foo", "x" ); // want NoSuchElementException
            }
            catch ( ArgumentException e )
            {
                error = e.Message;
            }
            string expecting = "no such attribute: foo in template context [t]";
            Assert.AreEqual( expecting, error );

            // check setting known arg
            a = group.GetInstanceOf( "t2" );
            a.SetAttribute( "item", "x" ); // shouldn't get exception

            // check setting unknown arg in nonempty list of formal args
            a = group.GetInstanceOf( "t3" );
            a.SetAttribute( "b", "x" );
        }
示例#19
0
 public void TestTemplateGetPropertyGetsAttribute()
 {
     // This test will cause infinite loop if missing attribute no
     // properly caught in getAttribute
     string templates =
             "group test;" + newline +
             "Cfile(funcs) ::= <<" + newline +
             "#include \\<stdio.h>" + newline +
             "<funcs:{public void <it.name>(<it.args>);}; separator=\"\\n\">" + newline +
             "<funcs; separator=\"\\n\">" + newline +
             ">>" + newline +
             "func(name,args,body) ::= <<" + newline +
             "public void <name>(<args>) {<body>}" + newline +
             ">>" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate b = group.GetInstanceOf( "Cfile" );
     StringTemplate f1 = group.GetInstanceOf( "func" );
     StringTemplate f2 = group.GetInstanceOf( "func" );
     f1.SetAttribute( "name", "f" );
     f1.SetAttribute( "args", "" );
     f1.SetAttribute( "body", "i=1;" );
     f2.SetAttribute( "name", "g" );
     f2.SetAttribute( "args", "int arg" );
     f2.SetAttribute( "body", "y=1;" );
     b.SetAttribute( "funcs", f1 );
     b.SetAttribute( "funcs", f2 );
     string expecting = "#include <stdio.h>" + newline +
             "public void f();" + newline +
             "public void g(int arg);" + newline +
             "public void f() {i=1;}" + newline +
             "public void g(int arg) {y=1;}";
     Assert.AreEqual( expecting, b.ToString() );
 }
示例#20
0
 public void TestArgEvaluationContext()
 {
     string templates =
             "group test;" + newline +
             "method(name) ::= \"<stat(name=name)>\"" + newline +
             "stat(name) ::= \"x=y; // <name>\"" + newline
             ;
     // attribute name is not visible in stat because of the formal
     // arg called name in template stat.  However, we can set it's value
     // with an explicit name=name.  This looks weird, but makes total
     // sense as the rhs is evaluated in the context of method and the lhs
     // is evaluated in the context of stat's arg list.
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate b = group.GetInstanceOf( "method" );
     b.SetAttribute( "name", "foo" );
     string expecting = "x=y; // foo";
     string result = b.ToString();
     //System.err.println("result='"+result+"'");
     Assert.AreEqual( expecting, result );
 }
示例#21
0
 public void TestComplicatedInheritance()
 {
     // in super: decls invokes labels
     // in sub:   overridden decls which calls super.decls
     //           overridden labels
     // Bug: didn't see the overridden labels.  In other words,
     // the overridden decls called super which called labels, but
     // didn't get the subgroup overridden labels--it calls the
     // one in the superclass.  Ouput was "DL" not "DSL"; didn't
     // invoke sub's labels().
     string basetemplates =
         "group base;" + newline +
         "decls() ::= \"D<labels()>\"" + newline +
         "labels() ::= \"L\"" + newline
         ;
     StringTemplateGroup @base =
         new StringTemplateGroup( new StringReader( basetemplates ) );
     string subtemplates =
         "group sub;" + newline +
         "decls() ::= \"<super.decls()>\"" + newline +
         "labels() ::= \"SL\"" + newline
         ;
     StringTemplateGroup sub =
             new StringTemplateGroup( new StringReader( subtemplates ) );
     sub.SuperGroup = @base;
     StringTemplate st = sub.GetInstanceOf( "decls" );
     string expecting = "DSL";
     string result = st.ToString();
     Assert.AreEqual( expecting, result );
 }
示例#22
0
 public void TestSuperTemplateRef()
 {
     // you can refer to a template defined in a super group via super.t()
     StringTemplateGroup group = new StringTemplateGroup( "super" );
     StringTemplateGroup subGroup = new StringTemplateGroup( "sub" );
     subGroup.SuperGroup = group;
     group.DefineTemplate( "page", "$font()$:text" );
     group.DefineTemplate( "font", "Helvetica" );
     subGroup.DefineTemplate( "font", "$super.font()$ and Times" );
     StringTemplate st = subGroup.GetInstanceOf( "page" );
     string expecting =
             "Helvetica and Times:text";
     Assert.AreEqual( expecting, st.ToString() );
 }
示例#23
0
 public void TestSuperReferenceInIfClause()
 {
     string superGroupString =
         "group super;" + newline +
         "a(x) ::= \"super.a\"" + newline +
         "b(x) ::= \"<c()>super.b\"" + newline +
         "c() ::= \"super.c\""
         ;
     StringTemplateGroup superGroup = new StringTemplateGroup(
         new StringReader( superGroupString ), typeof( AngleBracketTemplateLexer ) );
     string subGroupString =
         "group sub;\n" +
         "a(x) ::= \"<if(x)><super.a()><endif>\"" + newline +
         "b(x) ::= \"<if(x)><else><super.b()><endif>\"" + newline +
         "c() ::= \"sub.c\""
         ;
     StringTemplateGroup subGroup = new StringTemplateGroup(
         new StringReader( subGroupString ), typeof( AngleBracketTemplateLexer ) );
     subGroup.SuperGroup = superGroup;
     StringTemplate a = subGroup.GetInstanceOf( "a" );
     a.SetAttribute( "x", "foo" );
     Assert.AreEqual( "super.a", a.ToString() );
     StringTemplate b = subGroup.GetInstanceOf( "b" );
     Assert.AreEqual( "sub.csuper.b", b.ToString() );
     StringTemplate c = subGroup.GetInstanceOf( "c" );
     Assert.AreEqual( "sub.c", c.ToString() );
 }
示例#24
0
 public void TestTemplateAlias()
 {
     string templates =
             "group test;" + newline +
             "page(name) ::= \"name is <name>\"" +
             "other ::= page" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate b = group.GetInstanceOf( "other" );  // alias for page
     b.SetAttribute( "name", "Ter" );
     string expecting = "name is Ter";
     string result = b.ToString();
     Assert.AreEqual( expecting, result );
 }
示例#25
0
 public void TestUndefinedArgumentAssignmentInApply()
 {
     string templates =
             "group test;" + newline +
             "page(name,x) ::= <<$name:bold(font=x)$>>" + newline +
             "bold() ::= \"<font face=$font$><b>$it$</b></font>\"" + newline;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     typeof( DefaultTemplateLexer ) );
     StringTemplate t = group.GetInstanceOf( "page" );
     t.SetAttribute( "x", "Times" );
     t.SetAttribute( "name", "Ter" );
     string error = "";
     try
     {
         t.ToString();
     }
     catch ( ArgumentException iae )
     {
         error = iae.Message;
     }
     string expecting = "template bold has no such attribute: font in template context [page <invoke bold arg context>]";
     Assert.AreEqual( expecting, error );
 }
示例#26
0
        public void TestSuperRegionRefError()
        {
            string templates1 =
                "group super;" + newline +
                "a() ::= \"X<@r()>Y\"" +
                "@a.r() ::= \"foo\"" + newline;
            StringTemplateGroup group =
                new StringTemplateGroup( new StringReader( templates1 ) );

            string templates2 =
                "group sub;" + newline +
                "@a.r() ::= \"A<@super.q()>B\"" + newline;
            IStringTemplateErrorListener errors = new ErrorBuffer();
            StringTemplateGroup subGroup =
                    new StringTemplateGroup( new StringReader( templates2 ),
                                            typeof( AngleBracketTemplateLexer ),
                                            errors,
                                            group );

            StringTemplate st = subGroup.GetInstanceOf( "a" );
            string result = errors.ToString();
            string expecting = "template a has no region called q";
            Assert.AreEqual( expecting, result );
        }
示例#27
0
        private void button1_Click(object sender, EventArgs e)
        {
            /*StringTemplate template = new StringTemplate(txtTemplate.Text);
            template.SetAttribute(txtName.Text, txtValue.Text);
            template.SetAttribute(txtName2.Text, txtValue2.Text);
            txtOutput.Text = template.ToString();
            */
            System.IO.TextReader tr = new System.IO.StreamReader("stellar_test_group.stg");
            StringTemplateGroup stg = new StringTemplateGroup(tr,typeof(TemplateLexer)); //lexer added to use $..$ in group templates instead of <..>
            StringTemplate st = stg.GetInstanceOf("E57_URI");
            StringTemplate st2 = stg.GetInstanceOf("E19_URI");
            StringTemplate st3 = stg.GetInstanceOf("E57");
            StringTemplate st4 = stg.GetInstanceOf("E19");

            st2.SetAttribute("site", "molas");
            st2.SetAttribute("id", "12345");

            st3.SetAttribute("site", "molas");
            st3.SetAttribute("id", "12345");

            st4.SetAttribute("uri", st2.ToString());

            String s = st3.ToString();
            txtOutput.Text = s;
        }
示例#28
0
 public void TestUndefinedDefaultAttributeReference()
 {
     string templates =
             "group test;" + newline +
             "page() ::= <<$bold()$>>" + newline +
             "bold() ::= \"$it$\"" + newline;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     typeof( DefaultTemplateLexer ) );
     StringTemplate t = group.GetInstanceOf( "page" );
     string error = "";
     try
     {
         t.ToString();
     }
     catch ( ArgumentException nse )
     {
         error = nse.Message;
     }
     string expecting = "no such attribute: it in template context [page bold]";
     Assert.AreEqual( expecting, error );
 }
        /// <summary>
        /// Given the output report path, generate HTML-formate report for the target project.
        /// </summary>
        /// <param name="path">Report location</param>
        public void Generate(string path)
        {
            List<string> methodFullNameAndParams = new List<string>();

            StringTemplateGroup group = new StringTemplateGroup("myGroup", Constants.TemplatesLoc);
            StringTemplate st = group.GetInstanceOf("Home");
            st.SetAttribute("ProjName", this.projName);
            st.SetAttribute("NUM_DB_METHODS", this.num_db_methods);
            st.SetAttribute("NUM_TOTAL_METHODS", this.num_total_methods);
            st.SetAttribute("NUM_SQL_OPERATING", this.num_sql_operating);
            st.SetAttribute("NUM_LOCAL", this.num_local);
            st.SetAttribute("NUM_DELEGATED", this.num_delegated);
            foreach (string methodTitle in allMethodTitles)
            {
                string[] tokens = methodTitle.Split(new string[] { "] " }, StringSplitOptions.None);
                string methodHeader = tokens[1];
                methodFullNameAndParams.Add(methodHeader);
                string methodDescription = allMethodFullDescriptions[methodTitle];

                st.SetAttribute("IDNum", globalMethodHeaderToIndex[methodHeader]);
                st.SetAttribute("MethodSignature", methodTitle);
                //st.SetAttribute("SourceCode", "...");
                //st.SetAttribute("SwumDesc", "xxx");
                st.SetAttribute("MethodBodyDesc", methodDescription);
                //allMethodSigniture.Add(methodTitle);
            }

            methodFullNameAndParams.Sort();
            //hyper index
            foreach (string mh in methodFullNameAndParams)
            {
                st.SetAttribute("MethodLinkID", mh);

            }

            //st.SetAttribute("Message", "hello ");
            String result = st.ToString(); // yields "int x = 0;"
            //Console.WriteLine(result);

            StreamWriter writetext = new StreamWriter(path);
            writetext.WriteLine(result);
            writetext.Close();
        }
示例#30
0
 public void TestUnknownRegionDefError()
 {
     // cannot define an implicitly-defined template more than once
     string templates =
             "group test;" + newline +
             "a() ::= \"X<@r()>Y\"" + newline +
             "@a.q() ::= \"foo\"" + newline;
     IStringTemplateErrorListener errors = new ErrorBuffer();
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     errors );
     StringTemplate st = group.GetInstanceOf( "a" );
     st.ToString();
     string result = errors.ToString();
     string expecting = "group test line 3: template a has no region called q";
     Assert.AreEqual( expecting, result );
 }