Package com.google.caja.lexer

Examples of com.google.caja.lexer.InputSource


  protected boolean needsDebugData() {
    return false;
  }
 
  private DomParser getDomParser(String source, final MessageQueue mq) throws ParseException {
    InputSource is = getInputSource();
    HtmlLexer lexer = new HtmlLexer(CharProducer.Factory.fromString(source, is));
    final Namespaces ns = Namespaces.HTML_DEFAULT;  // Includes OpenSocial
    final boolean needsDebugData = needsDebugData();
    DomParser parser = new DomParser(lexer, /* wantsComments */ true, is, ns, mq);
    parser.setDomImpl(documentFactory);
View Full Code Here


    return parsedCss;
  }

  private CssTree.StyleSheet parseImpl(String css, Uri source)
      throws ParseException {
    InputSource inputSource = new InputSource(source.toJavaUri());
    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

    boolean passed = false;

    MessageQueue mq = new SimpleMessageQueue();
    MessageContext mc = new MessageContext();
    Uri contextUri = req.getUri();
    InputSource is = new InputSource(contextUri.toJavaUri());

    PluginMeta pluginMeta = new PluginMeta(
            proxyFetcher(req, contextUri), proxyUriPolicy(req));
    PluginCompiler compiler = new PluginCompiler(BuildInfo.getInstance(),
            pluginMeta, mq);
View Full Code Here

       
        try {
          HttpResponse response = requestPipeline.execute(request);
          byte[] responseBytes = IOUtils.toByteArray(response.getResponse());
          return FetchedData.fromBytes(responseBytes, mimeType, response.getEncoding(),
              new InputSource(ref.getUri()));
        } catch (GadgetException e) {
          LOG.info("Failed to retrieve: " + ref.toString());
          return null;
        } catch (IOException e) {
          LOG.info("Failed to read: " + ref.toString());
View Full Code Here

    ParseTreeNode outputJs;
    Node outputHtml;

    Map<InputSource, ? extends CharSequence> originalSources
        = Collections.singletonMap(new InputSource(guessURI(base, url)), input);

    PluginMeta meta = new PluginMeta(fetcher, null);
    if (opt_idClass != null && opt_idClass.length() != 0) {
      meta.setIdClass(opt_idClass);
    }
    PluginCompiler compiler = makePluginCompiler(meta, mq);
    compiler.setJobCache(new AppEngineJobCache());
    compiler.setMessageContext(mc);

    URI uri = guessURI(base, url);
    InputSource is = new InputSource(uri);
    CharProducer cp = CharProducer.Factory.fromString(input, is);
    boolean okToContinue = true;
    Dom inputNode = null;
    try {
      DomParser p = new DomParser(new HtmlLexer(cp), false, is, mq);
View Full Code Here

    List<Message> sorted = Lists.newArrayList(messages);
    Collections.sort(sorted, new Comparator<Message>() {
      public int compare(Message a, Message b) {
        MessagePart a0 = firstPartOf(a);
        MessagePart b0 = firstPartOf(b);
        InputSource aSrc = toInputSource(a0), bSrc = toInputSource(b0);
        // Compure by source first.
        if (aSrc != null && bSrc != null) {
          int delta = aSrc.getUri().compareTo(bSrc.getUri());
          if (delta != 0) { return delta; }
        }
        // Sort positionless parts after ones with a position.
        long aSPos = Integer.MAX_VALUE + 1L, aEPos = Integer.MAX_VALUE + 1L;
        long bSPos = Integer.MAX_VALUE + 1L, bEPos = Integer.MAX_VALUE + 1L;
View Full Code Here

      MessageContext mc, MessageQueue mq)
      throws IOException {
    List<LintJob> compUnits = Lists.newArrayList();
    // Parse each input, and find annotations.
    for (File inp : inputs) {
      InputSource src = new InputSource(inp.toURI());
      mc.addInputSource(src);

      CharProducer cp = CharProducer.Factory.create(
          new InputStreamReader(new FileInputStream(inp), "UTF-8"), src);
      contents.put(src, new FileContent(cp));
View Full Code Here

    }
    return compUnits;
  }

  public static LintJob makeLintJob(Block program, MessageQueue mq) {
    InputSource src = program.getFilePosition().source();
    List<Token<?>> tokens = program.getComments();
    return new LintJob(
        src,
        parseIdentifierListFromComment("requires", tokens, mq),
        parseIdentifierListFromComment("provides", tokens, mq),
View Full Code Here

    }
    // Check that two files do not provide the same thing.
    Map<String, InputSource> providedBy = Maps.newHashMap();
    for (LintJob job : jobs) {
      for (String symbolName : job.provides) {
        InputSource originallyDefinedIn = providedBy.put(symbolName, job.src);
        if (originallyDefinedIn != null) {
          mq.addMessage(
              LinterMessageType.MULTIPLY_PROVIDED_SYMBOL,
              job.src, originallyDefinedIn,
              MessagePart.Factory.valueOf(symbolName));
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.