Package com.google.gxp.compiler.alerts.common

Examples of com.google.gxp.compiler.alerts.common.RequiredAttributeHasCondError


                        "  <gxp:attr name='alt' cond='sometimes'>",
                        "    text",
                        "  </gxp:attr>",
                        "</call:callee>");
    compileFiles(callee, caller);
    assertAlert(new RequiredAttributeHasCondError(pos(2, 1), "<call:callee>", "alt"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here


      Set<String> allowedAttributes = ImmutableSet.copyOf(validatorMap.keySet());

      for (final Attribute attr : element.getAttributes()) {
        AttributeValidator validator = validatorMap.remove(attr.getName());
        if (attr.getCondition() != null && validator.isFlagSet(AttributeValidator.Flag.REQUIRED)) {
          alertSink.add(new RequiredAttributeHasCondError(element, attr));
        }
      }

      if (template == null) {
        throw new AssertionError("found output element without a template");
View Full Code Here

          AttrBundleParam bundle = (AttrBundleParam) actualArgument;
          for (Map.Entry<AttributeValidator, Attribute> attr : bundle.getAttrs().entrySet()) {
            validatorMap.remove(attr.getKey().getName());
            if (attr.getValue().getCondition() != null
                && attr.getKey().isFlagSet(AttributeValidator.Flag.REQUIRED)) {
              alertSink.add(new RequiredAttributeHasCondError(call, attr.getValue()));
            }
          }
        }
        newAttrBuilder.put(param.getKey(), visitAttribute(param.getValue()));
      }

      validateAttributeBundles(call, call.getAttrBundles(), validatorMap, allowedAttributes);
      Map<String, Attribute> newAttrParams = newAttrBuilder.build();

      // check for missing required attributes
      for (FormalParameter parameter : callee.getParameters()) {
        if (!parameter.hasDefault()) {
          if (!newAttrParams.containsKey(parameter.getPrimaryName())) {
            alertSink.add(new MissingAttributeError(call, parameter.getPrimaryName()));
          } else {
            Attribute fpAttribute = call.getAttributes().get(parameter.getPrimaryName());
            if (fpAttribute != null && fpAttribute.getCondition() != null) {
              alertSink.add(new RequiredAttributeHasCondError(call, fpAttribute));
            }
          }
        }
      }
View Full Code Here

    String callee = "<gxp:param type='int' name='i'/>";
    String caller = "<my:" + getTemplateBaseName() + ">" +
        "<gxp:attr name='i' cond='1 > 0'><gxp:eval expr='42' /></gxp:attr>" +
        "</my:" + getTemplateBaseName() + ">";
    compile(callee, caller);
    assertAlert(new RequiredAttributeHasCondError(pos(3, 1),
                                                  "<my:" + getTemplateBaseName() + ">", "i"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here

    compile("<img src='foo.jpg'>",
            "  <gxp:attr name='alt' cond='false'>",
            "    foo",
            "  </gxp:attr>",
            "</img>");
    assertAlert(new RequiredAttributeHasCondError(pos(2,1), "<img>", "alt"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here

  public void testLoop_conditionalDelimiter() throws Exception {
    compile("<gxp:loop var='x' type='int' iterable='list'>",
            "  <gxp:attr name='delimiter' cond='false'>",
            "  </gxp:attr>",
            "</gxp:loop>");
    assertAlert(new RequiredAttributeHasCondError(pos(2,1), "<gxp:loop>", "delimiter"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here

  public Expression getOptionalAttributeValue(String name, Expression fallback) {
    Expression result = null;
    Attribute nullAttr = getAttribute(name);
    if (nullAttr != null) {
      if (nullAttr.getCondition() != null) {
        alertSink.add(new RequiredAttributeHasCondError(forNode, nullAttr));
      }
      result = nullAttr.getValue();
    }

    // if we don't have anything yet, or if we got a NativeExpression
View Full Code Here

  public Expression getOptionalAttributeValue(String name, Expression fallback) {
    Expression result = null;
    Attribute nullAttr = getAttribute(name);
    if (nullAttr != null) {
      if (nullAttr.getCondition() != null) {
        alertSink.add(new RequiredAttributeHasCondError(forNode, nullAttr));
      }
      result = nullAttr.getValue();
    }

    // if we don't have anything yet, or if we got a NativeExpression
View Full Code Here

    String callee = "<gxp:param type='int' name='i'/>";
    String caller = "<my:" + getTemplateBaseName() + ">" +
        "<gxp:attr name='i' cond='1 > 0'><gxp:eval expr='42' /></gxp:attr>" +
        "</my:" + getTemplateBaseName() + ">";
    compile(callee, caller);
    assertAlert(new RequiredAttributeHasCondError(pos(3, 1),
                                                  "<my:" + getTemplateBaseName() + ">", "i"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.alerts.common.RequiredAttributeHasCondError

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.