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


Java XMethod.getNumParams方法代码示例

本文整理汇总了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();
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:34,代码来源:TypeQualifierApplications.java

示例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");
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:39,代码来源:Analysis.java

示例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);
            }
        }

        
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:69,代码来源:BuildObligationPolicyDatabase.java

示例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);

    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:48,代码来源:BackwardTypeQualifierDataflowAnalysis.java

示例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);
            }
        }
    }


}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:63,代码来源:BuildObligationPolicyDatabase.java

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


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