Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EMF/Query2/DevGuide
EMF Query2 Developer Guide
Installation
Overview of Query2
Query2 provides easy mechanism to query emf metadata with minimal loading of resources. Query2 has an in-built indexing mechanism which indexes types, resources and references. This data is used during query execution and hence avoiding loading of resources wherever needed. Hence, if you want to use query2, you are mandatorily required to setup indexing. After that you can use it execute queries. We will see how to set it up in later sections. Query2 also provides you different ways to specify queries. We will see them in coming sections.
Using Query2
Setting up Indexes
Step 1 Create dependency to index plugin: Add dependency to the plugins
- org.eclipse.emf.query.index.ui
- org.eclipse.emf.query.index
Step 2 Using Indexing api: To index the resources, you can use IndexFactory as the starting point. It is a singleton class, which can keep the index for your complete workspace. Following is code sample to index new resource:
IndexFactory.getInstance().executeUpdateCommand( new UpdateCommandAdapter() { @Override public void execute(final IndexUpdater updater) { final ResourceIndexer indexer = new ResourceIndexer(); final ResourceSet rs = new ResourceSetImpl(); try { indexer.resourceChanged(updater, rs.getResource(URI.createPlatformResourceURI(resource.getFullPath().toString(), true), true)); } catch (Exception e) { // Put your logging here } } });