Java Code Examples for com.google.javascript.rhino.JSDocInfo#hasThisType()

The following examples show how to use com.google.javascript.rhino.JSDocInfo#hasThisType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollapseProperties.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Warns about any references to "this" in the given FUNCTION. The function
 * is getting collapsed, so the references will change.
 */
private void checkForHosedThisReferences(Node function, JSDocInfo docInfo,
    final Name name) {
  // A function is getting collapsed. Make sure that if it refers to
  // "this", it must be a constructor or documented with @this.
  if (docInfo == null ||
      (!docInfo.isConstructor() && !docInfo.hasThisType())) {
    NodeTraversal.traverse(compiler, function.getLastChild(),
        new NodeTraversal.AbstractShallowCallback() {
          @Override
          public void visit(NodeTraversal t, Node n, Node parent) {
            if (n.isThis()) {
              compiler.report(
                  JSError.make(name.getDeclaration().getSourceName(), n,
                      UNSAFE_THIS, name.getFullName()));
            }
          }
        });
  }
}
 
Example 2
Source File: Closure_89_CollapseProperties_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Warns about any references to "this" in the given FUNCTION. The function
 * is getting collapsed, so the references will change.
 */
private void checkForHosedThisReferences(Node function, JSDocInfo docInfo,
    final Name name) {
  // A function is getting collapsed. Make sure that if it refers to
  // "this", it must be a constructor or documented with @this.
  if (docInfo == null ||
      (!docInfo.isConstructor() && !docInfo.hasThisType())) {
    NodeTraversal.traverse(compiler, function.getLastChild(),
        new NodeTraversal.AbstractShallowCallback() {
          public void visit(NodeTraversal t, Node n, Node parent) {
            if (n.getType() == Token.THIS) {
              compiler.report(
                  JSError.make(name.declaration.sourceName, n,
                      UNSAFE_THIS, name.fullName()));
            }
          }
        });
  }
}
 
Example 3
Source File: Closure_89_CollapseProperties_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Warns about any references to "this" in the given FUNCTION. The function
 * is getting collapsed, so the references will change.
 */
private void checkForHosedThisReferences(Node function, JSDocInfo docInfo,
    final Name name) {
  // A function is getting collapsed. Make sure that if it refers to
  // "this", it must be a constructor or documented with @this.
  if (docInfo == null ||
      (!docInfo.isConstructor() && !docInfo.hasThisType())) {
    NodeTraversal.traverse(compiler, function.getLastChild(),
        new NodeTraversal.AbstractShallowCallback() {
          public void visit(NodeTraversal t, Node n, Node parent) {
            if (n.getType() == Token.THIS) {
              compiler.report(
                  JSError.make(name.declaration.sourceName, n,
                      UNSAFE_THIS, name.fullName()));
            }
          }
        });
  }
}
 
Example 4
Source File: Closure_130_CollapseProperties_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Warns about any references to "this" in the given FUNCTION. The function
 * is getting collapsed, so the references will change.
 */
private void checkForHosedThisReferences(Node function, JSDocInfo docInfo,
    final Name name) {
  // A function is getting collapsed. Make sure that if it refers to
  // "this", it must be a constructor or documented with @this.
  if (docInfo == null ||
      (!docInfo.isConstructor() && !docInfo.hasThisType())) {
    NodeTraversal.traverse(compiler, function.getLastChild(),
        new NodeTraversal.AbstractShallowCallback() {
          @Override
          public void visit(NodeTraversal t, Node n, Node parent) {
            if (n.isThis()) {
              compiler.report(
                  JSError.make(name.getDeclaration().getSourceName(), n,
                      UNSAFE_THIS, name.getFullName()));
            }
          }
        });
  }
}
 
Example 5
Source File: Closure_130_CollapseProperties_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Warns about any references to "this" in the given FUNCTION. The function
 * is getting collapsed, so the references will change.
 */
private void checkForHosedThisReferences(Node function, JSDocInfo docInfo,
    final Name name) {
  // A function is getting collapsed. Make sure that if it refers to
  // "this", it must be a constructor or documented with @this.
  if (docInfo == null ||
      (!docInfo.isConstructor() && !docInfo.hasThisType())) {
    NodeTraversal.traverse(compiler, function.getLastChild(),
        new NodeTraversal.AbstractShallowCallback() {
          @Override
          public void visit(NodeTraversal t, Node n, Node parent) {
            if (n.isThis()) {
              compiler.report(
                  JSError.make(name.getDeclaration().getSourceName(), n,
                      UNSAFE_THIS, name.getFullName()));
            }
          }
        });
  }
}
 
Example 6
Source File: Closure_41_FunctionTypeBuilder_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Infers the type of {@code this}.
 * @param info The JSDocInfo for this function.
 */
FunctionTypeBuilder inferThisType(JSDocInfo info) {
  ObjectType maybeThisType = null;
  if (info != null && info.hasThisType()) {
    maybeThisType = ObjectType.cast(
        info.getThisType().evaluate(scope, typeRegistry));
  }
  if (maybeThisType != null) {
    thisType = maybeThisType;
    thisType.setValidator(new ThisTypeValidator());
  }

  return this;
}
 
Example 7
Source File: Closure_41_FunctionTypeBuilder_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Determines whether the given jsdoc info declares a function type.
 */
static boolean isFunctionTypeDeclaration(JSDocInfo info) {
  return info.getParameterCount() > 0 ||
      info.hasReturnType() ||
      info.hasThisType() ||
      info.isConstructor() ||
      info.isInterface();
}
 
Example 8
Source File: Closure_90_FunctionTypeBuilder_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Infers the type of {@code this}.
 * @param info The JSDocInfo for this function.
 * @param owner The node for the object whose prototype "owns" this function.
 *     For example, {@code A} in the expression {@code A.prototype.foo}. May
 *     be null to indicate that this is not a prototype property.
 */
FunctionTypeBuilder inferThisType(JSDocInfo info,
    @Nullable Node owner) {
  ObjectType maybeThisType = null;
  if (info != null && info.hasThisType()) {
    maybeThisType = ObjectType.cast(
        info.getThisType().evaluate(scope, typeRegistry));
  }
  if (maybeThisType != null) {
    thisType = maybeThisType;
    thisType.setValidator(new ThisTypeValidator());
  } else if (owner != null &&
             (info == null || !info.hasType())) {
    // If the function is of the form:
    // x.prototype.y = function() {}
    // then we can assume "x" is the @this type. On the other hand,
    // if it's of the form:
    // /** @type {Function} */ x.prototype.y;
    // then we should not give it a @this type.
    String ownerTypeName = owner.getQualifiedName();
    ObjectType ownerType = ObjectType.cast(
        typeRegistry.getForgivingType(
            scope, ownerTypeName, sourceName,
            owner.getLineno(), owner.getCharno()));
    if (ownerType != null) {
      thisType = ownerType;
    }
  }

  return this;
}
 
Example 9
Source File: Closure_41_FunctionTypeBuilder_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Determines whether the given jsdoc info declares a function type.
 */
static boolean isFunctionTypeDeclaration(JSDocInfo info) {
  return info.getParameterCount() > 0 ||
      info.hasReturnType() ||
      info.hasThisType() ||
      info.isConstructor() ||
      info.isInterface();
}
 
Example 10
Source File: FunctionTypeBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether the given JsDoc info declares a function type.
 */
static boolean isFunctionTypeDeclaration(JSDocInfo info) {
  return info.getParameterCount() > 0 ||
      info.hasReturnType() ||
      info.hasThisType() ||
      info.isConstructor() ||
      info.isInterface();
}
 
Example 11
Source File: Closure_90_FunctionTypeBuilder_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Determines whether the given jsdoc info declares a function type.
 */
static boolean isFunctionTypeDeclaration(JSDocInfo info) {
  return info.getParameterCount() > 0 ||
      info.hasReturnType() ||
      info.hasThisType() ||
      info.isConstructor() ||
      info.isInterface();
}
 
Example 12
Source File: Closure_90_FunctionTypeBuilder_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Infers the type of {@code this}.
 * @param info The JSDocInfo for this function.
 * @param owner The node for the object whose prototype "owns" this function.
 *     For example, {@code A} in the expression {@code A.prototype.foo}. May
 *     be null to indicate that this is not a prototype property.
 */
FunctionTypeBuilder inferThisType(JSDocInfo info,
    @Nullable Node owner) {
  ObjectType maybeThisType = null;
  if (info != null && info.hasThisType()) {
    maybeThisType = ObjectType.cast(
        info.getThisType().evaluate(scope, typeRegistry));
  }
  if (maybeThisType != null) {
    thisType = maybeThisType;
    thisType.setValidator(new ThisTypeValidator());
  } else if (owner != null &&
             (info == null || !info.hasType())) {
    // If the function is of the form:
    // x.prototype.y = function() {}
    // then we can assume "x" is the @this type. On the other hand,
    // if it's of the form:
    // /** @type {Function} */ x.prototype.y;
    // then we should not give it a @this type.
    String ownerTypeName = owner.getQualifiedName();
    ObjectType ownerType = ObjectType.cast(
        typeRegistry.getForgivingType(
            scope, ownerTypeName, sourceName,
            owner.getLineno(), owner.getCharno()));
    if (ownerType != null) {
      thisType = ownerType;
    }
  }

  return this;
}
 
Example 13
Source File: Closure_90_FunctionTypeBuilder_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Determines whether the given jsdoc info declares a function type.
 */
static boolean isFunctionTypeDeclaration(JSDocInfo info) {
  return info.getParameterCount() > 0 ||
      info.hasReturnType() ||
      info.hasThisType() ||
      info.isConstructor() ||
      info.isInterface();
}
 
Example 14
Source File: Closure_99_CheckGlobalThis_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // or @override annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null &&
        (jsDoc.isConstructor() ||
         jsDoc.hasThisType() ||
         jsDoc.isOverride())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {};
    int pType = parent.getType();
    if (!(pType == Token.BLOCK ||
          pType == Token.SCRIPT ||
          pType == Token.NAME ||
          pType == Token.ASSIGN)) {
      return false;
    }
  }

  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();
    
    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
        if (lhs.getType() == Token.GETPROP &&
            lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        if (lhs.getQualifiedName() != null && lhs.getQualifiedName().contains(".prototype.")) {
          return false;
        }
    }
  }

  return true;
}
 
Example 15
Source File: Closure_99_CheckGlobalThis_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // or @override annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null &&
        (jsDoc.isConstructor() ||
         jsDoc.isInterface() ||
         jsDoc.hasThisType() ||
         jsDoc.isOverride())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {};
    int pType = parent.getType();
    if (!(pType == Token.BLOCK ||
          pType == Token.SCRIPT ||
          pType == Token.NAME ||
          pType == Token.ASSIGN)) {
      return false;
    }
  }

  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();
    
    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (NodeUtil.isGet(lhs)) {
        if (lhs.getType() == Token.GETPROP &&
            lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        Node llhs = lhs.getFirstChild();
        if (llhs.getType() == Token.GETPROP &&
            llhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
      }
    }
  }

  return true;
}
 
Example 16
Source File: Closure_91_CheckGlobalThis_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // or @override annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null &&
        (jsDoc.isConstructor() ||
         jsDoc.isInterface() ||
         jsDoc.hasThisType() ||
         jsDoc.isOverride())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {}; // or
    // var a = {x: function() {}};
    int pType = parent.getType();
    if (!(pType == Token.BLOCK ||
          pType == Token.SCRIPT ||
          pType == Token.NAME ||
          pType == Token.ASSIGN ||

          // object literal keys
          pType == Token.STRING ||
          pType == Token.NUMBER)) {
      return false;
    }

    // Don't traverse functions that are getting lent to a prototype.
    Node gramps = parent.getParent();
    if (NodeUtil.isObjectLitKey(parent, gramps)) {
      JSDocInfo maybeLends = gramps.getJSDocInfo();
      if (maybeLends != null &&
          maybeLends.getLendsName() != null &&
          maybeLends.getLendsName().endsWith(".prototype")) {
        return false;
      }
    }
  }

  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();

    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (NodeUtil.isGet(lhs)) {
        if (lhs.getType() == Token.GETPROP &&
            lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        Node llhs = lhs.getFirstChild();
        if (llhs.getType() == Token.GETPROP &&
            llhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
      }
    }
  }

  return true;
}
 
Example 17
Source File: Closure_91_CheckGlobalThis_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // or @override annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null &&
        (jsDoc.isConstructor() ||
         jsDoc.isInterface() ||
         jsDoc.hasThisType() ||
         jsDoc.isOverride())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {}; // or
    // var a = {x: function() {}};
    int pType = parent.getType();
    if (!(pType == Token.BLOCK ||
          pType == Token.SCRIPT ||
          pType == Token.NAME ||
          pType == Token.ASSIGN ||

          // object literal keys
          pType == Token.STRING ||
          pType == Token.NUMBER)) {
      return false;
    }

    // Don't traverse functions that are getting lent to a prototype.
  }

  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();

    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (NodeUtil.isGet(lhs)) {
        if (lhs.getType() == Token.GETPROP &&
            lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        Node llhs = lhs.getFirstChild();
        if (llhs.getType() == Token.GETPROP &&
            llhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
      }
    }
  }

  return true;
}
 
Example 18
Source File: Closure_100_CheckGlobalThis_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null && (jsDoc.isConstructor() || jsDoc.hasThisType())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {};
  }

  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();
    
    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (lhs.getType() == Token.GETPROP) {
        if (lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        String leftName = lhs.getQualifiedName();
        if (leftName != null && leftName.contains(".prototype.")) {
          return false;
        }
      }
    }
  }

  return true;
}
 
Example 19
Source File: Closure_100_CheckGlobalThis_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null && (jsDoc.isConstructor() || jsDoc.hasThisType())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {};
    int pType = parent.getType();
    if (!(pType == Token.BLOCK ||
          pType == Token.SCRIPT ||
          pType == Token.NAME ||
          pType == Token.ASSIGN)) {
      return false;
    }
  }

  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();
    
    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (lhs.getType() == Token.GETPROP) {
        if (lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        String leftName = lhs.getQualifiedName();
        if (leftName != null && leftName.contains(".prototype.")) {
          return false;
        }
      }
    }
  }

  return true;
}
 
Example 20
Source File: CheckGlobalThis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {

  if (n.isFunction()) {
    // Don't traverse functions that are constructors or have the @this
    // or @override annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null &&
        (jsDoc.isConstructor() ||
         jsDoc.isInterface() ||
         jsDoc.hasThisType() ||
         jsDoc.isOverride())) {
      return false;
    }

    // Don't traverse functions unless they would normally
    // be able to have a @this annotation associated with them. e.g.,
    // var a = function() { }; // or
    // function a() {} // or
    // a.x = function() {}; // or
    // var a = {x: function() {}};
    int pType = parent.getType();
    if (!(pType == Token.BLOCK ||
          pType == Token.SCRIPT ||
          pType == Token.NAME ||
          pType == Token.ASSIGN ||

          // object literal keys
          pType == Token.STRING_KEY)) {
      return false;
    }

    // Don't traverse functions that are getting lent to a prototype.
    Node gramps = parent.getParent();
    if (NodeUtil.isObjectLitKey(parent, gramps)) {
      JSDocInfo maybeLends = gramps.getJSDocInfo();
      if (maybeLends != null &&
          maybeLends.getLendsName() != null &&
          maybeLends.getLendsName().endsWith(".prototype")) {
        return false;
      }
    }
  }

  if (parent != null && parent.isAssign()) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();

    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (NodeUtil.isGet(lhs)) {
        if (lhs.isGetProp() &&
            lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        Node llhs = lhs.getFirstChild();
        if (llhs.isGetProp() &&
            llhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
      }
    }
  }

  return true;
}