Using PatternLanguage model instances within Pattern Matcher API as Matcher?

77 views
Skip to first unread message

Emre Taspolatoglu

unread,
Apr 25, 2013, 4:06:03 PM4/25/13
to incquer...@googlegroups.com
Hello there! After a little research in the source code of EMF-Incquery, I have decided to ask my question here, since I somehow couldn't bring two pieces together.

What I want to do is, to use an instance of PatternLanguage.ecore filled with valid patterns to query EMF model instances. (Instead of using *.eiq files directly on model instances) I believe, since it is possible to generate *eiq-code from PatternLanguage.ecore instances (thanks to Xtext, as described in the below link), it should also be possible to directly query an EMF instance via instances of PatternLanguage.ecore, since like sad, they also can contain valid patterns.

http://www.eclipse.org/forums/index.php/t/480168/

So I was looking into the two parts of the Query Explorer UI, how EMF-IncQuery registers patterns and loads models:

First of all, we register all the valid patterns from *.eiq into the pattern registry. By choosing the action from the editor menu, EMF-IncQuery calls -eventually- RuntimeMatcherRegistrator for this function, which then registers all the valid patterns from the patternmodel file into the registry. Secondly, we load our model instance which should be queried. By clicking the green load button or choosing between Load Resouce or Load ResourceSet; EMF-IncQuery calls LoadResouceHandler or LoadResourceSetHandler.

But I unfortunately couldn't find how in the end EMF-IncQuery brings these two parts together, where we get the results of our query patterns. Where does it happen? Or do I even need to think about this, when I could actually use PatternMatcher API directly?

I hope, that how I thought to achieve my goal is -first of all- possible. So, can an instance of PatternLanguage.ecore, be it either a dynamic instance or an example model, be used within the EMF-IncQuery Pattern Matcher API? If so, how to generate a Matcher from the mentioned patternlanguage instances? I would be very glad, if you could point me to the right direction.

Thanks a lot,
Emre

István Ráth

unread,
Apr 26, 2013, 1:22:06 AM4/26/13
to incquer...@googlegroups.com
Hi Emre,

On Thursday, 25 April 2013 22:06:03 UTC+2, Emre Taspolatoglu wrote:

But I unfortunately couldn't find how in the end EMF-IncQuery brings these two parts together, where we get the results of our query patterns. Where does it happen? Or do I even need to think about this, when I could actually use PatternMatcher API directly?

Don't bother with the internals of the Query Explorer, use the Advanced API instead.

The source code sample on this page is also featured in the "headless" example mentioned on the top of the page and found in Git.

Note however, that we are currently working on an API refactoring in preparation for our first 0.7 release, so things may change until July.
 
cheers
Istvan

Emre Taspolatoglu

unread,
Apr 26, 2013, 4:19:57 AM4/26/13
to incquer...@googlegroups.com
Hello Istvan,

thanks for the tip. I was kind of lost in the in the Query Explorer code and was trying to come up with an own API. But this looks definitely easier and more promising.

So using the Advanced API, it is possible to use any kind of pattern model representations, including the .xmi instances of PatternLanguage.ecore?

I see that in the org.eclipse.incquery.application.common example, the IncQueryHeadlessAdvanced.java has this line, where the pattern models are being loaded from a file, more interestingly from a hidden .xmi file called "globalEiqModel.xmi" as follows:

ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createPlatformPluginURI("headlessQueries.incquery/queries/globalEiqModel.xmi", false);
Resource patternResource = resourceSet.getResource(fileURI, true);

I believe, that this means, that every .xmi file with valid patterns to search for, could be used as a pattern model resource?

FYI: I am seeing two errors in the example application code.

1.) IncQueryHeadless.java, line 215:

        IObservableSet set = IncQueryObservables.observeMatchesAsSet(factory, engine);

Error :The method observeMatchesAsSet(IMatcherFactory<Matcher>, Notifier) in the type IncQueryObservables is not applicable for the arguments (EPackageMatcherFactory,
 IncQueryEngine)

2.) IncQueryHeadlessAdvanced.java, line 163:

        matcher.addCallbackOnMatchUpdate(new IMatchUpdateListener<IPatternMatch>() {

Error: The method addCallbackOnMatchUpdate(IMatchUpdateListener<capture#13-of ? extends IPatternMatch>, boolean) in the type IncQueryMatcher<capture#13-of ? extends
 IPatternMatch> is not applicable for the arguments (new IMatchUpdateListener<IPatternMatch>(){}, boolean)

Best regards,
Emre

Istvan Rath

unread,
Apr 26, 2013, 4:24:17 AM4/26/13
to EMF-IncQuery Users on behalf of Emre Taspolatoglu
Hi,

about the compile errors - which IncQuery version are you using?

So using the Advanced API, it is possible to use any kind of pattern model representations, including the .xmi instances of PatternLanguage.ecore?

Yes.


I see that in the org.eclipse.incquery.application.common example, the IncQueryHeadlessAdvanced.java has this line, where the pattern models are being loaded from a file, more interestingly from a hidden .xmi file called "globalEiqModel.xmi" as follows:

ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createPlatformPluginURI("headlessQueries.incquery/queries/globalEiqModel.xmi", false);
Resource patternResource = resourceSet.getResource(fileURI, true);

I believe, that this means, that every .xmi file with valid patterns to search for, could be used as a pattern model resource?
Yes.

cheers
Istvan

Emre Taspolatoglu

unread,
Apr 26, 2013, 5:24:09 AM4/26/13
to incquer...@googlegroups.com
Hello again, thanks a lot for the quick responses!


On Friday, April 26, 2013 10:24:17 AM UTC+2, István Ráth wrote:
Hi,

about the compile errors - which IncQuery version are you using?

I am using the EMF-IncQuery SDK with the version number 0.7.0.201303081734, downloaded and installed from the Eclipse Marketplace. Should I have better used the nightly builds, from GIT etc?

Great. That was what I was looking for. So I could skip the creation of the *.eiq files and use directly instances of the PatternLanguage.ecore as *.xmi files for the generic API.

cheers
Istvan

Istvan Rath

unread,
Apr 26, 2013, 8:27:19 AM4/26/13
to EMF-IncQuery Users on behalf of Emre Taspolatoglu
Hi,

I am using the EMF-IncQuery SDK with the version number 0.7.0.201303081734, downloaded and installed from the Eclipse Marketplace. Should I have better used the nightly builds, from GIT etc?

OK, it seems that the headless example depends on a recent integration build, please try with that.

"Integration builds"

cheers
Istvan

 

Emre Taspolatoglu

unread,
May 1, 2013, 6:02:51 PM5/1/13
to incquer...@googlegroups.com
Hello Istvan,

indeed, the integration build of IncQuery has solved the errors. But now, the applications are giving the following error, when I try to run them:

EMF-IncQuery pattern storage globalEiqModel.xmi not found in bundle/project: headlessQueries.incquery

The same thing goes also for my own pattern model, not just the headless one from the example projects. I thought that these files were generated automatically, after having a valid pattern model file (*.eiq). Am I wrong here? Before I was able to run the apis after commenting the problematic parts which I also didn't need for that time.

Best regards,

Emre

Istvan Rath

unread,
May 2, 2013, 3:16:48 AM5/2/13
to EMF-IncQuery Users on behalf of Emre Taspolatoglu
Hi Emre,

as far as I know, we haven't changed anything regarding the generation of queries/globalEiqModel.xmi recently. They are generated automatically, however they are designed to be hidden from the user (for a good reason).

As everything works well in my local configuration, I suspect something has been changed on your side:

- have you opened/modified/deleted the globalEiqModel.xmi file manually?
- please check that the file is _actually there_ in your project. You can do so with a file manager outside of Eclipse, or by deactivating the EMF-IncQuery filter in your Package Explorer configuration (available e.g. in the pulldown menu of the Package Explorer view).
- you can try a full clean and rebuild of your IncQuery projects (Project | Clean … )

HTH
Istvan

--
You received this message because you are subscribed to the Google Groups "EMF-IncQuery Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to incquery-user...@googlegroups.com.
To post to this group, send email to incquer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/incquery-users/-/gwr-LMeCbXQJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Emre Taspolatoglu

unread,
May 2, 2013, 3:36:15 AM5/2/13
to EMF-IncQuery Users
Hello Istvan,

yes, they are hidden from the user, but I knew they were there, checking them once in awhile from the Navigator for my own needs. But, the problem has been solved with a clean build. Thanks a lot. Still funny though, why they were not created in the first place, after the initial project creation.

Best regards,
Emre



--
You received this message because you are subscribed to a topic in the Google Groups "EMF-IncQuery Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/incquery-users/m0QSxs49-qw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to incquery-user...@googlegroups.com.

To post to this group, send email to incquer...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages