@@ -0,0 +1,3234 @@
+/*%0A * Copyright 2013 Google Inc. All rights reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.google.errorprone.refaster;%0A%0Aimport com.google.auto.value.AutoValue;%0Aimport com.google.common.collect.ImmutableList;%0A%0Aimport com.sun.source.tree.NewArrayTree;%0Aimport com.sun.source.tree.TreeVisitor;%0Aimport com.sun.tools.javac.tree.JCTree;%0Aimport com.sun.tools.javac.tree.JCTree.JCExpression;%0Aimport com.sun.tools.javac.tree.JCTree.JCNewArray;%0A%0Aimport java.util.List;%0A%0Aimport javax.annotation.Nullable;%0A%0A/**%0A * %7B@link UTree%7D version of %7B@link NewArrayTree%7D, which represents an array instantiation.%0A */%0A@AutoValue%0Apublic abstract class UNewArray extends UExpression implements NewArrayTree %7B%0A%0A  public static UNewArray create(UExpression type,%0A      List%3C? extends UExpression%3E dimensions,%0A      List%3C? extends UExpression%3E initializers) %7B%0A    return new AutoValue_UNewArray(%0A        type,%0A        dimensions != null ? ImmutableList.copyOf(dimensions) : null,%0A        initializers != null ? ImmutableList.copyOf(initializers) : null);%0A  %7D%0A%0A  @Nullable%0A  @Override%0A  public abstract UExpression getType();%0A%0A  @Nullable%0A  @Override%0A  public abstract List%3CUExpression%3E getDimensions();%0A%0A  @Nullable%0A  @Override%0A  public abstract List%3CUExpression%3E getInitializers();%0A%0A  @Override%0A  @Nullable%0A  public Unifier unify(JCTree target, @Nullable Unifier unifier) %7B%0A    if (unifier != null && target instanceof JCNewArray) %7B%0A      JCNewArray newArray = (JCNewArray) target;%0A      unifier = Unifier.unifyNullable(unifier, getType(), newArray.getType());%0A      unifier = Unifier.unifyList(unifier, getDimensions(), newArray.getDimensions());%0A%0A      boolean hasRepeated = false;%0A      List%3CUExpression%3E initializers = getInitializers();%0A      if (initializers != null) %7B%0A        for (UExpression initializer : initializers) %7B%0A          if (initializer instanceof URepeated) %7B%0A            hasRepeated = true;%0A            break;%0A          %7D%0A        %7D%0A      %7D%0A      return Unifier.unifyList(unifier, initializers, newArray.getInitializers(), hasRepeated);%0A    %7D%0A    return null;%0A  %7D%0A%0A  @Override%0A  public Kind getKind() %7B%0A    return Kind.NEW_ARRAY;%0A  %7D%0A%0A  @Override%0A  public %3CR, D%3E R accept(TreeVisitor%3CR, D%3E visitor, D data) %7B%0A    return visitor.visitNewArray(this, data);%0A  %7D%0A%0A  @Override%0A  public JCNewArray inline(Inliner inliner) throws CouldNotResolveImportException %7B%0A    return inliner.maker().NewArray(%0A        (getType() == null) ? null : getType().inline(inliner),%0A        (getDimensions() == null) ? null :%0A            inliner.%3CJCExpression, UExpression%3EinlineList(getDimensions()),%0A        (getInitializers() == null) ? null :%0A            inliner.%3CJCExpression, UExpression%3EinlineList(getInitializers()));%0A  %7D%0A%7D%0A

Move UNewArray to third_party Refaster. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72191295