package annotator.find;

import com.sun.source.tree.*;
import com.sun.source.util.TreePath;

/**
 * Represents the criterion that a program element is not enclosed by any
 * method (i.e. it's a field, class type parameter, etc.).
 */
final class NotInMethodCriterion implements Criterion {

  /**
   * {@inheritDoc}
   */
  public Kind getKind() {
    return Kind.NOT_IN_METHOD;
  }

  /** {@inheritDoc} */
  @Override
  public boolean isSatisfiedBy(TreePath path, Tree leaf) {
    assert path == null || path.getLeaf() == leaf;
    return isSatisfiedBy(path);
  }

  /** {@inheritDoc} */
  @Override
  public boolean isSatisfiedBy(TreePath path) {
    do {
      Tree tree = path.getLeaf();
      if (tree.getKind() == Tree.Kind.METHOD)
        return false;
      if (tree.getKind() == Tree.Kind.CLASS || tree.getKind() == Tree.Kind.NEW_CLASS) {
        return true;
      }
      path = path.getParentPath();
    } while (path != null && path.getLeaf() != null);

    return true;
  }

  /**
   * {@inheritDoc}
   */
  public String toString() {
    return "not in method";
  }

}

@@ -307,32 +307,44 @@
 heritDoc%7D%0A   */%0A
+  @Override%0A
   public Kind ge
@@ -779,82 +779,35 @@
 if (
-tree.getKind() == Tree.Kind.CLASS %7C%7C tree.getKind() == Tree.Kind.NEW_CLASS
+Criteria.isClassEquiv(tree)
 ) %7B%0A
@@ -978,16 +978,28 @@
 %7D%0A   */%0A
+  @Override%0A
   public

Call helper method instead of hard-coding class-equivalent structures here.