Package com.google.gxp.compiler.base

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


    return new PackageImport(pos(), "<gxp:import>", packageName);
  }

  public Parameter param(String name, String typeStr,
                         Expression defaultValue) {
    Type type = nativeType(pos(), typeStr);
    FormalParameter formal = new FormalParameter(pos(), "<gxp:param>", name, false, type,
                                                 defaultValue, false, null, null, false,
                                                 SpaceOperatorSet.NULL);
    return new Parameter(formal, Collections.<JavaAnnotation>emptyList(),
                         defaultValue, false, null, false, str(""));
View Full Code Here


      return null;
    }

    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));
View Full Code Here

      return null;
    }

    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(
View Full Code Here

          alertSink.add(new ConflictingAttributesError(node, conflict, defaultTypeAttr));
        }
      }

      // build an appropriate type
      Type type = (gxpType != null) ? createGxpType(node, attrMap, gxpType)
          : (contentType != null) ? createContentType(node, null)
          : (defaultType == null || !nativeType.isEmpty()) ? new NativeType(node, nativeType)
          : defaultType;

      if (type != null && type.onlyAllowedInParam() && !forParam) {
        alertSink.add(new InvalidTypeError(type));
        type = null;
      }

      return type;
View Full Code Here

      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);
View Full Code Here

    @Override
    public Expression visitBoundCall(BoundCall call) {
      boolean oldVisible = visible;
      Callable callee = call.getCallee();
      for (Map.Entry<String, Attribute> param : call.getAttributes().entrySet()) {
        Type type = callee.getParameterByPrimary(param.getKey()).getType();
        visible = isTypeVisible(type);
        visitAttribute(param.getValue());
      }
      visible = oldVisible;
      return call;
View Full Code Here

      return null;
    }

    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));
View Full Code Here

      return null;
    }

    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(
View Full Code Here

          alertSink.add(new ConflictingAttributesError(node, conflict, defaultTypeAttr));
        }
      }

      // build an appropriate type
      Type type = (gxpType != null) ? createGxpType(node, attrMap, gxpType)
          : (contentType != null) ? createContentType(node, null)
          : (defaultType == null || !nativeType.isEmpty()) ? new NativeType(node, nativeType)
          : defaultType;

      if (type != null && type.onlyAllowedInParam() && !forParam) {
        alertSink.add(new InvalidTypeError(type));
        type = null;
      }

      return type;
View Full Code Here

      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);
View Full Code Here

TOP

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

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.