Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331905 - Allow finding Ecore resources even if no ResourceSet given
Summary: Allow finding Ecore resources even if no ResourceSet given
Status: RESOLVED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Query2 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-06 09:59 EST by Axel Uhl CLA
Modified: 2010-12-07 00:44 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Uhl CLA 2010-12-06 09:59:45 EST
Build Identifier: CVS Head of 2010-12-06

The current EmfHelper implementation fails with an NPE if the QueryContext doesn't provide a valid ResourceSet. Finding Ecore resources through the package registry may, however, still be possible if a new ResourceSetImpl were created in this case. This may be solved using the following patch:

org.eclipse.emf.query2/src/org/eclipse/emf/query2/internal/shared/EmfHelper.java
--- org.eclipse.emf.query2/src/org/eclipse/emf/query2/internal/shared/EmfHelper.java    2010-11-17 11:12:24.686748700 +0100
+++ org.eclipse.emf.query2/src/org/eclipse/emf/query2/internal/shared/EmfHelper
.java   2010-12-06 15:32:55.362157900 +0100
@@ -69,6 +69,8 @@
                        if (rsImpl.getURIResourceMap() == null) {
                                rsImpl.setURIResourceMap(new HashMap<URI, Resource>());
                        }
+               } else if (this.rs == null) {
+                   this.rs = new ResourceSetImpl(); // allows at least for retrieving metamodel URIs
                }
                //              this.createDirtyIndex();
                this.index = index;

Reproducible: Always
Comment 1 saurav sarkar CLA 2010-12-07 00:44:43 EST
Hi Axel,

Thanks for raising it.
I have provided the fix as you mentioned.

I have submitted TestQueryBugs class which provides a test for the above scenario.

Cheers,
Saurav