本文整理汇总了Java中edu.umd.cs.findbugs.ba.SourceInfoMap.SourceLineRange方法的典型用法代码示例。如果您正苦于以下问题:Java SourceInfoMap.SourceLineRange方法的具体用法?Java SourceInfoMap.SourceLineRange怎么用?Java SourceInfoMap.SourceLineRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.SourceInfoMap
的用法示例。
在下文中一共展示了SourceInfoMap.SourceLineRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSourceLines
import edu.umd.cs.findbugs.ba.SourceInfoMap; //导入方法依赖的package包/类
@Override
public SourceLineAnnotation getSourceLines() {
if (sourceLines == null) {
// Create source line annotation for field on demand
AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext();
if (currentAnalysisContext == null)
sourceLines = new SourceLineAnnotation(className, sourceFileName, -1, -1, -1, -1);
else {
SourceInfoMap.SourceLineRange fieldLine = currentAnalysisContext.getSourceInfoMap().getFieldLine(className,
fieldName);
if (fieldLine == null)
sourceLines = new SourceLineAnnotation(className, sourceFileName, -1, -1, -1, -1);
else
sourceLines = new SourceLineAnnotation(className, sourceFileName, fieldLine.getStart(), fieldLine.getEnd(),
-1, -1);
}
}
return sourceLines;
}
示例2: getSourceAnnotationForMethod
import edu.umd.cs.findbugs.ba.SourceInfoMap; //导入方法依赖的package包/类
/**
* @param className
* @param methodName
* @param methodSig
* @return
*/
static SourceLineAnnotation getSourceAnnotationForMethod(String className, String methodName, String methodSig) {
JavaClassAndMethod targetMethod = null;
Code code = null;
try {
JavaClass targetClass = AnalysisContext.currentAnalysisContext().lookupClass(className);
targetMethod = Hierarchy.findMethod(targetClass, methodName, methodSig);
if (targetMethod != null) {
Method method = targetMethod.getMethod();
if (method != null)
code = method.getCode();
}
} catch (ClassNotFoundException e) {
AnalysisContext.reportMissingClass(e);
}
SourceInfoMap sourceInfoMap = AnalysisContext.currentAnalysisContext().getSourceInfoMap();
SourceInfoMap.SourceLineRange range = sourceInfoMap.getMethodLine(className, methodName, methodSig);
if (range != null)
return new SourceLineAnnotation(className, AnalysisContext.currentAnalysisContext().lookupSourceFile(className),
range.getStart(), range.getEnd(), 0, code == null ? -1 : code.getLength());
if (sourceInfoMap.fallBackToClassfile() && targetMethod != null)
return forEntireMethod(targetMethod.getJavaClass(), targetMethod.getMethod());
// If we couldn't find the source lines,
// create an unknown source line annotation referencing
// the class and source file.
return createUnknown(className);
}
示例3: getSourceLinesForClass
import edu.umd.cs.findbugs.ba.SourceInfoMap; //导入方法依赖的package包/类
public static SourceLineAnnotation getSourceLinesForClass(@DottedClassName String className, String sourceFileName) {
// Create source line annotation for class on demand
AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext();
if (currentAnalysisContext == null)
return new SourceLineAnnotation(className, sourceFileName, -1, -1, -1, -1);
SourceInfoMap.SourceLineRange classLine = currentAnalysisContext.getSourceInfoMap().getClassLine(className);
if (classLine == null)
return SourceLineAnnotation.getSourceAnnotationForClass(className, sourceFileName);
else
return new SourceLineAnnotation(className, sourceFileName, classLine.getStart(), classLine.getEnd(), -1, -1);
}