/*
 * fb-contrib - Auxiliary detectors for Java programs
 * Copyright (C) 2009-2016 Jean-Noel Rouvignac
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.mebigfatguy.fbcontrib.utils;

import edu.umd.cs.findbugs.ba.XClass;
import edu.umd.cs.findbugs.ba.XMethod;
import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
import edu.umd.cs.findbugs.classfile.ClassDescriptor;
import edu.umd.cs.findbugs.classfile.DescriptorFactory;
import edu.umd.cs.findbugs.classfile.Global;

/**
 * Utility class for XClass and XMethod classes.
 */
public class XClassUtils {

    /**
     * Returns an <code>XClass</code> object for the given
     * <code>ClassDescriptor</code> object.
     * 
     * @param classDesc
     *            the class descriptor for which to find the XClass object
     * @return the class
     * @throws AssertionError
     *             if the analysis of the class failed
     */
    public XClass getXClass(final ClassDescriptor classDesc) throws AssertionError {
        try {
            return Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc);
        } catch (CheckedAnalysisException e) {
            AssertionError ae = new AssertionError("Can't find ClassInfo for " + classDesc);
            ae.initCause(e);
            throw (ae);
        }
    }

    /**
     * Returns an <code>XClass</code> object for the given slashed class name.
     * 
     * @param slashedClassName
     *            the class name for which to find the XClass object
     * @return the class
     * @throws AssertionError
     *             if the analysis of the class failed
     */
    public XClass getXClass(String slashedClassName) {
        return getXClass(DescriptorFactory.createClassDescriptor(slashedClassName));
    }

    /**
     * Looks for the method up the class hierarchy.
     * 
     * @param xClass
     *            the class where to look for the method
     * @param methodName
     *            the name of the method to look for
     * @param methodSig
     *            the signature of the method to look for
     * @return the method
     */
    public XMethod getXMethod(final XClass xClass, final String methodName, final String methodSig) {
        if (xClass == null) {
            return null;
        }

        XMethod xMethod = xClass.findMethod(methodName, methodSig, false);
        if (xMethod == null) {
            ClassDescriptor descriptor = xClass.getSuperclassDescriptor();
            if (descriptor != null) {
                final XClass superClass = getXClass(descriptor);
                xMethod = getXMethod(superClass, methodName, methodSig);
            }
        }
        return xMethod;
    }

    /**
     * Looks for the method up the class hierarchy.
     * 
     * @param slashedClassName
     *            the class slashed name where to look for the method
     * @param methodName
     *            the name of the method to look for
     * @param methodSig
     *            the signature of the method to look for
     * @return the method
     */
    public XMethod getXMethod(String slashedClassName, String methodName, String methodSig) {
        final XClass xClass = getXClass(slashedClassName);
        return getXMethod(xClass, methodName, methodSig);
    }

}

@@ -99,18 +99,17 @@
 ignac%0A *
- 
 %0A
+
  * This 
@@ -359,25 +359,24 @@
  version.%0A *
- 
 %0A * This lib
@@ -619,17 +619,16 @@
 ails.%0A *
- 
 %0A * You 
@@ -1263,16 +1263,132 @@
 tils %7B%0A%0A
+    /**%0A     * private to enforce the helper nature of this static class%0A     */%0A    private XClassUtils() %7B%0A    %7D%0A%0A
     /**%0A
@@ -1445,23 +1445,16 @@
 he given
-%0A     *
  %3Ccode%3EC
@@ -1481,33 +1481,32 @@
 %3E object.%0A     *
- 
 %0A     * @param c
@@ -1710,32 +1710,39 @@
   */%0A    public 
+static 
 XClass getXClass
@@ -2196,33 +2196,32 @@
 ass name.%0A     *
- 
 %0A     * @param s
@@ -2434,16 +2434,23 @@
  public 
+static 
 XClass g
@@ -2635,33 +2635,32 @@
 ierarchy.%0A     *
- 
 %0A     * @param x
@@ -2919,32 +2919,39 @@
   */%0A    public 
+static 
 XMethod getXMeth
@@ -3569,17 +3569,16 @@
 .%0A     *
- 
 %0A     * 
@@ -3857,32 +3857,32 @@
  method%0A     */%0A
-
     public XMeth
@@ -3876,16 +3876,23 @@
  public 
+static 
 XMethod 

make XClassUtils a static access class