-
Notifications
You must be signed in to change notification settings - Fork 30
feat: add capability to skip loading the AST from storage #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,11 @@ | |
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.eclipse.emf.common.notify.Adapter; | ||
| import org.eclipse.emf.common.util.BasicEList; | ||
| import org.eclipse.emf.common.util.URI; | ||
| import org.eclipse.emf.ecore.EObject; | ||
| import org.eclipse.emf.ecore.InternalEObject; | ||
| import org.eclipse.emf.ecore.impl.MinimalEObjectImpl.Container; | ||
| import org.eclipse.emf.ecore.resource.Resource; | ||
| import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; | ||
| import org.eclipse.emf.ecore.util.EcoreUtil; | ||
|
|
@@ -123,8 +125,6 @@ public void loadResource(final Resource resource) throws IOException { | |
| if (uri != null && uri.isHierarchical() && !uri.isRelative()) { | ||
| baseURI = uri; | ||
| } | ||
| boolean installDerivedState = ResourceSetOptions.installDerivedState(resourceSet); // must be read before readCompressedInt, see HACK comment inside | ||
| // readCompressedInt | ||
| int size = readCompressedInt(); | ||
| if (!installDerivedState && size == 2) { // the InfererenceContainer is always in the second slot | ||
| size--; | ||
|
|
@@ -153,6 +153,8 @@ public void loadResource(final Resource resource) throws IOException { | |
| private final ITraceSet traceSet; | ||
|
|
||
| private ResourceLoadMode mode; | ||
| private boolean installDerivedState; | ||
| private boolean skipModel; | ||
|
|
||
| public DirectLinkingResourceStorageLoadable(final InputStream in, final boolean loadNodeModel, final boolean splitContents, final ITraceSet traceSet) { | ||
| super(in, loadNodeModel); | ||
|
|
@@ -182,6 +184,8 @@ public void loadIntoResource(final StorageAwareResource resource, final Resource | |
| throw new IllegalArgumentException("Incompatible resource load mode: " + loadMode.instruction(Constituent.RESOURCE)); //$NON-NLS-1$ | ||
| } | ||
| this.mode = loadMode; | ||
| this.installDerivedState = ResourceSetOptions.installDerivedState(resource.getResourceSet()); | ||
| this.skipModel = ResourceSetOptions.skipModel(resource.getResourceSet()); | ||
| traceSet.started(ResourceLoadStorageEvent.class, resource.getURI(), loadMode); | ||
| try { | ||
| super.loadIntoResource(resource); | ||
|
|
@@ -223,7 +227,12 @@ protected void loadEntries(final StorageAwareResource resource, final ZipInputSt | |
| LOG.warn("Proxying of resource contents is not supported: " + resource.getURI()); //$NON-NLS-1$ | ||
| // fall through | ||
| case LOAD: | ||
| readContents(resource, new NonLockingBufferInputStream(zipIn)); | ||
| if (!skipModel) { | ||
| readContents(resource, new NonLockingBufferInputStream(zipIn)); | ||
| } else { | ||
| // TODO I need to put something in the resource. Don't want to get into proxying yet (might have to). | ||
| addFakeModel(resource); | ||
| } | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -286,6 +295,15 @@ protected void loadEntries(final StorageAwareResource resource, final ZipInputSt | |
| } | ||
| } | ||
|
|
||
| private void addFakeModel(final StorageAwareResource resource) { | ||
| InternalEObject[] values = new InternalEObject[] {new Container()}; | ||
| BasicEList<InternalEObject> internalEObjectList = new BasicEList<InternalEObject>(); // NOPMD LooseCoupling | ||
| internalEObjectList.setData(1, values); | ||
| @SuppressWarnings("unchecked") | ||
| InternalEList<InternalEObject> internalEObjects = (InternalEList<InternalEObject>) (InternalEList<?>) resource.getContents(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about adding subclassed BasicEList which throws an UnsoportedOperationException in all operations? That way we are sure that we are not getting wrong results because we access a partially loaded resource.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that's not going to work: this list is returned from Resource.getContents(), the inference container is contained in it |
||
| internalEObjects.addAllUnique(internalEObjectList); | ||
| } | ||
|
|
||
| /** | ||
| * Read the node model from the given input stream. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.