本文整理汇总了Java中edu.umd.cs.findbugs.ba.XMethod.getNumParams方法的典型用法代码示例。如果您正苦于以下问题:Java XMethod.getNumParams方法的具体用法?Java XMethod.getNumParams怎么用?Java XMethod.getNumParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.XMethod
的用法示例。
在下文中一共展示了XMethod.getNumParams方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDirectAnnotation
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
* Get the direct annotations (if any) on given method parameter.
*
* @param m
* a method
* @param parameter
* a parameter (0 == first parameter)
* @return Collection of AnnotationValues representing annotations directly
* applied to this parameter
*/
private static Collection<AnnotationValue> getDirectAnnotation(XMethod m, int parameter) {
HashMap<XMethod, Map<Integer, Collection<AnnotationValue>>> directParameterAnnotations = getDirectParameterAnnotations();
Map<Integer, Collection<AnnotationValue>> map = directParameterAnnotations.get(m);
if (map == null) {
int n = m.getNumParams();
if (m.isVarArgs())
n--; // ignore annotations on varargs parameters
map = new HashMap<Integer, Collection<AnnotationValue>>(n + 2);
for (int i = 0; i < n; i++) {
Collection<AnnotationValue> a = TypeQualifierResolver.resolveTypeQualifiers(m.getParameterAnnotations(i));
if (!a.isEmpty())
map.put(i, a);
}
if (map.isEmpty())
map = Collections.emptyMap();
directParameterAnnotations.put(m, map);
}
Collection<AnnotationValue> result = map.get(parameter);
if (result != null)
return result;
return Collections.emptyList();
}
示例2: addEffectiveRelevantQualifiers
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private static void addEffectiveRelevantQualifiers(HashSet<TypeQualifierValue<?>> result, XMethod xmethod) {
if (DEBUG_FIND_EFFECTIVE_RELEVANT_QUALIFIERS) {
System.out.println(" Finding effective qualifiers for " + xmethod);
}
for (TypeQualifierValue<?> tqv : TypeQualifierValue.getAllKnownTypeQualifiers()) {
if (DEBUG_FIND_EFFECTIVE_RELEVANT_QUALIFIERS) {
System.out.print(" " + tqv + "...");
}
TypeQualifierAnnotation tqa;
boolean add = false;
tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, tqv);
if (tqa != null) {
add = true;
}
if (!add) {
int numParams = xmethod.getNumParams();
for (int i = 0; i < numParams; i++) {
tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, i, tqv);
if (tqa != null) {
add = true;
break;
}
}
}
if (add) {
result.add(tqv);
}
if (DEBUG_FIND_EFFECTIVE_RELEVANT_QUALIFIERS) {
System.out.println(add ? "YES" : "NO");
}
}
}
示例3: addObligations
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
* @param xmethod
*/
public void addObligations(XMethod xmethod) {
// See what obligation parameters there are
Obligation[] paramObligationTypes = database.getFactory().getParameterObligationTypes(xmethod);
//
// Check for @WillCloseWhenClosed, @WillClose, @WillNotClose, or
// other
// indications of how obligation parameters are handled.
//
boolean methodHasCloseInName = false;
if (INFER_CLOSE_METHODS) {
SplitCamelCaseIdentifier splitter = new SplitCamelCaseIdentifier(xmethod.getName());
methodHasCloseInName = splitter.split().contains("close");
}
for (int i = 0; i < xmethod.getNumParams(); i++)
if (paramObligationTypes[i] != null) {
if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
//
// Calling this method deletes a parameter obligation
// and
// creates a new obligation for the object returned by
// the method.
//
handleWillCloseWhenClosed(xmethod, paramObligationTypes[i]);
} else if (xmethod.getParameterAnnotation(i, willClose) != null) {
if (paramObligationTypes[i] == null) {
// Hmm...
if (DEBUG_ANNOTATIONS) {
System.out.println("Method " + xmethod.toString() + " has param " + i + " annotated @WillClose, "
+ "but its type is not an obligation type");
}
} else {
addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
ObligationPolicyDatabaseEntryType.STRONG);
}
sawAnnotationsInApplicationCode = true;
} else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
// No database entry needs to be added
sawAnnotationsInApplicationCode = true;
} else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
// Method has "close" in its name.
// Assume that it deletes the obligation.
addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
ObligationPolicyDatabaseEntryType.STRONG);
} else {
/*
* // Interesting case: we have a parameter which is // an
* Obligation type, but no annotation or other indication //
* what is done by the method with the obligation. // We'll
* create a "weak" database entry deleting the //
* obligation. If strict checking is performed, // weak
* entries are ignored.
*/
if (xmethod.getName().equals("<init>") || xmethod.isStatic()
|| xmethod.getName().toLowerCase().indexOf("close") >= 0
|| xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
ObligationPolicyDatabaseEntryType.WEAK);
}
}
}
示例4: modelArguments
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void modelArguments(Location location) throws DataflowAnalysisException {
// Model arguments to called method
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
XMethod calledMethod = XFactory.createXMethod(inv, cpg);
SignatureParser sigParser = new SignatureParser(calledMethod.getSignature());
if (sigParser.getNumParameters() == 0)
return;
ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location);
if (!vnaFrame.isValid()) {
// AnalysisContext.logError("bad vna frame in " + xmethod +
// " at location " + location.getHandle().getPosition() +
// " calling " + calledMethod);
return;
}
if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledMethod))
return;
for (int param = 0; param < calledMethod.getNumParams(); param++) {
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, param,
typeQualifierValue);
boolean interproc = false;
if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
// See if there's an entry for this parameter
// in the interprocedural type qualifier database.
TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
tqa = tqdb.getParameter(calledMethod.getMethodDescriptor(), param, typeQualifierValue);
if (tqa != null) {
interproc = true;
}
}
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
ValueNumber vn = vnaFrame.getArgument(inv, cpg, param, sigParser);
SourceSinkInfo info = new SourceSinkInfo(SourceSinkType.ARGUMENT_TO_CALLED_METHOD, location, vn, when);
info.setParameter(param);
info.setInterproc(interproc);
registerSourceSink(info);
}
}
示例5: addObligations
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
* @param xmethod
*/
public void addObligations(XMethod xmethod) {
// See what obligation parameters there are
Obligation[] paramObligationTypes = database.getFactory().getParameterObligationTypes(xmethod);
//
// Check for @WillCloseWhenClosed, @WillClose, @WillNotClose, or
// other
// indications of how obligation parameters are handled.
//
boolean methodHasCloseInName = false;
if (INFER_CLOSE_METHODS) {
SplitCamelCaseIdentifier splitter = new SplitCamelCaseIdentifier(xmethod.getName());
methodHasCloseInName = splitter.split().contains("close");
}
for (int i = 0; i < xmethod.getNumParams(); i++) {
Obligation obligationType = paramObligationTypes[i];
if (obligationType != null) {
if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
//
// Calling this method deletes a parameter obligation
// and
// creates a new obligation for the object returned by
// the method.
//
handleWillCloseWhenClosed(xmethod, obligationType);
} else if (xmethod.getParameterAnnotation(i, willClose) != null) {
addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
ObligationPolicyDatabaseEntryType.STRONG);
sawAnnotationsInApplicationCode = true;
} else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
// No database entry needs to be added
sawAnnotationsInApplicationCode = true;
} else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
// Method has "close" in its name.
// Assume that it deletes the obligation.
addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
ObligationPolicyDatabaseEntryType.STRONG);
} else {
/*
* // Interesting case: we have a parameter which is // an
* Obligation type, but no annotation or other indication //
* what is done by the method with the obligation. // We'll
* create a "weak" database entry deleting the //
* obligation. If strict checking is performed, // weak
* entries are ignored.
*/
if (xmethod.getName().equals("<init>") || xmethod.isStatic()
|| xmethod.getName().toLowerCase().indexOf("close") >= 0
|| xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
ObligationPolicyDatabaseEntryType.WEAK);
}
}
}
}
示例6: modelArguments
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void modelArguments(Location location) throws DataflowAnalysisException {
// Model arguments to called method
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
XMethod calledMethod = XFactory.createXMethod(inv, cpg);
SignatureParser sigParser = new SignatureParser(calledMethod.getSignature());
if (sigParser.getNumParameters() == 0)
return;
ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location);
if (!vnaFrame.isValid()) {
// AnalysisContext.logError("bad vna frame in " + xmethod +
// " at location " + location.getHandle().getPosition() +
// " calling " + calledMethod);
return;
}
if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledMethod))
return;
for (int param = 0; param < calledMethod.getNumParams(); param++) {
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, param,
typeQualifierValue);
boolean interproc = false;
if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
// See if there's an entry for this parameter
// in the interprocedural type qualifier database.
TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
tqa = tqdb.getParameter(calledMethod.getMethodDescriptor(), param, typeQualifierValue);
if (tqa != null) {
interproc = true;
}
}
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
ValueNumber vn = vnaFrame.getArgument(inv, cpg, param, sigParser);
SourceSinkInfo info = new SourceSinkInfo(SourceSinkType.ARGUMENT_TO_CALLED_METHOD, location, vn, when);
info.setParameter(param);
info.setInterproc(interproc);
registerSourceSink(info);
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:48,代码来源:BackwardTypeQualifierDataflowAnalysis.java