Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Checking the EClass of an EObject in a pattern
Checking the EClass of an EObject in a pattern [message #1746772] Fri, 04 November 2016 12:27 Go to next message
Erhan Leblebici is currently offline Erhan LeblebiciFriend
Messages: 5
Registered: November 2016
Junior Member
Hello,

I have two EClasses "Employee" and its subclass "PartTimeEmployee" in my metamodel. I am trying to specify a pattern which should only match for direct instances of Employee (and not for instances of the subclass).

The pattern below for example will match for PartTimeEmployee instances as well.

pattern findEmployee(e : Employee){
Employee(e);
}

Is it possible to check in a pattern if the EClass of e is Employee and nothing else? I am looking for something like e.eClass() as provided by EMF.

Cheers,
Erhan
Re: Checking the EClass of an EObject in a pattern [message #1746785 is a reply to message #1746772] Fri, 04 November 2016 14:56 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

sadly, there is no built-in support for this feature as of now. As a workaround, I can suggest something like follows:


pattern specialEmployee(e : PartTimeEmployee) {
PartTimeEmployee(e);
} or {
// Put all direct subclasses into separate bodies
}

pattern findEmployee(e : Employee){
Employee(e);
neg find specialEmployee(e);
}

I know this is not really easy to use, but this is currently the only way to use it.

However, could you elaborate your use case why you need this functionality? We might be capable of suggesting an alternative approach here; or if the issue seems general, we might also update the query language/runtimes to support this use case as well.

Best regards,
Zoltán
Re: Checking the EClass of an EObject in a pattern [message #1746810 is a reply to message #1746785] Fri, 04 November 2016 20:01 Go to previous messageGo to next message
Erhan Leblebici is currently offline Erhan LeblebiciFriend
Messages: 5
Registered: November 2016
Junior Member
Hello,

I am using patterns to parse a graph with respect to a grammar. Each original grammar rule creates objects with specific types, so parsing a given graph with patterns must be specific on types as well. (if my grammar rule creates Employee, then I should exactly parse Employee and not some subtypes). This parser will be then used for model transformation, consistency checking etc.

Your solution is still a managable one with one additional pattern for each type. Thanks for that! Nevertheless, I'd be of course even more happy to hear about a new language feature addressing this issue in the future Smile

Cheers,
Erhan

Re: Checking the EClass of an EObject in a pattern [message #1746824 is a reply to message #1746810] Sat, 05 November 2016 08:21 Go to previous message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi Erhan,

I see, I cannot provide any real alternative here. Maybe you could do this instanceof check in your transfomation rules, etc., but still, this is only a workaround.

I have opened a ticket https://bugs.eclipse.org/bugs/show_bug.cgi?id=507094 for this issue; however, I don't know when will it be addressed.

Cheers,
Zoltán
Previous Topic:Tutorial Issue: createRule.precondition errors
Next Topic:Applying the same tranformation rule multiple times on the same match
Goto Forum:
  


Current Time: Tue Mar 19 03:45:44 GMT 2024

Powered by FUDForum. Page generated in 0.02410 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top