Example usage for org.eclipse.jdt.core.util IConstantPoolEntry getMethodDescriptor

List of usage examples for org.eclipse.jdt.core.util IConstantPoolEntry getMethodDescriptor

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.util IConstantPoolEntry getMethodDescriptor.

Prototype

char[] getMethodDescriptor();

Source Link

Document

Returns the method descriptor value for a CONSTANT_Methodref or CONSTANT_InterfaceMethodref type entry.

Usage

From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.NamingAdvisor.java

License:Open Source License

private void addClassFile(IClassFile classFile) {
    IClassFileReader reader = ToolFactory.createDefaultClassFileReader(classFile,
            IClassFileReader.CONSTANT_POOL | IClassFileReader.METHOD_INFOS);
    IConstantPool constants = reader.getConstantPool();
    for (int i = 0, max = constants.getConstantPoolCount(); i < max; i++) {
        switch (constants.getEntryKind(i)) {
        case IConstantPoolConstant.CONSTANT_Class: {
            IConstantPoolEntry constant = constants.decodeEntry(i);
            addClass(new String(constant.getClassInfoName()).replace('/', '.'));
            break;
        }/*from   w  ww  . j av a 2  s  .  c om*/
        case IConstantPoolConstant.CONSTANT_Fieldref: {
            IConstantPoolEntry constant = constants.decodeEntry(i);
            addClassSig(constant.getFieldDescriptor());
            break;
        }
        case IConstantPoolConstant.CONSTANT_Methodref: {
            IConstantPoolEntry constant = constants.decodeEntry(i);
            addMethod(new String(constant.getClassName()), new String(constant.getMethodName()),
                    constant.getMethodDescriptor());
            break;
        }
        case IConstantPoolConstant.CONSTANT_InterfaceMethodref: {
            IConstantPoolEntry constant = constants.decodeEntry(i);
            addMethod(new String(constant.getClassName()), new String(constant.getMethodName()),
                    constant.getMethodDescriptor());
            break;
        }
        default:
        }
    }

    // Add the method parameter / return types
    for (IMethodInfo method : reader.getMethodInfos()) {
        for (char[] p : Signature.getParameterTypes(method.getDescriptor())) {
            addClassSig(p);
        }
        addClassSig(Signature.getReturnType(method.getDescriptor()));
    }
}