Class AccessPath

java.lang.Object
com.google.errorprone.dataflow.AccessPath

public abstract class AccessPath
extends Object
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()  
  • Method Summary

    Modifier and Type Method Description
    abstract Element base()
    If present, base of access path is contained Element; if absent, base is `this`
    static AccessPath fromFieldAccess​(org.checkerframework.shaded.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.shaded.dataflow.cfg.node.LocalVariableNode node)  
    static AccessPath fromNodeIfTrackable​(org.checkerframework.shaded.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.shaded.dataflow.cfg.node.VariableDeclarationNode node)  
    static boolean isAutoValueAccessor​(com.sun.source.tree.Tree tree)
    Check whether tree is an AutoValue accessor.
    abstract com.google.common.collect.ImmutableList<String> path()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AccessPath

      public AccessPath()
  • Method Details

    • base

      @Nullable public abstract Element base()
      If present, base of access path is contained Element; if absent, base is `this`
    • path

      public abstract com.google.common.collect.ImmutableList<String> path()
    • isAutoValueAccessor

      public static boolean isAutoValueAccessor​(com.sun.source.tree.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

      @Nullable public static AccessPath fromFieldAccess​(org.checkerframework.shaded.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.shaded.dataflow.cfg.node.LocalVariableNode node)
    • fromVariableDecl

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

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