Class LocalVariableAnnotation

java.lang.Object
edu.umd.cs.findbugs.LocalVariableAnnotation
All Implemented Interfaces:
BugAnnotation, XMLWriteable, XMLWriteableWithMessages, Serializable, Cloneable, Comparable<BugAnnotation>

public class LocalVariableAnnotation extends Object implements BugAnnotation
Bug annotation class for local variable names
Author:
William Pugh
See Also:
  • Field Details

  • Constructor Details

    • LocalVariableAnnotation

      public LocalVariableAnnotation(String name, int register, int pc)
      Constructor.
      Parameters:
      name - the name of the local variable
      register - the local variable index
      pc - the bytecode offset of the instruction that mentions this local variable
    • LocalVariableAnnotation

      public LocalVariableAnnotation(String name, int register, int pc, int line)
      Constructor.
      Parameters:
      name - the name of the local variable
      register - the local variable index
      pc - the bytecode offset of the instruction that mentions this local variable
  • Method Details

    • getLocalVariableAnnotation

      public static LocalVariableAnnotation getLocalVariableAnnotation(org.apache.bcel.classfile.Method method, Location location, org.apache.bcel.generic.IndexedInstruction ins)
    • getLocalVariableAnnotation

      public static LocalVariableAnnotation getLocalVariableAnnotation(org.apache.bcel.classfile.Method method, int local, int position1, int position2)
    • getParameterLocalVariableAnnotation

      public static LocalVariableAnnotation getParameterLocalVariableAnnotation(org.apache.bcel.classfile.Method method, int local)
      Get a local variable annotation describing a parameter.
      Parameters:
      method - a Method
      local - the local variable containing the parameter
      Returns:
      LocalVariableAnnotation describing the parameter
    • clone

      public Object clone()
      Specified by:
      clone in interface BugAnnotation
      Overrides:
      clone in class Object
    • accept

      public void accept(BugAnnotationVisitor visitor)
      Description copied from interface: BugAnnotation
      Accept a BugAnnotationVisitor.
      Specified by:
      accept in interface BugAnnotation
      Parameters:
      visitor - the visitor to accept
    • format

      public String format(String key, ClassAnnotation primaryClass)
      Description copied from interface: BugAnnotation
      Format the annotation as a String. The given key specifies additional information about how the annotation should be formatted. If the key is empty, then the "default" format will be used.
      Specified by:
      format in interface BugAnnotation
      Parameters:
      key - how the annotation should be formatted
      primaryClass - The primary class for the bug; some bug annotation format msgs are simplified in relation to that class.
    • setDescription

      public void setDescription(String description)
      Description copied from interface: BugAnnotation
      Set a description of this bug annotation. The description is a key for the FindBugsAnnotationDescriptions resource bundle.
      Specified by:
      setDescription in interface BugAnnotation
    • getDescription

      public String getDescription()
      Description copied from interface: BugAnnotation
      Get a description of this bug annotation. The description is a key for the FindBugsAnnotationDescriptions resource bundle.
      Specified by:
      getDescription in interface BugAnnotation
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(BugAnnotation o)
      Specified by:
      compareTo in interface Comparable<BugAnnotation>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeXML

      public void writeXML(XMLOutput xmlOutput) throws IOException
      Description copied from interface: XMLWriteable
      Write this object to given XMLOutput.
      Specified by:
      writeXML in interface XMLWriteable
      Parameters:
      xmlOutput - the XMLOutput for the document
      Throws:
      IOException
    • writeXML

      public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException
      Specified by:
      writeXML in interface XMLWriteableWithMessages
      Throws:
      IOException
    • isNamed

      public boolean isNamed()
    • getName

      public String getName()
      Returns:
      name of local variable
    • getPC

      public int getPC()
    • getRegister

      public int getRegister()
    • isSignificant

      public boolean isSignificant()
      Description copied from interface: BugAnnotation
      Is this annotation used to compute instance hashes or match bug instances across versions
      Specified by:
      isSignificant in interface BugAnnotation
      Returns:
      true if significant
    • getLocalVariableAnnotation

      @CheckForNull public static LocalVariableAnnotation getLocalVariableAnnotation(org.apache.bcel.classfile.Method method, OpcodeStack.Item item, int pc)
    • getLocalVariableAnnotation

      @CheckForNull public static LocalVariableAnnotation getLocalVariableAnnotation(DismantleBytecode visitor, OpcodeStack.Item item)
    • findMatchingIgnoredParameter

      @CheckForNull public static LocalVariableAnnotation findMatchingIgnoredParameter(ClassContext classContext, org.apache.bcel.classfile.Method method, String name, String signature)
    • findUniqueBestMatchingParameter

      @CheckForNull public static LocalVariableAnnotation findUniqueBestMatchingParameter(ClassContext classContext, org.apache.bcel.classfile.Method method, String name, String signature)
    • toString

      public String toString(ClassAnnotation primaryClass)
      Specified by:
      toString in interface BugAnnotation