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 Jacob
Messages: 116
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 Merks
Messages: 26088
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
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 Parker
Messages: 1340
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:How to create genmodel from ecore programmatically without using headless invocation/eclipse plugins
Goto Forum:
  


Current Time: Wed Oct 01 20:36:50 GMT 2014

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

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