Package com.google.caja.parser.js

Examples of com.google.caja.parser.js.Identifier


         p = p.getParentContext()) {
      for (NameContext.VarInfo<String, ?> ni : p.vars()) {
        String rewrittenName = ni.newName;
        rewrittenNames.put(
            rewrittenName,
            new FormalParam(new Identifier(ni.declaredAt, rewrittenName)));
      }
    }
    for (String fixedExtern : fixedExterns) {
      rewrittenNames.put(
          fixedExtern,
          new FormalParam(new Identifier(FilePosition.UNKNOWN, fixedExtern)));
    }
    // If the input NameContext contains (foo => a, bar => b) then the program
    // looks like { (function (a, b) { @rewrittenExpression; }; }
    Block program = (Block) QuasiBuilder.substV(
        "{ (function (@formals*) { @f; }); }",
View Full Code Here


    if (existing != null
        && !(existing instanceof Identifier
             && ident.equals(existing.getValue()))) {
      return false;
    } else {
      Identifier identBinding = new Identifier(lit.getFilePosition(), ident);
      bindings.put(bindingName, identBinding);
      specimens.remove(0);
      return true;
    }
  }
View Full Code Here

  @Override
  protected boolean createSubstitutes(
      List<ParseTreeNode> substitutes, Map<String, ParseTreeNode> bindings) {
    ParseTreeNode binding = bindings.get(bindingName);
    Identifier ident;
    if (binding instanceof Identifier) {
      ident = (Identifier) binding;
    } else if (binding instanceof Reference) {
      ident = ((Reference) binding).getIdentifier();
    } else {
      return false;
    }
    if (ident.getName() == null) { return false; }
    StringLiteral sl = StringLiteral.valueOf(
        ident.getFilePosition(), ident.getName());
    substitutes.add(sl);
    return true;
  }
View Full Code Here

      List<ParseTreeNode> substitutes, Map<String, ParseTreeNode> bindings) {
    // Do we need to back out changes to bindings?
    if (qn.createSubstitutes(substitutes, bindings)) {
      return true;
    } else {
      substitutes.add(new Identifier(FilePosition.UNKNOWN, null));
      return true;
    }
  }
View Full Code Here

    if (dynamicValue instanceof FunctionConstructor) {
      emitStatement(
          quasiStmt(
              "el___.@name = @eventAdapter;",
              "name", new Reference(
                  SyntheticNodes.s(new Identifier(pos, name))),
              "eventAdapter", dynamicValue),
          source);
    } else {
      emitStatement(
          quasiStmt(
View Full Code Here

  private Block consolidate(List<SafeJsChunk> chunks) {
    Block consolidated = new Block();
    MutableParseTreeNode.Mutation mut = consolidated.createMutation();
    FilePosition unk = FilePosition.UNKNOWN;
    for (SafeJsChunk chunk : chunks) {
      Identifier ident = new Identifier(unk, "module");
      mut.appendChild(new FunctionDeclaration(new FunctionConstructor(
          unk, ident, Collections.<FormalParam>emptyList(),
          (Block) chunk.body)));
    }
    mut.execute();
View Full Code Here

        + ".v___(IMPORTS___.i_v___? IMPORTS___.i: ___.ri(IMPORTS___, 'i'));");
  }

  public final void testNoSpuriousRewriteErrorFound() {
    newPassThruSanitizer().sanitize(
        new Identifier(FilePosition.UNKNOWN, "x"));
    assertFalse(mq.hasMessageAtLevel(MessageLevel.FATAL_ERROR));
  }
View Full Code Here

    assertFalse(mq.hasMessageAtLevel(MessageLevel.FATAL_ERROR));
  }

  public final void testRewriteErrorIsDetected() {
    newPassThruSanitizer().sanitize(
        new Identifier(FilePosition.UNKNOWN, "x__"));
    assertTrue(mq.hasMessageAtLevel(MessageLevel.FATAL_ERROR));
  }
View Full Code Here

    assertTrue(mq.hasMessageAtLevel(MessageLevel.FATAL_ERROR));
  }

  public final void testNonAsciiIsDetected() {
    newPassThruSanitizer().sanitize(
        new Identifier(FilePosition.UNKNOWN, "\u00e6"));
    assertTrue(mq.hasMessageAtLevel(MessageLevel.FATAL_ERROR));
  }
View Full Code Here

  private static BreakStmt b(String label) {
    return new BreakStmt(FilePosition.UNKNOWN, label);
  }
  private static Declaration decl(String name) {
    return new Declaration(
        FilePosition.UNKNOWN, new Identifier(FilePosition.UNKNOWN, name), null);
  }
View Full Code Here

TOP

Related Classes of com.google.caja.parser.js.Identifier

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.