use of org.eclipse.jdt.internal.core.JavaModelManager in project xtext-eclipse by eclipse.
the class ZipFileAwareTrace method getContents.
@Override
public InputStream getContents(SourceRelativeURI uri, IProject project) {
// inspired by org.eclipse.jdt.internal.core.JarEntryFile.getContents()
JavaModelManager modelManager = JavaModelManager.getJavaModelManager();
ZipFile zipFile = null;
try {
zipFile = modelManager.getZipFile(zipFilePath);
ZipEntry zipEntry = zipFile.getEntry(uri.getURI().toString());
if (zipEntry != null) {
byte[] contents = Util.getZipEntryByteContent(zipEntry, zipFile);
return new ByteArrayInputStream(contents);
}
} catch (IOException e) {
log.debug("Could not read zip file " + uri, e);
} catch (CoreException e) {
log.debug("Could not read zip file " + uri, e);
} finally {
if (zipFile != null) {
modelManager.closeZipFile(zipFile);
}
}
return null;
}
Aggregations