|
25 | 25 | import org.apache.logging.log4j.LogManager; |
26 | 26 | import org.apache.logging.log4j.Logger; |
27 | 27 | import org.eclipse.emf.common.notify.Adapter; |
| 28 | +import org.eclipse.emf.common.util.BasicEList; |
28 | 29 | import org.eclipse.emf.common.util.URI; |
29 | 30 | import org.eclipse.emf.ecore.EObject; |
30 | 31 | import org.eclipse.emf.ecore.InternalEObject; |
| 32 | +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl.Container; |
31 | 33 | import org.eclipse.emf.ecore.resource.Resource; |
32 | 34 | import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; |
33 | 35 | import org.eclipse.emf.ecore.util.EcoreUtil; |
@@ -123,8 +125,6 @@ public void loadResource(final Resource resource) throws IOException { |
123 | 125 | if (uri != null && uri.isHierarchical() && !uri.isRelative()) { |
124 | 126 | baseURI = uri; |
125 | 127 | } |
126 | | - boolean installDerivedState = ResourceSetOptions.installDerivedState(resourceSet); // must be read before readCompressedInt, see HACK comment inside |
127 | | - // readCompressedInt |
128 | 128 | int size = readCompressedInt(); |
129 | 129 | if (!installDerivedState && size == 2) { // the InfererenceContainer is always in the second slot |
130 | 130 | size--; |
@@ -153,6 +153,8 @@ public void loadResource(final Resource resource) throws IOException { |
153 | 153 | private final ITraceSet traceSet; |
154 | 154 |
|
155 | 155 | private ResourceLoadMode mode; |
| 156 | + private boolean installDerivedState; |
| 157 | + private boolean skipModel; |
156 | 158 |
|
157 | 159 | public DirectLinkingResourceStorageLoadable(final InputStream in, final boolean loadNodeModel, final boolean splitContents, final ITraceSet traceSet) { |
158 | 160 | super(in, loadNodeModel); |
@@ -182,6 +184,8 @@ public void loadIntoResource(final StorageAwareResource resource, final Resource |
182 | 184 | throw new IllegalArgumentException("Incompatible resource load mode: " + loadMode.instruction(Constituent.RESOURCE)); //$NON-NLS-1$ |
183 | 185 | } |
184 | 186 | this.mode = loadMode; |
| 187 | + this.installDerivedState = ResourceSetOptions.installDerivedState(resource.getResourceSet()); |
| 188 | + this.skipModel = ResourceSetOptions.skipModel(resource.getResourceSet()); |
185 | 189 | traceSet.started(ResourceLoadStorageEvent.class, resource.getURI(), loadMode); |
186 | 190 | try { |
187 | 191 | super.loadIntoResource(resource); |
@@ -223,7 +227,12 @@ protected void loadEntries(final StorageAwareResource resource, final ZipInputSt |
223 | 227 | LOG.warn("Proxying of resource contents is not supported: " + resource.getURI()); //$NON-NLS-1$ |
224 | 228 | // fall through |
225 | 229 | case LOAD: |
226 | | - readContents(resource, new NonLockingBufferInputStream(zipIn)); |
| 230 | + if (!skipModel) { |
| 231 | + readContents(resource, new NonLockingBufferInputStream(zipIn)); |
| 232 | + } else { |
| 233 | + // TODO I need to put something in the resource. Don't want to get into proxying yet (might have to). |
| 234 | + addFakeModel(resource); |
| 235 | + } |
227 | 236 | break; |
228 | 237 | } |
229 | 238 |
|
@@ -286,6 +295,15 @@ protected void loadEntries(final StorageAwareResource resource, final ZipInputSt |
286 | 295 | } |
287 | 296 | } |
288 | 297 |
|
| 298 | + private void addFakeModel(final StorageAwareResource resource) { |
| 299 | + InternalEObject[] values = new InternalEObject[] {new Container()}; |
| 300 | + BasicEList<InternalEObject> internalEObjectList = new BasicEList<InternalEObject>(); // NOPMD LooseCoupling |
| 301 | + internalEObjectList.setData(1, values); |
| 302 | + @SuppressWarnings("unchecked") |
| 303 | + InternalEList<InternalEObject> internalEObjects = (InternalEList<InternalEObject>) (InternalEList<?>) resource.getContents(); |
| 304 | + internalEObjects.addAllUnique(internalEObjectList); |
| 305 | + } |
| 306 | + |
289 | 307 | /** |
290 | 308 | * Read the node model from the given input stream. |
291 | 309 | * |
|
0 commit comments