Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore] enum in switch statement
[xcore] enum in switch statement [message #896768] Thu, 19 July 2012 16:24 Go to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Hi

defining a operation in xcore brings me to the point to have a switch statement using a enum
property. But i can't figure out how to code the case:

Example:

enum EditType
{
PROJECT_FILE = 0
DATABASE = 1
}

class A
{
EditType editType
op void doSomeThing(){
switch(editType){
case DATABASE: //getting an ERROR
case 1: //this is OK but not nice
}
}
}

How do I specify the specific switch case?

Martin
Re: [xcore] enum in switch statement [message #896849 is a reply to message #896768] Fri, 20 July 2012 06:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Martin,

You use it like this:

op void doSomeThing(){
switch(editType){
case EditType::PROJECT_FILE:
{

}
case EditType::DATABASE:
{

}
}
}

I.e., the Xbase syntax for referring to static fields uses "::" not
".". It would be nice if Xbase made the enumerator's visible without
qualification in the switch. Maybe you could open a bugzilla
enhancement against Xtext's Xbase. Please post the bugzilla number here.


On 19/07/2012 6:24 PM, Martin Jacob wrote:
> Hi
>
> defining a operation in xcore brings me to the point to have a switch
> statement using a enum property. But i can't figure out how to code
> the case:
>
> Example:
>
> enum EditType
> {
> PROJECT_FILE = 0
> DATABASE = 1
> }
>
> class A
> {
> EditType editType
> op void doSomeThing(){
> switch(editType){
> case DATABASE: //getting an ERROR
> case 1: //this is OK but not nice
> }
> }
> }
>
> How do I specify the specific switch case?
>
> Martin


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] enum in switch statement [message #1096716 is a reply to message #896768] Wed, 28 August 2013 19:27 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Stale thread, but please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=400096.
Previous Topic:How to deserialize Base64-encoded EMF value without EMF
Next Topic:serialize derived feature but ignore all set operations
Goto Forum:
  


Current Time: Tue Mar 19 04:16:07 GMT 2024

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

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

Back to the top