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


Java SourceInfoMap类代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.ba.SourceInfoMap的典型用法代码示例。如果您正苦于以下问题:Java SourceInfoMap类的具体用法?Java SourceInfoMap怎么用?Java SourceInfoMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SourceInfoMap类属于edu.umd.cs.findbugs.ba包,在下文中一共展示了SourceInfoMap类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAnalysisContext

import edu.umd.cs.findbugs.ba.SourceInfoMap; //导入依赖的package包/类
/**
 * Create the AnalysisContext that will serve as the BCEL-compatibility
 * layer over the AnalysisCache.
 *
 * @param project
 *            The project
 * @param appClassList
 *            list of ClassDescriptors identifying application classes
 * @param sourceInfoFileName
 *            name of source info file (null if none)
 */
@SuppressWarnings({"UnusedDeclaration"})
public static void createAnalysisContext(Project project, List<ClassDescriptor> appClassList,
        @CheckForNull String sourceInfoFileName) throws  IOException {
    AnalysisCacheToAnalysisContextAdapter analysisContext = new AnalysisCacheToAnalysisContextAdapter();

    // Make this the current analysis context
    AnalysisContext.setCurrentAnalysisContext(analysisContext);

    // Make the AnalysisCache the backing store for
    // the BCEL Repository
    analysisContext.clearRepository();

    // If needed, load SourceInfoMap
    if (sourceInfoFileName != null) {
        SourceInfoMap sourceInfoMap = analysisContext.getSourceInfoMap();
        sourceInfoMap.read(new FileInputStream(sourceInfoFileName));
    }
    analysisContext.setProject(project);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:31,代码来源:FindBugs2.java

示例2: 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

示例3: createAnalysisContext

import edu.umd.cs.findbugs.ba.SourceInfoMap; //导入依赖的package包/类
/**
 * Create the AnalysisContext that will serve as the BCEL-compatibility
 * layer over the AnalysisCache.
 *
 * @param project
 *            The project
 * @param appClassList
 *            list of ClassDescriptors identifying application classes
 * @param sourceInfoFileName
 *            name of source info file (null if none)
 */
@SuppressWarnings({"UnusedDeclaration"})
public static void createAnalysisContext(Project project, List<ClassDescriptor> appClassList,
        @CheckForNull String sourceInfoFileName) throws  IOException {
    AnalysisContext analysisContext = new AnalysisContext();

    // Make this the current analysis context
    AnalysisContext.setCurrentAnalysisContext(analysisContext);

    // Make the AnalysisCache the backing store for
    // the BCEL Repository
    analysisContext.clearRepository();

    // If needed, load SourceInfoMap
    if (sourceInfoFileName != null) {
        SourceInfoMap sourceInfoMap = analysisContext.getSourceInfoMap();
        sourceInfoMap.read(new FileInputStream(sourceInfoFileName));
    }
    analysisContext.setProject(project);
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:31,代码来源:FindBugs2.java

示例4: 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

示例5: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。