Ejemplo n.º 1
0
        public void TestEmptyTemplate()
        {
            var diagnostics = GetDiagnostics("EmptyTemplate.lg");

            Assert.AreEqual(1, diagnostics.Count);
            Assert.AreEqual(DiagnosticSeverity.Warning, diagnostics[0].Severity);
            Assert.IsTrue(diagnostics[0].Message.Contains(TemplateErrors.NoTemplateBody("template")));
        }
            private LGTemplateParser.BodyContext CheckTemplateBody(string templateName, string templateBody, LGFileParser.TemplateBodyContext context, int startLine)
            {
                if (string.IsNullOrWhiteSpace(templateBody))
                {
                    var diagnostic = BuildTemplatesDiagnostic(TemplateErrors.NoTemplateBody(templateName), context, DiagnosticSeverity.Warning);
                    this.templates.Diagnostics.Add(diagnostic);
                }
                else
                {
                    try
                    {
                        return(AntlrParseTemplate(templateBody, startLine));
                    }
                    catch (TemplateException e)
                    {
                        e.Diagnostics.ToList().ForEach(u => this.templates.Diagnostics.Add(u));
                    }
                }

                return(null);
            }