Example usage for org.eclipse.jdt.internal.core Openable getParent

List of usage examples for org.eclipse.jdt.internal.core Openable getParent

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core Openable getParent.

Prototype

@Override
public IJavaElement getParent() 

Source Link

Usage

From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java

License:Open Source License

/**
* Create a type info from the given class file in a jar and adds it to the given list of infos.
*///from  ww w .j a va 2  s .  c o  m
protected IBinaryType createInfoFromClassFileInJar(Openable classFile) {
    PackageFragment pkg = (PackageFragment) classFile.getParent();
    String classFilePath = Util.concatWith(pkg.names, classFile.getElementName(), '/');
    IBinaryType info = null;
    java.util.zip.ZipFile zipFile = null;
    try {
        zipFile = ((JarPackageFragmentRoot) pkg.getParent()).getJar();
        info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(zipFile, classFilePath);
    } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) {
        if (TypeHierarchy.DEBUG) {
            e.printStackTrace();
        }
        return null;
    } catch (java.io.IOException e) {
        if (TypeHierarchy.DEBUG) {
            e.printStackTrace();
        }
        return null;
    } catch (CoreException e) {
        if (TypeHierarchy.DEBUG) {
            e.printStackTrace();
        }
        return null;
    } finally {
        JavaModelManager.getJavaModelManager().closeZipFile(zipFile);
    }
    this.infoToHandle.put(info, classFile);
    return info;
}