|
Re: Implementing EMF Query2 Indexing [message #691306 is a reply to message #691070] |
Fri, 01 July 2011 07:51 |
saurav sarkar Messages: 428 Registered: July 2009 |
Senior Member |
|
|
Hi Roshan,
Comments below
Roshan Soni wrote on Thu, 30 June 2011 12:28Hi,
I'm trying to implement indexing on my EMF domain model. I am following the developer guide here: http://wiki.eclipse.org/EMF/Query2/DevGuide
1. To start off I created an eCore model (ccnet) and then also generated the edit and editor plugins using the genmodel.
2. I created a new plugin called com..index and I added the dependencies from step 1 in the guide: Note that the dependencies for index are in the org.eclipse.emf.query2 package and not the query package as in the guide.
org.eclipse.emf.query2.index.ui
org.eclipse.emf.query2.index
3. I added the extension point as in step 3 to support my file extension, ccnet:
<extension
point="org.eclipse.emf.ecore.extension_parser">
<parser
class="com.index.builder.CcnetIndexFactory"
type="ccnet">
</parser>
</extension>
The class here is supposed to be the Factory class which is supposed to create your type of resource.If you feel it is XMI or XML you can put XMIResourceFactoryImpl and XMLResourceFactoryImpl.
Quote:
4. I implemented the Resource.Factory class for the QueryBuilder extension point as follows:
public class CcnetIndexFactory implements org.eclipse.emf.ecore.resource.Resource.Factory {
@Override
public Resource createResource(final URI uri) {
Index indexFactory = IndexFactory.getInstance();
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, true));
} catch (Exception e) {
System.out.println(e);
}
}
});
return null;
}
}
4. After launching I added the QueryIndexBuilder and QueryIndexNature to my test project.
You need not call any indexing API from yourself.The Index builder will automatically visit your type of files in your workspace and index it.
Quote:
5. When I try to load the editor I get a stack overflow exception, when I debug and step through the program i can see that the CcnetIndexFactory.createResource(URI), just keeps getting called in an infinite loop.
I'm surely setting something up incorrectly, but I'm not sure what I'm doing wrong.
Correcting the above points will solve your problem
Quote:
Any help is appreciated.
Thanks,
Roshan
cheers,
Saurav
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
|
|
|
Powered by
FUDForum. Page generated in 0.02341 seconds