Package edu.umd.cs.findbugs.ba
Class SourceInfoMap
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.SourceInfoMap
-
public class SourceInfoMap extends java.lang.ObjectGlobal information about the source code for an application. Currently, this object contains a map of source line information for fields and classes (items we don't get line number information for directly in classfiles), and also source line information for methods that don't appear directly in classfiles, such as abstract and native methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSourceInfoMap.FieldDescriptor(package private) static classSourceInfoMap.MethodDescriptorstatic classSourceInfoMap.SourceLineRangeA range of source lines.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,SourceInfoMap.SourceLineRange>classLineMapprivate static booleanDEBUGprivate static java.util.regex.PatternDIGITSprivate java.util.Map<SourceInfoMap.FieldDescriptor,SourceInfoMap.SourceLineRange>fieldLineMapprivate java.util.Map<SourceInfoMap.MethodDescriptor,SourceInfoMap.SourceLineRange>methodLineMap
-
Constructor Summary
Constructors Constructor Description SourceInfoMap()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClassLine(java.lang.String className, SourceInfoMap.SourceLineRange range)Add line number entry for a class.voidaddFieldLine(java.lang.String className, java.lang.String fieldName, SourceInfoMap.SourceLineRange range)Add a line number entry for a field.voidaddMethodLine(java.lang.String className, java.lang.String methodName, java.lang.String methodSignature, SourceInfoMap.SourceLineRange range)Add a line number entry for a method.private static SourceInfoMap.SourceLineRangecreateRange(java.lang.String start, java.lang.String end)private static booleanexpect(java.util.StringTokenizer tokenizer, java.lang.String token)Expect a particular token string to be returned by the given StringTokenizer.booleanfallBackToClassfile()SourceInfoMap.SourceLineRangegetClassLine(java.lang.String className)Look up the line number range for a class.SourceInfoMap.SourceLineRangegetFieldLine(java.lang.String className, java.lang.String fieldName)Look up the line number range for a field.SourceInfoMap.SourceLineRangegetMethodLine(java.lang.String className, java.lang.String methodName, java.lang.String methodSignature)Look up the line number range for a method.booleanisEmpty()private static java.lang.StringparseVersionNumber(java.lang.String line)Parse the sourceInfo version string.voidread(java.io.InputStream inputStream)Read source info from given InputStream.
-
-
-
Field Detail
-
DEBUG
private static final boolean DEBUG
-
fieldLineMap
private final java.util.Map<SourceInfoMap.FieldDescriptor,SourceInfoMap.SourceLineRange> fieldLineMap
-
methodLineMap
private final java.util.Map<SourceInfoMap.MethodDescriptor,SourceInfoMap.SourceLineRange> methodLineMap
-
classLineMap
private final java.util.Map<java.lang.String,SourceInfoMap.SourceLineRange> classLineMap
-
DIGITS
private static final java.util.regex.Pattern DIGITS
-
-
Method Detail
-
fallBackToClassfile
public boolean fallBackToClassfile()
-
isEmpty
public boolean isEmpty()
-
addFieldLine
public void addFieldLine(java.lang.String className, java.lang.String fieldName, SourceInfoMap.SourceLineRange range)Add a line number entry for a field.- Parameters:
className- name of class containing the fieldfieldName- name of fieldrange- the line number(s) of the field
-
addMethodLine
public void addMethodLine(java.lang.String className, java.lang.String methodName, java.lang.String methodSignature, SourceInfoMap.SourceLineRange range)Add a line number entry for a method.- Parameters:
className- name of class containing the methodmethodName- name of methodmethodSignature- signature of methodrange- the line number of the method
-
addClassLine
public void addClassLine(java.lang.String className, SourceInfoMap.SourceLineRange range)Add line number entry for a class.- Parameters:
className- name of classrange- the line numbers of the class
-
getFieldLine
@CheckForNull public SourceInfoMap.SourceLineRange getFieldLine(java.lang.String className, java.lang.String fieldName)
Look up the line number range for a field.- Parameters:
className- name of class containing the fieldfieldName- name of field- Returns:
- the line number range, or null if no line number is known for the field
-
getMethodLine
@CheckForNull public SourceInfoMap.SourceLineRange getMethodLine(java.lang.String className, java.lang.String methodName, java.lang.String methodSignature)
Look up the line number range for a method.- Parameters:
className- name of class containing the methodmethodName- name of methodmethodSignature- signature of method- Returns:
- the line number range, or null if no line number is known for the method
-
getClassLine
@CheckForNull public SourceInfoMap.SourceLineRange getClassLine(java.lang.String className)
Look up the line number range for a class.- Parameters:
className- name of the class- Returns:
- the line number range, or null if no line number is known for the class
-
read
public void read(@WillClose java.io.InputStream inputStream) throws java.io.IOExceptionRead source info from given InputStream. The stream is guaranteed to be closed.- Parameters:
inputStream- the InputStream- Throws:
java.io.IOException- if an I/O error occurs, or if the format is invalid
-
parseVersionNumber
private static java.lang.String parseVersionNumber(java.lang.String line)
Parse the sourceInfo version string.- Parameters:
line- the first line of the sourceInfo file- Returns:
- the version number constant, or null if the line does not appear to be a version string
-
expect
private static boolean expect(java.util.StringTokenizer tokenizer, java.lang.String token)Expect a particular token string to be returned by the given StringTokenizer.- Parameters:
tokenizer- the StringTokenizertoken- the expectedToken- Returns:
- true if the expected token was returned, false if not
-
createRange
private static SourceInfoMap.SourceLineRange createRange(java.lang.String start, java.lang.String end)
-
-