コード例 #1
0
ファイル: CodeSplitters.java プロジェクト: qffan/gwt
  private static void logInitialLoadSequence(
      TreeLogger logger, LinkedHashSet<JRunAsync> initialLoadSequence) {
    if (!logger.isLoggable(TreeLogger.TRACE)) {
      return;
    }

    StringBuilder message = new StringBuilder();
    message.append("Initial load sequence of split points: ");
    if (initialLoadSequence.isEmpty()) {
      message.append("(none)");
    } else {
      Collection<Integer> runAsyncIds =
          Collections2.transform(
              initialLoadSequence,
              new Function<JRunAsync, Integer>() {
                @Override
                public Integer apply(JRunAsync runAsync) {
                  return runAsync.getRunAsyncId();
                }
              });
      message.append(Joiner.on(", ").join(runAsyncIds));
    }

    logger.log(TreeLogger.TRACE, message.toString());
  }
コード例 #2
0
ファイル: JProgram.java プロジェクト: imatellan/gwt
 public Collection<JType> getSubclasses(JType type) {
   return Collections2.transform(
       typeOracle.getSubTypeNames(type.getName()),
       new Function<String, JType>() {
         @Override
         public JType apply(String typeName) {
           return getFromTypeMap(typeName);
         }
       });
 }
コード例 #3
0
ファイル: CodeSplitters.java プロジェクト: qffan/gwt
 /**
  * Returns the collection of asyncs as a collection of singleton collections containing one async
  * each.
  */
 static Collection<Collection<JRunAsync>> getListOfLists(Collection<JRunAsync> runAsyncs) {
   return Collections2.transform(
       runAsyncs,
       new Function<JRunAsync, Collection<JRunAsync>>() {
         @Override
         public Collection<JRunAsync> apply(JRunAsync runAsync) {
           return Lists.newArrayList(runAsync);
         }
       });
 }
コード例 #4
0
ファイル: JProgram.java プロジェクト: imatellan/gwt
 public void setInitialAsyncSequence(LinkedHashSet<JRunAsync> initialAsyncSequence) {
   assert this.initialAsyncSequence.isEmpty();
   initialFragmentIdSequence = Lists.newArrayList();
   // TODO(rluble): hack for now the initial fragments correspond to the initial runAsyncIds.
   initialFragmentIdSequence.addAll(
       Collections2.transform(
           initialAsyncSequence,
           new Function<JRunAsync, Integer>() {
             @Override
             public Integer apply(JRunAsync runAsync) {
               return runAsync.getRunAsyncId();
             }
           }));
   this.initialAsyncSequence = initialAsyncSequence;
 }
コード例 #5
0
ファイル: JjsUtils.java プロジェクト: uddata/gwt
  /**
   * Creates a multi expression from a list of expressions, removing expressions that do not have
   * side effects if possible.
   */
  public static JExpression createOptimizedMultiExpression(
      boolean ignoringResult, List<JExpression> expressions) {

    int numberOfExpressions = expressions.size();
    JExpression result = expressions.get(numberOfExpressions - 1);

    numberOfExpressions = expressions.size();
    if (numberOfExpressions == 0) {
      return new JMultiExpression(SourceOrigin.UNKNOWN);
    }

    expressions =
        Lists.newArrayList(
            Collections2.filter(
                expressions.subList(0, numberOfExpressions - 1),
                Predicates.and(
                    Predicates.notNull(),
                    new Predicate<JExpression>() {
                      @Override
                      public boolean apply(JExpression expression) {
                        return expression.hasSideEffects();
                      }
                    })));

    if (result != null && (!ignoringResult || result.hasSideEffects())) {
      expressions.add(result);
    }

    if (expressions.size() == 1) {
      // Do not create a multi expression if it consists only of the result.
      return expressions.iterator().next();
    }

    SourceInfo info =
        expressions.size() > 0 ? expressions.get(0).getSourceInfo() : SourceOrigin.UNKNOWN;
    return new JMultiExpression(info, expressions);
  }