当前位置: 首页>>代码示例>>Java>>正文


Java SourceInfoMap.SourceLineRange方法代码示例

本文整理汇总了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;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:FieldAnnotation.java

示例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);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:39,代码来源:SourceLineAnnotation.java

示例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);
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:ClassAnnotation.java


注:本文中的edu.umd.cs.findbugs.ba.SourceInfoMap.SourceLineRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。