code: public static boolean isMethodDeclaration(Node n) {
      if (n.isFunction()) {
        Node parent = n.getParent();
        switch (parent.getToken()) {
          case GETTER_DEF:
          case SETTER_DEF:
          case MEMBER_FUNCTION_DEF:
            // `({ get x() {} })`
            // `({ set x(v) {} })`
            // `({ f() {} })`
            return true;
          case COMPUTED_PROP:
            // `({ [expression]() {} })`
            // `({ get [expression]() {} })`
            // `({ set [expression](x) {} })`
            // (but not `({ [expression]: function() {} })`
            // The first child is the expression, and could possibly be a function.
            return parent.getLastChild() == n
                && (parent.getBooleanProp(Node.COMPUTED_PROP_METHOD)
                    || parent.getBooleanProp(Node.COMPUTED_PROP_GETTER)
                    || parent.getBooleanProp(Node.COMPUTED_PROP_SETTER));
          default:
            return false;
        }
      } else {
        return false;
      }
    }
docs: Is this node a class or object literal member function?
  
  <p>examples:
  
  <pre><code>
  class C {
  f() {}
  get x() { return this.x_; }
  set x(v) { this.x_ = v; }
  [someExpr]() {}
  }
  obj = {
  f() {}
  get x() { return this.x_; }
  set x(v) { this.x_ = v; }
  [someExpr]() {}
  }
  </code></pre>