示例#1
0
 public byte[] getBytes() throws EGLModelException {
   EGLElement pkg = (EGLElement) getParent();
   if (pkg instanceof EglarPackageFragment) {
     EglarPackageFragmentRoot root = (EglarPackageFragmentRoot) pkg.getParent();
     ZipFile zip = null;
     try {
       zip = root.getJar();
       String entryName =
           CharOperation.concatWith(((PackageFragment) pkg).names, getElementName(), '/');
       ZipEntry ze = zip.getEntry(entryName);
       if (ze != null) {
         return org.eclipse.edt.ide.core.internal.model.util.Util.getZipEntryByteContent(ze, zip);
       }
       throw new EGLModelException(
           new EGLModelStatus(IEGLModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
     } catch (IOException ioe) {
       throw new EGLModelException(ioe, IEGLModelStatusConstants.IO_EXCEPTION);
     } catch (CoreException e) {
       if (e instanceof EGLModelException) {
         throw (EGLModelException) e;
       } else {
         throw new EGLModelException(e);
       }
     } finally {
       EGLModelManager.getEGLModelManager().closeZipFile(zip);
     }
   } else {
     IFile file = (IFile) getResource();
     return Util.getResourceContentsAsByteArray(file);
   }
 }
示例#2
0
  @Override
  protected void buildStructure(OpenableElementInfo info, IProgressMonitor monitor)
      throws EGLModelException {
    // Note: This method seems to be exactly the same as the one it overrides in Openable

    if (monitor != null && monitor.isCanceled()) return;

    // remove existing (old) infos
    removeInfo();

    HashMap newElements = new HashMap(11);
    info.setIsStructureKnown(generateInfos(info, monitor, newElements, getResource()));
    EGLModelManager.getEGLModelManager().getElementsOutOfSynchWithBuffers().remove(this);
    for (Iterator iter = newElements.keySet().iterator(); iter.hasNext(); ) {
      IEGLElement key = (IEGLElement) iter.next();
      Object value = newElements.get(key);
      EGLModelManager.getEGLModelManager().putInfo(key, value);
    }
    // add the info for this at the end, to ensure that a getInfo cannot reply null in case the LRU
    // cache needs
    // to be flushed. Might lead to performance issues.
    // see PR 1G2K5S7: ITPJCORE:ALL - NPE when accessing source for a binary type
    EGLModelManager.getEGLModelManager().putInfo(this, info);
  }
示例#3
0
  @Override
  protected boolean generateInfos(
      OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
      throws EGLModelException {
    // put the info now, because getting the contents requires it
    EGLModelManager.getEGLModelManager().putInfo(this, info);
    ClassFileElementInfo unitInfo = (ClassFileElementInfo) info;

    // generate structure
    IRFileStructureRequestor requestor = new IRFileStructureRequestor(this, unitInfo, newElements);
    BinaryElementParser parser = new BinaryElementParser(requestor, project);
    parser.parseDocument(this, true);
    //		if (isWorkingCopy()) {
    //			EGLFile original = (EGLFile) getOriginalElement();
    //			// might be IResource.NULL_STAMP if original does not exist
    //			unitInfo.fTimestamp = ((IFile) original.getResource()).getModificationStamp();
    //		}
    return unitInfo.isStructureKnown();
  }