Home » Archived » EMF-IncQuery » Unique names of derived features?
Unique names of derived features? [message #1250477] |
Wed, 19 February 2014 04:30  |
Eclipse User |
|
|
|
Hello,
do the names of the derived features in a model have to be unique, so that they can be declared as well behaving derived feature queries? Because I believe that this is not possible to declare a pattern with the same name twice, but also the pattern names have to be the same as the name of the derived feature they are querying or they have the "feature" parameter in QueryBasedFeature annotation to reference the derived feature.
Is there a workaround for this? Since the model I am building has lots of specific model elements, which might have the same kind of derived reference. And giving all of them different names would be cumbersome.
Thanks!
Emre
|
|
| |
Re: Unique names of derived features? [message #1250538 is a reply to message #1250493] |
Wed, 19 February 2014 05:31   |
Eclipse User |
|
|
|
Ok, I thought so. An example for the usage of the annotation parameters would be like this then:
Lets say we have two model elements "A" and "B", which have a derived reference with the same name "derivedReference" and the same type (e.g. "Class" element from model being referenced). When I define the two patterns for these two derived references, I could do it as the following.
@QueryBasedFeature (feature = "derivedReference", source = "A", target = "Class")
pattern firstDerivedReference (This: A, Target: Class) { ... }
@QueryBasedFeature (feature = "derivedReference", source = "B", target = "Class")
pattern secondDerivedReference (This: B, Target: Class) { ... }
Would it be the right usage? Could EMF IncQuery then differentiate between the two derived references and generate the notifiers accordingly?
Best regards,
Emre
[Updated on: Wed, 19 February 2014 05:31] by Moderator
|
|
| |
Re: Unique names of derived features? [message #1250544 is a reply to message #1250538] |
Wed, 19 February 2014 05:37   |
Eclipse User |
|
|
|
Just a quick response, the example you wrote is not exactly correct.
The 'source' and 'target' parameters refer to _parameters_, not EClasses. So in your case, use:
@QueryBasedFeature (feature = "derivedReference", source = This, target = Target)
pattern firstDerivedReference (This: A, Target: Class) { ... }
@QueryBasedFeature (feature = "derivedReference", source = This, target = Target)
pattern secondDerivedReference (This: B, Target: Class) { ... }
As written in the wiki, you don't have to declare 'source' and 'target' if only two parameters are used in the query and the first is the source and the second is the target.
Edit: I corrected the example to make sure the information is correct for future readers.
[Updated on: Sun, 23 February 2014 19:46] by Moderator
|
|
| | | | |
Re: Unique names of derived features? [message #1254940 is a reply to message #1251805] |
Sun, 23 February 2014 19:36   |
Eclipse User |
|
|
|
Hello again,
I needed to use the parameters again, and I am getting the following error: Invalid parameter type String. Expected Variable
I use them, like you have corrected:
@QueryBasedFeature (feature = "ref", source = "This", target = "Target")
pattern refQuery(This: A, Middle: B, Target: C) = { ... }
The source is the derived feature is A, the target is B, but I have to make a definitive stop at the Middle B, to be able traverse the model.
What might be the reason?
Thanks!
EDIT: Ok, it's solved, clearly, I should have been more careful to the error. After removing quotes, it was gone.
[Updated on: Sun, 23 February 2014 19:44] by Moderator
|
|
| |
Goto Forum:
Current Time: Tue Jul 15 00:54:26 EDT 2025
Powered by FUDForum. Page generated in 0.25123 seconds
|