Package com.google.caja.lexer

Examples of com.google.caja.lexer.InputSource


    }
    return parsedCss;
  }

  private CssTree.StyleSheet parseImpl(String css) throws ParseException {
    InputSource inputSource = new InputSource(FAKE_SOURCE);
    CharProducer producer = CharProducer.Factory.create(new StringReader(css),
        inputSource);
    TokenStream<CssTokenType> lexer = new CssLexer(producer);
    TokenQueue<CssTokenType> queue = new TokenQueue<CssTokenType>(lexer, inputSource,
        new Criterion<Token<CssTokenType>>() {
View Full Code Here


  }

  List<Object> parseImpl(String content) throws GadgetException {
    List<Object> parsedCss = Lists.newArrayList();
    CharProducer producer = CharProducer.Factory.create(new StringReader(content),
        new InputSource(DUMMY_SOURCE));
    CssLexer lexer = new CssLexer(producer);
    try {
      StringBuilder builder = new StringBuilder();
      boolean inImport = false;
      while (lexer.hasNext()) {
View Full Code Here

  protected void registerUri(
      String uri, byte[] content, String contentType, String charset) {
    uriContent.put(
        URI.create(uri),
        FetchedData.fromBytes(
            content, contentType, charset, new InputSource(URI.create(uri))));
  }
View Full Code Here

  public final void testFileExtensionsBasedContentTypeGuessing()
      throws ParseException {
    // Override input sources, so that DomParser has a file extension available
    // when deciding whether to treat the input as HTML or XML.
    this.is = new InputSource(URI.create("http:///" + getName() + ".html"));
    assertParsedMarkup(
        Arrays.asList(
            "<xmp><br/></xmp>"
            ),
        Arrays.asList(
            "Fragment 1+1-1+17",
            "  Element : xmp 1+1-1+17",
            "    Text : <br/> 1+6-1+11"
            ),
        Arrays.<String>asList(),
        Arrays.asList(
            "<xmp><br/></xmp>"
            ),
        null, true);

    this.is = new InputSource(URI.create("http:///" + getName() + ".xml"));
    assertParsedMarkup(
        Arrays.asList(
            "<xmp><br/></xmp>"
            ),
        Arrays.asList(
            "Fragment 1+1-1+17",
            "  Element : xmp 1+1-1+17",
            "    Element : br 1+6-1+11"
            ),
        Arrays.<String>asList(),
        Arrays.asList(
            "<xmp><br /></xmp>"
            ),
        null, true);

    this.is = new InputSource(URI.create("http:///" + getName() + ".xhtml"));
    assertParsedMarkup(
        Arrays.asList(
            "<xmp><br/></xmp>"
            ),
        Arrays.asList(
View Full Code Here

        " VarZ:" + getClass().getName() + ".msPerRun=" + microsPerRun);
  }

  private int benchmark(int nRuns) throws IOException, ParseException {
    CharProducer testInput = fromResource("amazon.com.html");
    InputSource is = testInput.getSourceBreaks(0).source();
    MessageQueue mq = DevNullMessageQueue.singleton();
    long t0 = System.nanoTime();
    for (int i = nRuns; --i >= 0;) {
      HtmlLexer lexer = new HtmlLexer(testInput.clone());
      lexer.setTreatedAsXml(false);
View Full Code Here

        dumpedSeed = true;
        // Make sure it shows up in the junit test runner trace.
        System.err.println("junit.seed=" + SEED);
      }
    }
    this.is = new InputSource(URI.create("http://example.org/" + getName()));
    this.mc = new MessageContext();
    mc.addInputSource(is);
    this.mq = TestUtil.createTestMessageQueue(this.mc);
  }
View Full Code Here

  protected CharProducer fromResource(String resourcePath)
      throws IOException {
    URI resource = TestUtil.getResource(getClass(), resourcePath);
    if (resource == null) { throw new FileNotFoundException(resourcePath); }
    return fromResource(resourcePath, new InputSource(resource));
  }
View Full Code Here

    return (DocumentFragment) parseMarkup(cp, false, false);
  }

  private Node parseMarkup(CharProducer cp, boolean asXml, boolean asDoc)
      throws ParseException {
    InputSource is = sourceOf(cp);
    HtmlLexer lexer = new HtmlLexer(cp);
    lexer.setTreatedAsXml(asXml);
    TokenQueue<HtmlTokenType> tq = new TokenQueue<HtmlTokenType>(
        lexer, is, DomParser.SKIP_COMMENTS);
    DomParser p = new DomParser(tq, asXml, mq);
View Full Code Here

  }

  public final void testMultiplyProvidedSymbols() throws Exception {
    runLinterTest(
        jobs(new LintJobMaker(js(fromString(
            "var foo = 0, bar = 1;", new InputSource(URI.create("test:///f1"))
            )))
            .withProvides("foo", "bar")
            .make(),
            new LintJobMaker(js(fromString(
            "var bar = 2, baz = 4;", new InputSource(URI.create("test:///f2"))
            )))
            .withProvides("bar", "baz")
            .make()),
        "ERROR: f2: Another input, f1, already @provides bar");
  }
View Full Code Here

      }
    }
  }

  public final void testMessageSorting() {
    InputSource a = new InputSource(URI.create("test:///a"));
    InputSource b = new InputSource(URI.create("test:///b"));
    InputSource c = new InputSource(URI.create("test:///c"));
    FilePosition a1 = FilePosition.instance(a, 1, 10, 10);
    FilePosition a2 = FilePosition.instance(a, 2, 20, 10);
    FilePosition a12 = FilePosition.span(a1, a2);
    FilePosition b2 = FilePosition.instance(b, 2, 20, 10);
    FilePosition c1 = FilePosition.instance(c, 1, 10, 10);
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.InputSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.