예제 #1
0
        public ParserContext(ITextDocument source, ParserBase codeParser, ParserBase markupParser, ParserBase activeParser)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }
            if (activeParser == null)
            {
                throw new ArgumentNullException("activeParser");
            }
            if (activeParser != codeParser && activeParser != markupParser)
            {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source = new TextDocumentReader(source);
            CodeParser = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            Errors = new List<RazorError>();
        }
예제 #2
0
        public ParserContext(ITextDocument source, ParserBase codeParser, ParserBase markupParser, ParserBase activeParser)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }
            if (activeParser == null)
            {
                throw new ArgumentNullException("activeParser");
            }
            if (activeParser != codeParser && activeParser != markupParser)
            {
                throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
            }

            CaptureOwnerTask();

            Source       = new TextDocumentReader(source);
            CodeParser   = codeParser;
            MarkupParser = markupParser;
            ActiveParser = activeParser;
            Errors       = new List <RazorError>();
        }
예제 #3
0
        /// <summary>
        ///     Decorates the code parser.
        /// </summary>
        /// <param name="incomingCodeParser">The code parser.</param>
        /// <returns>The decorated parser.</returns>
        public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
        {
            if (incomingCodeParser is CSharpCodeParser)
                return new CSharp.CSharpCodeParser();

            if (incomingCodeParser is VBCodeParser)
                return new VisualBasic.VBCodeParser();

            return base.DecorateCodeParser(incomingCodeParser);
        }
예제 #4
0
        public RazorParser(ParserBase codeParser, ParserBase markupParser)
        {
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }

            MarkupParser = markupParser;
            CodeParser = codeParser;

            Optimizers = new List<ISyntaxTreeRewriter>()
            {
                // Move whitespace from start of expression block to markup
                new WhiteSpaceRewriter(MarkupParser.BuildSpan),
                // Collapse conditional attributes where the entire value is literal
                new ConditionalAttributeCollapser(MarkupParser.BuildSpan),
            };
        }
예제 #5
0
        public RazorParser(ParserBase codeParser, ParserBase markupParser)
        {
            if (codeParser == null)
            {
                throw new ArgumentNullException("codeParser");
            }
            if (markupParser == null)
            {
                throw new ArgumentNullException("markupParser");
            }

            MarkupParser = markupParser;
            CodeParser   = codeParser;

            Optimizers = new List <ISyntaxTreeRewriter>()
            {
                // Move whitespace from start of expression block to markup
                new WhiteSpaceRewriter(MarkupParser.BuildSpan),
                // Collapse conditional attributes where the entire value is literal
                new ConditionalAttributeCollapser(MarkupParser.BuildSpan),
            };
        }
예제 #6
0
 /// <summary>
 /// Gets an instance of the markup parser and is provided an opportunity to decorate or replace it
 /// </summary>
 /// <param name="incomingMarkupParser">The markup parser</param>
 /// <returns>Either the same markup parser, after modifications, or a different markup parser</returns>
 public virtual ParserBase DecorateMarkupParser(ParserBase incomingMarkupParser)
 {
     if (incomingMarkupParser == null)
     {
         throw new ArgumentNullException("incomingMarkupParser");
     }
     return incomingMarkupParser;
 }