Package com.google.gxp.compiler.base

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


    public Void visitClauseElement(GxpNamespace.GxpElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();


      Expression predicate =
          attrMap.getOptionalExprValue("cond",
                                       new BooleanConstant(node, true));
      if (predicate != null) {
        output.accumulate(
            new Conditional.Clause(node, predicate,
View Full Code Here


    }

    private TemplateName.FullyQualified createRootName(Node node) {
      AttributeMap attrMap = nodeParts.getAttributes();

      Expression nameAttr = attrMap.getValue("name", null);
      if (nameAttr != null) {
        String s = nameAttr.getStaticString(alertSink, null);
        if (!className.equals(s)) {
          alertSink.add(new MismatchedTemplateNameError(
                            nameAttr.getSourcePosition(), s, className));
        }
      }

      return TemplateName.parseFullyQualifiedDottedName(
          alertSink, node.getSourcePosition(), className);
View Full Code Here

    public Void visitAbbrElement(GxpNamespace.GxpElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();
      Type type = createType(node, attrMap, false, null);
      String name = getVariableName(attrMap, "name", false);
      Expression expr = attrMap.getExprValue("expr", null);
      Expression content = getCollapsableContent(attrMap);
      if (type != null && name != null && expr != null) {
        output.accumulate(new AbbrExpression(node, type, name, expr, content));
      }
      return null;
    }
View Full Code Here

    public Void visitLoopElement(GxpNamespace.GxpElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();
      Type type = createType(node, attrMap, false, null);
      String key = getVariableName(attrMap, "key", true);
      String var = getVariableName(attrMap, "var", false);
      Expression content = getCollapsableContent(attrMap);

      Expression delimiter = attrMap.getOptionalAttributeValue(
          "delimiter", new StringConstant(node, null, " "));

      Expression iterator = attrMap.getOptionalExprValue("iterator", null);
      Expression iterable = attrMap.getOptionalExprValue("iterable", null);

      if (iterable == null && iterator == null) {
        alertSink.add(new MissingAttributesError(node, "iterator", "iterable"));
        return null;
      }
View Full Code Here

    public Void visitParamElement(GxpNamespace.GxpElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();
      String name = getVariableName(attrMap, "name", false);
      List<JavaAnnotation> javaAnnotations
          = getJavaAnnotations(node, JavaAnnotation.Element.PARAM);
      Expression defaultValue = null;
      boolean hasDefaultFlag = false;
      Pattern regex = null;
      Expression constructor = null;
      boolean hasConstructorFlag = false;

      String content = attrMap.getOptional("content", null);
      Type defaultType = null;
      boolean consumesContent = content != null;
      if (consumesContent) {
        if (!"*".equals(content)) {
          alertSink.add(new InvalidAttributeValueError(attrMap.getAttribute("content")));
        }
        if (rootSchema != null) {
          defaultType = new ContentType(node.getSourcePosition(),
                                        node.getDisplayName(),
                                        rootSchema);
        }
      }

      Type type = createType(node, attrMap, true, defaultType);
      if (type == null) {
        // Bail out without trying to construct Parameter.
        return null;
      }
      if (consumesContent && !type.isContent()) {
        alertSink.add(new ContentTypeExpectedAlert(node.getSourcePosition(),
                                                   node.getDisplayName(),
                                                   "when content='*' is set."));
        type = defaultType;
      }

      if (type.takesDefaultParam()) {
        defaultValue = attrMap.getOptionalExprValue("default", null);
        hasDefaultFlag = attrMap.getBooleanValue("has-default");
      }

      if (type.takesRegexParam()) {
        String regexStr = attrMap.getOptional("regex", null);
        if (regexStr != null) {
          try {
            regex = Pattern.compile(regexStr);
          } catch (PatternSyntaxException e) {
            alertSink.add(new BadRegexError(node, e.getPattern()));
          }
        }
      } else {
        regex = type.getPattern(name);
      }

      if (type.takesConstructorParam()) {
        constructor = attrMap.getOptionalExprValue("constructor", null);
        hasConstructorFlag = attrMap.getBooleanValue("has-constructor");
      }

      SpaceOperatorSet spaceOperators = getSpaceOperators(attrMap);

      // Note that we *don't* want to run the comment through space collapsing
      // as the space operators specified on a gxp:param actually apply to the
      // passed values.
      // TODO(laurence): should gxp:param even support nested content?
      Expression comment = nodeParts.getContent();
      if (!comment.hasStaticString()) {
        alertSink.add(new RequiresStaticContentError(node));
        comment = new StringConstant(node, null, "");
      }
      if (name != null) {
        FormalParameter formal = new FormalParameter(node, name, consumesContent, type,
View Full Code Here

      List<Import> imports = nodeParts.getImports();
      List<ImplementsDeclaration> implementsDeclarations = nodeParts.getImplementsDeclarations();
      List<ThrowsDeclaration> throwsDeclarations = nodeParts.getThrowsDeclarations();
      List<Parameter> parameters = nodeParts.getParameters();
      List<FormalTypeParameter> formalTypeParameters = nodeParts.getFormalTypeParameters();
      Expression content = getCollapsableContent(attrMap);

      if (contentType != null) {
        output.accumulate(new Template(node,
                                       name,
                                       contentType.getSchema(),
View Full Code Here

      MultiLanguageAttrValue name = attrMap.getMultiLanguageAttrValue("name");
      String meaning = attrMap.getOptional("meaning", null);
      String comment = attrMap.getOptional("comment", null);
      boolean hidden = attrMap.getBooleanValue("hidden");
      // TODO(laurence): coerce content to HTML
      Expression content = getCollapsableContent(attrMap);

      ContentType contentType = createContentType(node, null);
      Schema schema = (contentType == null) ? null : contentType.getSchema();

      output.accumulate(
View Full Code Here

    // CallNamespace elements
    public Void visitCallElement(CallNamespace.CallElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();
      ImmutableMap.Builder<String, Attribute> attrBuilder = ImmutableMap.builder();
      Expression content = new ConvertibleToContent(getCollapsableContent(attrMap));
      List<String> bundles = getBundles(attrMap);

      for (Attribute attr : attrMap.getUnusedAttributes()) {
        if (attr.getNamespace() instanceof NullNamespace) {
          Expression value = attr.getValue();
          if (value instanceof StringConstant) {
            attr = attr.withValue(new ObjectConstant((StringConstant) value));
          }
          attrBuilder.put(attr.getName(), attr);
        } else {
View Full Code Here

      // tags (but NOT the element content) with placeholders
      String phName = attrMap.getOptional(GxpNamespace.INSTANCE, "ph", null);

      // TODO(laurence): always collect content here, and check against
      // NOENDTAG in Validator phase.
      Expression content;
      if (validator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        // Ignore supplied children. EditableParts will generate alerts about
        // them if necessary.
        content = new StringConstant(node, null, "");
      } else {
View Full Code Here

          AttributeValidator attrValidator =
              elementValidator.getAttributeValidator(attr.getName());
          if (attrValidator == null) {
            alertSink.add(new UnknownAttributeError(forNode, attr));
          } else {
            Expression attrValue = attr.getValue();
            if (attrValue instanceof StringConstant) {
              String value = ((StringConstant) attrValue).evaluate();
              if (!attrValidator.isValidValue(value)) {
                alertSink.add(new InvalidAttributeValueError(attr));
              }
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.