예제 #1
0
 /**
  * Checks if the provided URI is a valid Web Address (per RFC 3987bis).
  *
  * @param uri the URL to check
  */
 public static void maybeCheckValidUri(String uri) {
   if (GWT.isClient() || forceCheckValidUri) {
     Preconditions.checkArgument(isValidUri(uri), "String is not a valid URI: %s", uri);
   } else {
     assert isValidUri(uri) : "String is not a valid URI: " + uri;
   }
 }
  private Node transform(JsObjectLiteral x) {
    Node n = IR.objectlit();

    for (Object element : x.getPropertyInitializers()) {
      JsPropertyInitializer propInit = (JsPropertyInitializer) element;
      Node key;
      if (propInit.getLabelExpr().getKind() == NodeKind.NUMBER) {
        key = transformNumberAsString((JsNumberLiteral) propInit.getLabelExpr());
        key.putBooleanProp(Node.QUOTED_PROP, true);
      } else if (propInit.getLabelExpr().getKind() == NodeKind.NAME_REF) {
        key =
            transformNameAsString(
                ((JsNameRef) propInit.getLabelExpr()).getShortIdent(), propInit.getLabelExpr());
      } else {
        key = transform(propInit.getLabelExpr());
      }
      Preconditions.checkState(key.isString(), key);
      key.setType(Token.STRING_KEY);
      // Set as quoted as the rhino version we use does not distinguish one from the other.
      // Closure assumes unquoted property names are obfuscatable, but since there is no way to
      // distinguish between them at this point they have to be assumed quoted, hence not
      // obfuscatable.
      // TODO(rluble): Make sure this is handled correctly once rhino is upgraded.
      key.putBooleanProp(Node.QUOTED_PROP, true);
      n.addChildToBack(IR.propdef(key, transform(propInit.getValueExpr())));
    }
    return applySourceInfo(n, x);
  }
예제 #3
0
 /** Called to set this class's trivial initializer to point to a superclass. */
 void setClinitTarget(JDeclaredType newClinitTarget) {
   if (clinitTarget == newClinitTarget) {
     return;
   }
   if (newClinitTarget != null && getClass().desiredAssertionStatus()) {
     // Make sure this is a pure upgrade to a superclass or null.
     for (JClassType current = (JClassType) clinitTarget;
         current != newClinitTarget;
         current = current.getSuperClass()) {
       Preconditions.checkNotNull(
           current.getSuperClass(),
           "Null super class for: %s (currentTarget: %s; newTarget: %s) in %s",
           current,
           clinitTarget,
           newClinitTarget,
           this);
     }
   }
   clinitTarget = newClinitTarget;
 }
예제 #4
0
 LiteralWrapper(JValueLiteral literal) {
   Preconditions.checkNotNull(literal);
   this.literal = literal;
 }
 private Node transform(JsCatch x) {
   Node n = IR.catchNode(transformName(x.getParameter().getName()), transform(x.getBody()));
   Preconditions.checkState(x.getCondition() == null);
   return applySourceInfo(n, x);
 }