/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.errorprone.matchers;

import com.google.common.collect.Lists;
import com.google.errorprone.BugPattern;
import com.google.errorprone.VisitorState;
import com.sun.source.tree.Tree;

import java.util.Arrays;
import java.util.Collection;

/**
 * In addition to matching an AST node, also gives a message and/or suggested fix.
 * @author alexeagle@google.com (Alex Eagle)
 */
public abstract class DescribingMatcher<T extends Tree> implements Matcher<T> {

  protected final String name;
  /**
   * A collection of IDs for this check, to be checked for in @SuppressWarnings annotations.
   */
  protected final Collection<String> names;
  protected final String diagnosticMessage;
  
  public DescribingMatcher() {
    BugPattern annotation = this.getClass().getAnnotation(BugPattern.class);
    if (annotation == null) {
      throw new IllegalStateException("Class " + this.getClass().getCanonicalName()
          + " not annotated with @BugPattern");
    }
    name = annotation.name();
    names = Lists.newArrayListWithCapacity(annotation.altNames().length + 1);
    names.add(name);
    names.addAll(Arrays.asList(annotation.altNames()));
    diagnosticMessage = "[" + annotation.name() + "] " + annotation.summary()
        + "\n  (see http://code.google.com/p/error-prone/wiki/" + annotation.name() + ")";
  }
  
  public String getName() {
    return name;
  }
  
  public Collection<String> getNames() {
    return names;
  }

  /**
   * Additional description of a matched AST node, useful in reporting the error or performing an
   * automated refactoring.
   * @param t an AST node which matched this matcher
   * @param state the shared state
   * @return the description
   */
  public abstract Description describe(T t, VisitorState state);

}

@@ -655,48 +655,8 @@
 s;%0A%0A
-import com.google.common.collect.Lists;%0A
 impo
@@ -692,16 +692,16 @@
 attern;%0A
+
 import c
@@ -735,16 +735,17 @@
 rState;%0A
+%0A
 import c
@@ -766,24 +766,52 @@
 tree.Tree;%0A%0A
+import java.util.ArrayList;%0A
 import java.
@@ -1619,17 +1619,12 @@
 s = 
-Lists.
 new
+ 
 Arra
@@ -1632,20 +1632,16 @@
 List
-WithCapacity
+%3CString%3E
 (ann

Fix broken build