Package com.google.caja.parser.js

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


      Function<? super T, Expression> f) {
    FilePosition unk = FilePosition.UNKNOWN;
    ArrayConstructor arr = new ArrayConstructor(
        unk, Collections.<Expression>emptyList());
    for (T el : it) {
      arr.appendChild(el == null ? new NullLiteral(unk) : f.apply(el));
    }
    return arr;
  }
View Full Code Here


    // interprets to mean that the guest code did not supply a value.
    FilePosition pos = attr.valuePos;
    boolean unspecified = null !=
        attr.src.getUserData(TemplateCompiler.ATTRIBUTE_VALUE_WAS_UNSPECIFIED);
    Expression value = unspecified
        ? new NullLiteral(pos)
        : new StringLiteral(pos, attr.src.getValue());
    return (Expression) QuasiBuilder.substV(""
        + "IMPORTS___./*@synthetic*/rewriteTargetAttribute___("
        + "    @value, @tagName, @attribName)",
        "value", value,
View Full Code Here

    return r;
  }

  private Literal literal(String value, FilePosition pos) {
    if (empty(value)) {
      return new NullLiteral(pos);
    } else {
      return StringLiteral.valueOf(pos, value);
    }
  }
View Full Code Here

    // interprets to mean that the guest code did not supply a value.
    FilePosition pos = attr.valuePos;
    boolean unspecified = null !=
        attr.src.getUserData(TemplateCompiler.ATTRIBUTE_VALUE_WAS_UNSPECIFIED);
    Expression value = unspecified
        ? new NullLiteral(pos)
        : new StringLiteral(pos, attr.src.getValue());
    return (Expression) QuasiBuilder.substV(""
        + "IMPORTS___./*@synthetic*/rewriteTargetAttribute___("
        + "    @value, @tagName, @attribName)",
        "value", value,
View Full Code Here

      mq.addMessage(
          RewriterMessageType.ALPHA_RENAMING_FAILURE, e.getFilePosition(),
          MessagePart.Factory.valueOf(freeVarParts));
      mq.getMessages().addAll(sanityCheckMq.getMessages());
      // Substitute a safe value.  Errors have already been reported on mq.
      return new NullLiteral(e.getFilePosition());
    }
    return f;
  }
View Full Code Here

    return r;
  }

  private Literal literal(String value, FilePosition pos) {
    if (empty(value)) {
      return new NullLiteral(pos);
    } else {
      return StringLiteral.valueOf(pos, value);
    }
  }
View Full Code Here

          if (match(node) != null) {
            if (scope.isOuter()) {
              mq.addMessage(
                  RewriterMessageType.THIS_IN_GLOBAL_CONTEXT,
                  node.getFilePosition());
              return new NullLiteral(node.getFilePosition());
            }
          }
          return NONE;
        }
      },
      new Rule() {
        @Override
        @RuleDescription(
            name="argumentsReference",
            synopsis="Disallow arguments in the global scope.",
            reason="The declaration cannot be rewritten.",
            matches="arguments",
            substitutes="arguments")
            public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
          if (match(node) != null) {
            if (scope.isOuter()) {
              mq.addMessage(
                  RewriterMessageType.ARGUMENTS_IN_GLOBAL_CONTEXT,
                  node.getFilePosition());
              return new NullLiteral(node.getFilePosition());
            }
          }
          return NONE;
        }
      },
      new Rule() {
        @Override
        @RuleDescription(
            name="rename",
            synopsis="",
            reason="",
            matches="/* Reference */ @r",
            substitutes="@r")
        public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
          if (node instanceof Reference) {
            Reference r = (Reference) node;
            if (!isSynthetic(r)) {
              FilePosition pos = r.getFilePosition();
              String rname = r.getIdentifierName();
              NameContext<String, ?> context = contexts.get(scope);
              NameContext.VarInfo<String, ?> vi = context.lookup(rname);
              if (vi != null) {
                return new Reference(new Identifier(pos, vi.newName));
              } else {
                mq.addMessage(
                    RewriterMessageType.FREE_VARIABLE, pos,
                    MessagePart.Factory.valueOf(rname));
                return new NullLiteral(pos);
              }
            }
          }
          return NONE;
        }
View Full Code Here

TOP

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

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.