Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[xcore] enum in switch statement
https://www.eclipse.org/forums/index.php/mv/msg/367794/896768/#msg_896768
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]]>Martin Jacob2012-07-19T16:24:20-00:00Re: [xcore] enum in switch statement
https://www.eclipse.org/forums/index.php/mv/msg/367794/896849/#msg_896849
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 Merks2012-07-20T06:46:50-00:00Re: [xcore] enum in switch statement
https://www.eclipse.org/forums/index.php/mv/msg/367794/1096716/#msg_1096716
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400096.]]>Miles Parker2013-08-28T19:27:34-00:00