Record Class AccessPath

java.lang.Object
java.lang.Record
com.google.errorprone.dataflow.AccessPath
Record Components:
base - If present, base of access path is contained Element; if absent, base is `this`

public record AccessPath(@Nullable Element base, com.google.common.collect.ImmutableList<String> path) extends Record
A sequence of field names or autovalue accessors, along with a receiver: either a variable or a reference (explicit or implicit) to this. Fields and autovalue accessors are stored as strings, with a "()" appended to accessor names to distinguish them from fields of the same name

For example:

x.f.g, the g field of the f field of the local variable x is represented by {base = Some x, fields = "g" :: "f" :: nil}

foo.bar, the bar field of the foo field of the implicit this is represented by {base = None, fields = "bar" :: "foo" :: nil}

x.foo().foo, the foo field of the foo() autovalue accessor of the local variable x is represented by {base = Some x, fields = "foo" :: "foo()" :: nil}

Author:
bennostein@google.com (Benno Stein)
  • Constructor Summary

    Constructors
    Constructor
    Description
    AccessPath(@Nullable Element base, com.google.common.collect.ImmutableList<String> path)
    Creates an instance of a AccessPath record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Element
    Returns the value of the base record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static @Nullable AccessPath
    fromFieldAccess(org.checkerframework.errorprone.dataflow.cfg.node.FieldAccessNode fieldAccess)
    Creates an AccessPath from field reads / AutoValue accessor we can track and returns null otherwise (for example, when the receiver of the field access contains an array access or non-AutoValue method call.
    static AccessPath
    fromLocalVariable(org.checkerframework.errorprone.dataflow.cfg.node.LocalVariableNode node)
     
    static @Nullable AccessPath
    fromNodeIfTrackable(org.checkerframework.errorprone.dataflow.cfg.node.Node node)
    Returns an AccessPath representing node if node is representable as an access path and null otherwise
    static AccessPath
    fromVariableDecl(org.checkerframework.errorprone.dataflow.cfg.node.VariableDeclarationNode node)
     
    final int
    Returns a hash code value for this object.
    static boolean
    Check whether tree is an AutoValue accessor.
    com.google.common.collect.ImmutableList<String>
    Returns the value of the path record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AccessPath

      public AccessPath(@Nullable Element base, com.google.common.collect.ImmutableList<String> path)
      Creates an instance of a AccessPath record class.
      Parameters:
      base - the value for the base record component
      path - the value for the path record component
  • Method Details

    • isAutoValueAccessor

      public static boolean isAutoValueAccessor(Tree tree)
      Check whether tree is an AutoValue accessor. A tree is an AutoValue accessor iff:
      • it is a method invocation
      • of an abstract method
      • with 0 arguments
      • defined on a class annotated @AutoValue

      Public visibility for use in NullnessPropagationTransfer#returnValueNullness

    • fromFieldAccess

      public static @Nullable AccessPath fromFieldAccess(org.checkerframework.errorprone.dataflow.cfg.node.FieldAccessNode fieldAccess)
      Creates an AccessPath from field reads / AutoValue accessor we can track and returns null otherwise (for example, when the receiver of the field access contains an array access or non-AutoValue method call.
    • fromLocalVariable

      public static AccessPath fromLocalVariable(org.checkerframework.errorprone.dataflow.cfg.node.LocalVariableNode node)
    • fromVariableDecl

      public static AccessPath fromVariableDecl(org.checkerframework.errorprone.dataflow.cfg.node.VariableDeclarationNode node)
    • fromNodeIfTrackable

      public static @Nullable AccessPath fromNodeIfTrackable(org.checkerframework.errorprone.dataflow.cfg.node.Node node)
      Returns an AccessPath representing node if node is representable as an access path and null otherwise
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • base

      public @Nullable Element base()
      Returns the value of the base record component.
      Returns:
      the value of the base record component
    • path

      public com.google.common.collect.ImmutableList<String> path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component