RazorParser { public void parse(@Nonnull final TextReader input, @Nonnull final ParserVisitor visitor) { final ParserResults results = parseCore(new SeekableTextReader(checkNotNull(input))); checkNotNull(visitor).visit(results); } RazorParser(@Nonnull final ParserBase codeParser, @Nonnull final ParserBase markupParser); ParserBase getCodeParser(); ParserBase getMarkupParser(); List<ISyntaxTreeRewriter> getOptimizers(); boolean isDesignTimeMode(); RazorParser setDesignTimeMode(final boolean designTimeMode); void parse(@Nonnull final TextReader input, @Nonnull final ParserVisitor visitor); ParserResults parse(@Nonnull final TextReader input); ParserResults parse(@Nonnull final ITextDocument input); Task createParseTask(@Nonnull final TextReader input, @Nonnull final Delegates.IAction1<Span> spanCallback,
                                @Nonnull final Delegates.IAction1<RazorError> errorCallback
                               ); Task createParseTask(@Nonnull final TextReader input, @Nonnull final Delegates.IAction1<Span> spanCallback,
                                @Nonnull final Delegates.IAction1<RazorError> errorCallback,
                                @Nonnull final SynchronizationContext context
                               ); Task createParseTask(@Nonnull final TextReader input, @Nonnull final Delegates.IAction1<Span> spanCallback,
                                @Nonnull final Delegates.IAction1<RazorError> errorCallback,
                                @Nullable final CancellationToken cancelToken
                               ); Task createParseTask(@Nonnull final TextReader input, @Nonnull final Delegates.IAction1<Span> spanCallback,
                                @Nonnull final Delegates.IAction1<RazorError> errorCallback,
                                @Nonnull final SynchronizationContext context,
                                @Nullable final CancellationToken cancelToken
                               ); Task createParseTask(@Nonnull final TextReader input, @Nonnull final ParserVisitor consumer);  }
@Test public void parseMethodCallsParseDocumentOnMarkupParserAndReturnsResults() { final SpanFactory factory = SpanFactory.createJavaHtml(); final RazorParser parser = new RazorParser(new JavaCodeParser(), new HtmlMarkupParser()); ParserTestBase.evaluateResults( parser.parse(new StringReaderDelegate("foo @bar baz")), new MarkupBlock( factory.markup("foo "), new ExpressionBlock( factory.codeTransition(), factory.code("bar") .asImplicitExpression(JavaCodeParser.DefaultKeywords) .accepts(AcceptedCharacters.NonWhiteSpace) ), factory.markup(" baz") ) ); }
@Test public void parseMethodUsesProvidedParserListenerIfSpecified() { final SpanFactory factory = SpanFactory.createJavaHtml(); final RazorParser parser = new RazorParser(new JavaCodeParser(), new HtmlMarkupParser()); final ParserResults results = parser.parse(new StringReaderDelegate("foo @bar baz")); ParserTestBase.evaluateResults( results, new MarkupBlock( factory.markup("foo "), new ExpressionBlock( factory.codeTransition(), factory.code("bar") .asImplicitExpression(JavaCodeParser.DefaultKeywords) .accepts(AcceptedCharacters.NonWhiteSpace) ), factory.markup(" baz") ) ); }
@Test public void parseMethodSetsUpRunWithSpecifiedCodeParserMarkupParserAndListenerPassesToMarkupParser() { runParseWithListenerTest( (parser, reader) -> { assert parser != null; assert reader != null; parser.parse(reader); } ); }