Package com.google.gwt.core.ext

Examples of com.google.gwt.core.ext.TreeLogger$HelpInfo


  }

  @Override
  public String deploy(String suggestedFileName, String mimeType, byte[] data,
      boolean xhrCompatible) throws UnableToCompleteException {
    TreeLogger logger = getLogger();

    // data: URLs are not compatible with XHRs on FF and Safari browsers
    if ((!xhrCompatible) && (data.length < MAX_INLINE_SIZE)) {
      logger.log(TreeLogger.DEBUG, "Inlining", null);

      String base64Contents = toBase64(data);

      // CHECKSTYLE_OFF
      String encoded = "\"data:" + mimeType + ";base64," + base64Contents
View Full Code Here


    return toReturn;
  }

  public void finish() throws UnableToCompleteException {
    if (out != null) {
      TreeLogger logger = getLogger().branch(TreeLogger.DEBUG,
          "Writing container to disk");
      pw.close();

      assert partialPath != null : "partialPath";

      OutputStream realOut = getContext().tryCreateResource(logger, partialPath);
      try {
        realOut.write(out.toByteArray());
      } catch (IOException e) {
        logger.log(TreeLogger.ERROR, "Unable to write container file", e);
      }
      getContext().commitResource(logger, realOut);
    }
  }
View Full Code Here

      b.append('\"');
      numExpressions = concatOp(numExpressions, b);

      // Add the nodes at the substitution point
      for (CssNode x : entry.getValue()) {
        TreeLogger loopLogger = logger.branch(TreeLogger.DEBUG,
            "Performing substitution in node " + x.toString());

        if (x instanceof CssIf) {
          CssIf asIf = (CssIf) x;

          // Generate the sub-expressions
          String expression = makeExpression(loopLogger, context,
              cssResourceType, new CollapsedNode(asIf), prettyOutput);

          String elseExpression;
          if (asIf.getElseNodes().isEmpty()) {
            // We'll treat an empty else block as an empty string
            elseExpression = "\"\"";
          } else {
            elseExpression = makeExpression(loopLogger, context,
                cssResourceType, new CollapsedNode(asIf.getElseNodes()),
                prettyOutput);
          }

          // ((expr) ? "CSS" : "elseCSS") +
          b.append("((" + asIf.getExpression() + ") ? " + expression + " : "
              + elseExpression + ") ");
          numExpressions = concatOp(numExpressions, b);

        } else if (x instanceof CssProperty) {
          CssProperty property = (CssProperty) x;

          validateValue(loopLogger, context.getClientBundleType(),
              property.getValues());

          // (expr) +
          b.append("(" + property.getValues().getExpression() + ") ");
          numExpressions = concatOp(numExpressions, b);

        } else {
          // This indicates that some magic node is slipping by our visitors
          loopLogger.log(TreeLogger.ERROR, "Unhandled substitution "
              + x.getClass());
          throw new UnableToCompleteException();
        }
      }
      start = entry.getKey();
View Full Code Here

  static final String BUNDLE_MIME_TYPE = "image/png";
  private static final int IMAGE_MAX_SIZE = Integer.getInteger(
      "gwt.imageResource.maxBundleSize", 256);

  public static void main(String[] args) {
    final TreeLogger logger = new PrintWriterTreeLogger(new PrintWriter(
        System.out));
    if (args.length < 2) {
      logger.log(TreeLogger.ERROR, ImageBundleBuilder.class.getSimpleName()
          + " <output file> <input file> ...");
      System.exit(-1);
    }

    ImageBundleBuilder builder = new ImageBundleBuilder();
    boolean fail = false;
    for (int i = 1, j = args.length; i < j; i++) {
      TreeLogger loopLogger = logger.branch(TreeLogger.DEBUG,
          "Processing argument " + args[i]);
      File file = new File(args[i]);

      Exception ex = null;
      try {
        builder.assimilate(loopLogger, args[i], file.toURL());
      } catch (MalformedURLException e) {
        ex = e;
      } catch (UnableToCompleteException e) {
        ex = e;
      } catch (UnsuitableForStripException e) {
        ex = e;
      }
      if (ex != null) {
        loopLogger.log(TreeLogger.ERROR, "Unable to assimilate image", ex);
        fail = true;
      }
    }

    if (fail) {
View Full Code Here

    JMethod[] methods = remoteService.getOverridableMethods();

    JClassType exceptionClass = typeOracle.getType(Exception.class.getName());

    TreeLogger validationLogger = logger.branch(TreeLogger.DEBUG,
        "Analyzing methods:", null);
    for (JMethod method : methods) {
      TreeLogger methodLogger = validationLogger.branch(TreeLogger.DEBUG,
          method.toString(), null);
      JType returnType = method.getReturnType();
      if (returnType != JPrimitiveType.VOID) {
        TreeLogger returnTypeLogger = methodLogger.branch(TreeLogger.DEBUG,
            "Return type: " + returnType.getParameterizedQualifiedSourceName(),
            null);
        typesSentToBrowser.addRootType(returnTypeLogger, returnType);
      }

      JParameter[] params = method.getParameters();
      for (JParameter param : params) {
        TreeLogger paramLogger = methodLogger.branch(TreeLogger.DEBUG,
            "Parameter: " + param.toString(), null);
        JType paramType = param.getType();
        typesSentFromBrowser.addRootType(paramLogger, paramType);
      }

      JType[] exs = method.getThrows();
      if (exs.length > 0) {
        TreeLogger throwsLogger = methodLogger.branch(TreeLogger.DEBUG,
            "Throws:", null);
        for (JType ex : exs) {
          if (!exceptionClass.isAssignableFrom(ex.isClass())) {
            throwsLogger = throwsLogger.branch(
                TreeLogger.WARN,
                "'"
                    + ex.getQualifiedSourceName()
                    + "' is not a checked exception; only checked exceptions may be used",
                null);
View Full Code Here

    MethodCollector invokables = new MethodCollector(context, logger, toGenerate);

    SourceWriter sw = factory.createSourceWriter(context, pw);

    for (JMethod method : toGenerate.getMethods()) {
      TreeLogger l = logger.branch(Type.DEBUG, "Creating XTemplate method " + method.getName());
      final String template;
      XTemplate marker = method.getAnnotation(XTemplate.class);
      if (marker == null) {
        l.log(Type.ERROR, "Unable to create template for method " + method.getReadableDeclaration()
            + ", this may cause other failures.");
        continue;
      } else {
        if (marker.source().length() != 0) {
          if (marker.value().length() != 0) {
            l.log(Type.WARN, "Found both source file and inline template, using source file");
          }

          InputStream stream = getTemplateResource(context, toGenerate, l, marker.source());
          if (stream == null) {
            l.log(Type.ERROR, "No data could be loaded - no data at path " + marker.source());
            throw new UnableToCompleteException();
          }
          template = Util.readStreamAsString(stream);
        } else if (marker.value().length() != 0) {
          template = marker.value();
        } else {
          l.log(Type.ERROR,
              "XTemplate annotation found with no contents, cannot generate method " + method.getName()
                  + ", this may cause other failures.");
          continue;
        }
      }

      XTemplateParser p = new XTemplateParser(l.branch(Type.DEBUG,
          "Parsing provided template for " + method.getReadableDeclaration()));
      TemplateModel m = p.parse(template);
      SafeHtmlTemplatesCreator safeHtml = new SafeHtmlTemplatesCreator(context, l.branch(Type.DEBUG,
          "Building SafeHtmlTemplates"), method);

      sw.println(method.getReadableDeclaration(false, true, true, false, true) + "{");
      sw.indent();
View Full Code Here

  public ConditionParser(TreeLogger log) {
    this.log = log;
  }

  public List<Token> parse(String condition) {
    TreeLogger l = log.branch(Type.DEBUG, "Parsing condition: " + condition);
    // expect lots of whitespace for now... if it doesn't match an expression or
    // literal, it must be a ref
    List<Token> tokens = new ArrayList<Token>();

    Matcher m = NON_REF.matcher(condition);
    int lastMatchEnd = 0;
    while (m.find()) {
      int begin = m.start(), end = m.end();
      @SuppressWarnings("unused")
      String currentMatch = condition.substring(begin, end);

      // look for unmatched sections, indicating refs
      if (lastMatchEnd < begin) {
        Token ref = new Token();
        ref.type = Token.Type.Reference;
        ref.contents = condition.substring(lastMatchEnd, begin);
        tokens.add(ref);
      }
      lastMatchEnd = end;

      // deal with methods differently than bin/unary ops
      Token t = new Token();

      Matcher method = METHOD_PATTERN.matcher(m.group());
      if (method.matches()) {
        t.type = Token.Type.MethodInvocation;
        t.contents = method.group(1);
      } else {
        // TODO consider leaving out whitespace...
        t.type = Token.Type.ExpressionLiteral;
        t.contents = m.group();

        // look for accidental char/string mismatch
        Matcher str = POSSIBLE_STRING_LITERAL.matcher(t.contents);
        if (str.matches()) {
          if (str.group(1).length() > 1) {
            t.contents = "\"" + str.group(1) + "\"";
          } else {
            // TODO mechanism to disable this warn
            l.log(
                Type.WARN,
                "Possible char was turned into a string, please be aware that both ' and \" marks are used for String objects in XTemplates");
          }
        }
      }
View Full Code Here

    SourceWriter sw = factory.createSourceWriter(context, pw);


    // for each method,
    for (JMethod m : toGenerate.getOverridableMethods()) {
      TreeLogger l = logger.branch(Type.DEBUG, "Building method: " + m.getReadableDeclaration());

      // no support for params at this time
      if (m.getParameters().length != 0) {
        l.log(Type.ERROR, "Method " + m.toString() + " must not have parameters.");
        throw new UnableToCompleteException();
      }

      // ask for the types that provide the property data
      JClassType ret = m.getReturnType().isClassOrInterface();
View Full Code Here

    return findCustomFieldSerializer(type.getOracle(), type) != null;
  }

  private static void logSerializableTypes(TreeLogger logger,
      Set<JClassType> fieldSerializableTypes) {
    TreeLogger localLogger = logger.branch(TreeLogger.DEBUG, "Identified "
        + fieldSerializableTypes.size() + " serializable type"
        + ((fieldSerializableTypes.size() == 1) ? "" : "s"), null);

    for (JClassType fieldSerializableType : fieldSerializableTypes) {
      localLogger.branch(TreeLogger.DEBUG,
          fieldSerializableType.getParameterizedQualifiedSourceName(), null);
    }
  }
View Full Code Here

    if (tic != null && tic.isDone()) {
      // we have an answer already; use it.
      return tic;
    }

    TreeLogger localLogger = logger.branch(TreeLogger.DEBUG,
        classType.getParameterizedQualifiedSourceName(), null);

    JTypeParameter isTypeParameter = classType.isTypeParameter();
    if (isTypeParameter != null) {
      if (typeParametersInRootTypes.contains(isTypeParameter)) {
        return computeTypeInstantiability(localLogger,
            isTypeParameter.getFirstBound(),
            TypePaths.createTypeParameterInRootPath(path, isTypeParameter),
            problems);
      }

      /*
       * This type parameter was not in a root type and therefore it is the
       * caller's responsibility to deal with it. We assume that it is
       * indirectly instantiable here.
       */
      tic = getTypeInfoComputed(classType, path, true);
      tic.setInstantiableSubtypes(true);
      tic.setInstantiable(false);
      return tic;
    }

    JWildcardType isWildcard = classType.isWildcard();
    if (isWildcard != null) {
      boolean success = true;
      for (JClassType bound : isWildcard.getUpperBounds()) {
        success &= computeTypeInstantiability(localLogger, bound, path, problems).hasInstantiableSubtypes();
      }
      tic = getTypeInfoComputed(classType, path, true);
      tic.setInstantiableSubtypes(success);
      tic.setInstantiable(false);
      return tic;
    }

    JArrayType isArray = classType.isArray();
    if (isArray != null) {
      TypeInfoComputed arrayTic = checkArrayInstantiable(localLogger, isArray, path,
          problems);
      assert getTypeInfoComputed(classType, path, false) != null;
      return arrayTic;
    }

    if (classType == typeOracle.getJavaLangObject()) {
      /*
       * Report an error if the type is or erases to Object since this violates
       * our restrictions on RPC.  Should be fatal, but I worry users may have
       * Object-using code they can't readily get out of the class hierarchy.
       */
      problems.add(classType,
          "In order to produce smaller client-side code, 'Object' is not " +
          "allowed; please use a more specific type", Priority.DEFAULT);
      tic = getTypeInfoComputed(classType, path, true);
      tic.setInstantiable(false);
      return tic;
    }

    if (classType.isRawType() != null) {
      localLogger.log(
          TreeLogger.DEBUG,
          "Type '"
              + classType.getQualifiedSourceName()
              + "' should be parameterized to help the compiler produce the smallest code size possible for your module",
          null);
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.TreeLogger$HelpInfo

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.