Package com.google.gxp.compiler.base

Examples of com.google.gxp.compiler.base.Expression


                                           newBundle, null));
        }

        // Handle content parameter
        FormalParameter contentParam = callee.getContentConsumingParameter();
        Expression content = prepareExpressionAsParameterValue(contentParam,
                                                               apply(call.getContent()));
        boolean contentIgnorable = content.alwaysOnlyWhitespace();
        if (contentParam == null) {
          if (!contentIgnorable) {
            alertSink.add(new BadNodePlacementError(content, call));
          }
        } else {
View Full Code Here


      if (varNames.contains(abbr.getName())) {
        alertSink.add(new ConflictingVarNameError(abbr));
      }

      varNames.push(abbr.getName());
      Expression ret = super.visitAbbrExpression(abbr);
      varNames.pop();
      return ret;
    }
View Full Code Here

      // this is a set of all allowed attributes for the call attr bundles
      // it remains unchanged for the entire execution of this function
      Set<String> allowedAttributes = ImmutableSet.copyOf(validatorMap.keySet());

      for (final Map.Entry<String, Attribute> param : call.getAttributes().entrySet()) {
        Expression actualArgument = param.getValue().getValue();
        if (actualArgument instanceof AttrBundleParam) {
          AttrBundleParam bundle = (AttrBundleParam) actualArgument;
          for (Map.Entry<AttributeValidator, Attribute> attr : bundle.getAttrs().entrySet()) {
            validatorMap.remove(attr.getKey().getName());
            if (attr.getValue().getCondition() != null
View Full Code Here

      this.alertSink = Preconditions.checkNotNull(alertSink);
    }

    private Expression flattenDocType(OutputElement element, DocType docType) {
      Schema elementSchema = element.getSchema();
      Expression xmlDoctype =
          new StringConstant(element, elementSchema,
                             docType.toXml(element.getLocalName()));

      Expression sgmlDoctype;
      if (docType.isSgmlCompatible()) {
        sgmlDoctype =
            new StringConstant(element, elementSchema,
                               docType.toSgml(element.getLocalName()));
      } else {
View Full Code Here

        values.add(flattenXmlns(element));
      }

      for (final Attribute attr : element.getAttributes()) {
        AttributeValidator attrValidator = elementValidator.getAttributeValidator(attr.getName());
        Expression empty = new StringConstant(attr, elementSchema, "");
        if (attrValidator.isFlagSet(AttributeValidator.Flag.BOOLEAN)) {
          Expression attrValue = attr.getValue().acceptVisitor(this);
          if (attrValue.hasStaticString()) {
            values.add(buildBooleanAttrExpression(attr, element));
          } else {
            if (attrValue instanceof ConvertibleToContent) {
              ConvertibleToContent ctc = (ConvertibleToContent)attrValue;
              attrValue = ctc.getSubexpression();
            }
            values.add(new Conditional(element, elementSchema,
                                       attrValue,
                                       buildBooleanAttrExpression(attr, element),
                                       empty));
          }
        } else {
          Expression condition = attr.getCondition();
          if (condition != null) {
            values.add(new Conditional(element, elementSchema, condition,
                                       buildAttrExpression(attr, element), empty));
          } else {
            values.add(buildAttrExpression(attr, element));
View Full Code Here

    private Expression buildAttrExpression(Attribute attr,
                                           OutputElement element) {
      List<Expression> list = Lists.newArrayList();

      list.add(new StringConstant(attr, element.getSchema(), " " + attr.getName() + "=\""));
      Expression value = attr.getValue().acceptVisitor(this);
      if (!value.hasStaticString()) {
        value = new ExampleExpression(value, "");
      }
      list.add(value);
      list.add(new StringConstant(attr, element.getSchema(), "\""));
View Full Code Here

    StringConstant result = str(value);
    assertEquals(value, result.evaluate());
  }

  public void testEscape() throws Exception {
    Expression subexpression = expr("\"foo < bar\"");
    Schema schema = htmlSchema();

    EscapeExpression result =
        (EscapeExpression) escape(schema, subexpression);
View Full Code Here

    NativeExpression result = expr(nativeCode);
    assertEquals(nativeCode, result.getDefaultNativeCode());
  }

  public void testConcat() throws Exception {
    Expression value0 = expr("4 + 12");
    Expression value1 = str("slurm");
    Concatenation result = (Concatenation) concat(null, value0, value1);
    assertEquals(value0, result.getValues().get(0));
    assertEquals(value1, result.getValues().get(1));
  }
View Full Code Here

    Template newTemplate = (Template)newRoot;
    assertEquals(expected, newTemplate.getContent());
  }

  public void testBasic() throws Exception {
    Expression input = str(" hello world ");
    testCollapse(input, str("hello world"));
  }
View Full Code Here

    Expression input = str(" hello world ");
    testCollapse(input, str("hello world"));
  }

  public void testBasicWithNewlines() throws Exception {
    Expression input = str("\n hello world \n");
    testCollapse(input, str("hello world"));
  }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.base.Expression

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.