Example usage for org.eclipse.jdt.core Signature getThrownExceptionTypes

List of usage examples for org.eclipse.jdt.core Signature getThrownExceptionTypes

Introduction

In this page you can find the example usage for org.eclipse.jdt.core Signature getThrownExceptionTypes.

Prototype

public static String[] getThrownExceptionTypes(String methodSignature) throws IllegalArgumentException 

Source Link

Document

Extracts the thrown exception type signatures from the given method signature if any The method signature is expected to be dot-based.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryMethod.java

License:Open Source License

public String[] getExceptionTypes() throws JavaModelException {
    if (this.exceptionTypes == null) {
        IBinaryMethod info = (IBinaryMethod) getElementInfo();
        char[] genericSignature = info.getGenericSignature();
        if (genericSignature != null) {
            char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
            this.exceptionTypes = Signature.getThrownExceptionTypes(new String(dotBasedSignature));
        }/*from   w ww .  j av a 2  s.  c  o  m*/
        if (this.exceptionTypes == null || this.exceptionTypes.length == 0) {
            char[][] eTypeNames = info.getExceptionTypeNames();
            if (eTypeNames == null || eTypeNames.length == 0) {
                this.exceptionTypes = CharOperation.NO_STRINGS;
            } else {
                eTypeNames = ClassFile.translatedNames(eTypeNames);
                this.exceptionTypes = new String[eTypeNames.length];
                for (int j = 0, length = eTypeNames.length; j < length; j++) {
                    // 1G01HRY: ITPJCORE:WINNT - method.getExceptionType not in correct format
                    int nameLength = eTypeNames[j].length;
                    char[] convertedName = new char[nameLength + 2];
                    System.arraycopy(eTypeNames[j], 0, convertedName, 1, nameLength);
                    convertedName[0] = 'L';
                    convertedName[nameLength + 1] = ';';
                    this.exceptionTypes[j] = new String(convertedName);
                }
            }
        }
    }
    return this.exceptionTypes;
}

From source file:com.siteview.mde.internal.ui.search.dependencies.CalculateUsesOperation.java

License:Open Source License

protected void findReferences(IType type, Set pkgs, boolean binary) throws JavaModelException {
    if (type == null)
        return;/*  w w w.j  av  a 2 s . co  m*/
    // ignore private classes
    if (Flags.isPrivate(type.getFlags()))
        return;

    IMethod[] methods = type.getMethods();
    for (int i = 0; i < methods.length; i++) {
        if (!Flags.isPrivate(methods[i].getFlags())) {
            String methodSignature = methods[i].getSignature();
            addPackages(Signature.getThrownExceptionTypes(methodSignature), pkgs, type, binary);
            addPackages(Signature.getParameterTypes(methodSignature), pkgs, type, binary);
            addPackage(Signature.getReturnType(methodSignature), pkgs, type, binary);
        }
    }
    IField[] fields = type.getFields();
    for (int i = 0; i < fields.length; i++)
        if (!Flags.isPrivate(fields[i].getFlags()))
            addPackage(fields[i].getTypeSignature(), pkgs, type, binary);
    addPackage(type.getSuperclassTypeSignature(), pkgs, type, binary);
    addPackages(type.getSuperInterfaceTypeSignatures(), pkgs, type, binary);

    // make sure to check sub classes defined in the class
    IType[] subTypes = type.getTypes();
    for (int i = 0; i < subTypes.length; i++) {
        findReferences(subTypes[i], pkgs, binary);
    }
}

From source file:org.eclipse.pde.internal.ui.search.dependencies.CalculateUsesOperation.java

License:Open Source License

protected void findReferences(IType type, Set<String> pkgs, boolean binary) throws JavaModelException {
    if (type == null)
        return;// w  w  w.  j a v  a  2  s  .  c  o  m
    // ignore private classes
    if (Flags.isPrivate(type.getFlags()))
        return;

    IMethod[] methods = type.getMethods();
    for (int i = 0; i < methods.length; i++) {
        if (!Flags.isPrivate(methods[i].getFlags())) {
            String methodSignature = methods[i].getSignature();
            addPackages(Signature.getThrownExceptionTypes(methodSignature), pkgs, type, binary);
            addPackages(Signature.getParameterTypes(methodSignature), pkgs, type, binary);
            addPackage(Signature.getReturnType(methodSignature), pkgs, type, binary);
        }
    }
    IField[] fields = type.getFields();
    for (int i = 0; i < fields.length; i++)
        if (!Flags.isPrivate(fields[i].getFlags()))
            addPackage(fields[i].getTypeSignature(), pkgs, type, binary);
    addPackage(type.getSuperclassTypeSignature(), pkgs, type, binary);
    addPackages(type.getSuperInterfaceTypeSignatures(), pkgs, type, binary);

    // make sure to check sub classes defined in the class
    IType[] subTypes = type.getTypes();
    for (int i = 0; i < subTypes.length; i++) {
        findReferences(subTypes[i], pkgs, binary);
    }
}