public Description matchMemberSelect()

in nullaway/src/main/java/com/uber/nullaway/NullAway.java [593:624]


  public Description matchMemberSelect(MemberSelectTree tree, VisitorState state) {
    if (!withinAnnotatedCode(state)) {
      return Description.NO_MATCH;
    }
    Symbol symbol = ASTHelpers.getSymbol(tree);
    // Some checks for cases where we know this cannot be a null dereference.  The tree's symbol may
    // be null in cases where the tree represents part of a package name, e.g., in the package
    // declaration in a class, or in a requires clause in a module-info.java file; it should never
    // be null for a real field dereference or method call
    if (symbol == null
        || symbol.getSimpleName().toString().equals("class")
        || symbol.isEnum()
        || symbol instanceof ModuleElement) {
      return Description.NO_MATCH;
    }
    if ((tree.getExpression() instanceof AnnotatedTypeTree)
        && !config.isLegacyAnnotationLocation()) {
      checkNullableAnnotationPositionInType(
          ((AnnotatedTypeTree) tree.getExpression()).getAnnotations(), tree, state);
    }

    Description badDeref = matchDereference(tree.getExpression(), tree, state);
    if (!badDeref.equals(Description.NO_MATCH)) {
      return badDeref;
    }
    // if we're accessing a field of this, make sure we're not reading the field before init
    if (tree.getExpression() instanceof IdentifierTree
        && ((IdentifierTree) tree.getExpression()).getName().toString().equals("this")) {
      return checkForReadBeforeInit(tree, state);
    }
    return Description.NO_MATCH;
  }