本文整理汇总了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);
}