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


Java SourceLineAnnotation.setDescription方法代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.SourceLineAnnotation.setDescription方法的典型用法代码示例。如果您正苦于以下问题:Java SourceLineAnnotation.setDescription方法的具体用法?Java SourceLineAnnotation.setDescription怎么用?Java SourceLineAnnotation.setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.findbugs.SourceLineAnnotation的用法示例。


在下文中一共展示了SourceLineAnnotation.setDescription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: emitDataflowWarning

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入方法依赖的package包/类
private void emitDataflowWarning(XMethod xMethod, TypeQualifierValue typeQualifierValue,
        TypeQualifierValueSet forwardsFact, TypeQualifierValueSet backwardsFact, ValueNumber vn, FlowValue forward,
        FlowValue backward, Location locationToReport, @CheckForNull Location locationWhereDoomedValueIsObserved, ValueNumberFrame vnaFrame)
        throws CheckedAnalysisException {
    String bugType;
    if (typeQualifierValue.isStrictQualifier() && forward == FlowValue.UNKNOWN)
        bugType = "TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED";
    else if (backward == FlowValue.NEVER)
        bugType = "TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED";
    else
        bugType = "TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED";

    // Issue warning
    BugInstance warning = new BugInstance(this, bugType, Priorities.NORMAL_PRIORITY).addClassAndMethod(xMethod);
    annotateWarningWithTypeQualifier(warning, typeQualifierValue);

    Set<? extends SourceSinkInfo> sourceSet = (forward == FlowValue.ALWAYS) ? forwardsFact.getWhereAlways(vn) : forwardsFact
            .getWhereNever(vn);
    for (SourceSinkInfo source : sourceSet) {
        annotateWarningWithSourceSinkInfo(warning, xMethod, vn, source);
    }
    Set<? extends SourceSinkInfo> sinkSet = (backward == FlowValue.ALWAYS) ? backwardsFact.getWhereAlways(vn) : backwardsFact
            .getWhereNever(vn);

    Location sinkLocation = getSinkLocation(sinkSet);
    if (sinkLocation == null) {
        AnalysisContext.logError("Unable to compute sink location for " + xMethod);
        return;
    }

    // Hopefully we can find the conflicted value in a local variable
    if (locationWhereDoomedValueIsObserved != null) {
        Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, xMethod.getMethodDescriptor());

        LocalVariableAnnotation localVariable = ValueNumberSourceInfo.findLocalAnnotationFromValueNumber(method,
                locationWhereDoomedValueIsObserved, vn, vnaFrame);
        if (localVariable != null && !localVariable.equals(warning.getPrimaryLocalVariableAnnotation())) {
            localVariable.setDescription(localVariable.isSignificant() ? "LOCAL_VARIABLE_VALUE_DOOMED_NAMED"
                    : "LOCAL_VARIABLE_VALUE_DOOMED");
            warning.add(localVariable);

        }
        if (!sinkLocation.equals(locationToReport)) {
            // Report where we observed the value.
            // Note that for conflicts detected on control edges,
            // we REPORT the edge source location
            // rather than the target location, even though it is the
            // target location where the conflict is detected.
            // The only reason to use a different reporting location
            // is to produce a more informative report for the user,
            // since the edge source is where the branch is found.
            SourceLineAnnotation observedLocation = SourceLineAnnotation.fromVisitedInstruction(xMethod.getMethodDescriptor(),
                    locationToReport);
            observedLocation.setDescription("SOURCE_LINE_VALUE_DOOMED");
            warning.add(observedLocation);
        }
    }

    // Add value sinks
    for (SourceSinkInfo sink : sinkSet) {
        annotateWarningWithSourceSinkInfo(warning, xMethod, vn, sink);
    }

    bugReporter.reportBug(warning);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:66,代码来源:CheckTypeQualifiers.java


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