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


Java SourceSinkInfo类代码示例

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


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

示例1: emitSourceWarning

import edu.umd.cs.findbugs.ba.jsr305.SourceSinkInfo; //导入依赖的package包/类
private void emitSourceWarning(String bugType, XMethod xMethod, TypeQualifierValue typeQualifierValue,
        FlowValue backwardsFlowValue, TypeQualifierValueSet backwardsFact, SourceSinkInfo source, ValueNumber vn,
        Location location) {

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

    annotateWarningWithSourceSinkInfo(warning, xMethod, vn, source);

    Set<? extends SourceSinkInfo> sinkSet = (backwardsFlowValue == FlowValue.NEVER) ? backwardsFact.getWhereNever(vn) : backwardsFact
            .getWhereAlways(vn);
    for (SourceSinkInfo sink : sinkSet) {
        annotateWarningWithSourceSinkInfo(warning, xMethod, vn, sink);
    }

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

示例2: getSinkLocation

import edu.umd.cs.findbugs.ba.jsr305.SourceSinkInfo; //导入依赖的package包/类
private @CheckForNull
Location getSinkLocation(SourceSinkInfo sourceSinkInfo) {
    switch (sourceSinkInfo.getType()) {

    case ARGUMENT_TO_CALLED_METHOD:
    case RETURN_VALUE:
    case FIELD_STORE:
        return sourceSinkInfo.getLocation();

    default:
        return null;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:14,代码来源:CheckTypeQualifiers.java

示例3: emitDataflowWarning

import edu.umd.cs.findbugs.ba.jsr305.SourceSinkInfo; //导入依赖的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

示例4: annotateWarningWithSourceSinkInfo

import edu.umd.cs.findbugs.ba.jsr305.SourceSinkInfo; //导入依赖的package包/类
private void annotateWarningWithSourceSinkInfo(BugInstance warning, XMethod xMethod, ValueNumber vn,
        SourceSinkInfo sourceSinkInfo) {
    MethodDescriptor methodDescriptor = xMethod.getMethodDescriptor();
    switch (sourceSinkInfo.getType()) {
    case PARAMETER:
        try {
            Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
            LocalVariableAnnotation lva = LocalVariableAnnotation.getParameterLocalVariableAnnotation(method,
                    sourceSinkInfo.getLocal());
            lva.setDescription(lva.isSignificant() ? "LOCAL_VARIABLE_PARAMETER_VALUE_SOURCE_NAMED"
                    : "LOCAL_VARIABLE_PARAMETER_VALUE_SOURCE");
            warning.add(lva);
        } catch (CheckedAnalysisException e) {
            warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation()).describe("SOURCE_LINE_VALUE_SOURCE");
        }
        break;

    case CONSTANT_VALUE:
        Object constantValue = sourceSinkInfo.getConstantValue();
        if (constantValue instanceof String) {
            warning.addString((String) constantValue).describe(StringAnnotation.STRING_CONSTANT_ROLE);
        } else if (constantValue instanceof Integer) {
            warning.addInt((Integer) constantValue).describe(IntAnnotation.INT_VALUE);
        } else if (constantValue == null)
            warning.addString("null").describe(StringAnnotation.STRING_NONSTRING_CONSTANT_ROLE);
        else
            warning.addString(constantValue.toString()).describe(StringAnnotation.STRING_NONSTRING_CONSTANT_ROLE);
        break;

    case RETURN_VALUE_OF_CALLED_METHOD:
    case FIELD_LOAD:
        warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation()).describe("SOURCE_LINE_VALUE_SOURCE");
        break;

    case ARGUMENT_TO_CALLED_METHOD:
    case RETURN_VALUE:
    case FIELD_STORE:
        warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation());
        return;

    default:
        throw new IllegalStateException();
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:45,代码来源:CheckTypeQualifiers.java

示例5: annotateWarningWithSourceSinkInfo

import edu.umd.cs.findbugs.ba.jsr305.SourceSinkInfo; //导入依赖的package包/类
private void annotateWarningWithSourceSinkInfo(BugInstance warning, XMethod xMethod, ValueNumber vn,
        SourceSinkInfo sourceSinkInfo) {
    MethodDescriptor methodDescriptor = xMethod.getMethodDescriptor();
    switch (sourceSinkInfo.getType()) {
    case PARAMETER:
        try {
            Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
            LocalVariableAnnotation lva = LocalVariableAnnotation.getParameterLocalVariableAnnotation(method,
                    sourceSinkInfo.getLocal());
            lva.setDescription(lva.isSignificant() ? LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_NAMED_ROLE
                    : LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_ROLE);
            
            warning.add(lva);
        } catch (CheckedAnalysisException e) {
            warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation()).describe("SOURCE_LINE_VALUE_SOURCE");
        }
        break;

    case CONSTANT_VALUE:
        Object constantValue = sourceSinkInfo.getConstantValue();
        if (constantValue instanceof String) {
            warning.addString((String) constantValue).describe(StringAnnotation.STRING_CONSTANT_ROLE);
        } else if (constantValue instanceof Integer) {
            warning.addInt((Integer) constantValue).describe(IntAnnotation.INT_VALUE);
        } else if (constantValue == null)
            warning.addString("null").describe(StringAnnotation.STRING_NONSTRING_CONSTANT_ROLE);
        else
            warning.addString(constantValue.toString()).describe(StringAnnotation.STRING_NONSTRING_CONSTANT_ROLE);
        break;

    case RETURN_VALUE_OF_CALLED_METHOD:
    case FIELD_LOAD:
        warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation()).describe("SOURCE_LINE_VALUE_SOURCE");
        break;

    case ARGUMENT_TO_CALLED_METHOD:
    case RETURN_VALUE:
    case FIELD_STORE:
        warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation());
        return;

    default:
        throw new IllegalStateException();
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:46,代码来源:CheckTypeQualifiers.java


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