Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] Setting default value of a string
[Xcore] Setting default value of a string [message #1735188] Thu, 16 June 2016 08:34 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I want to set the default value of a string which is defined in a static variable in xtend.
But I am getting this error:
Multiple markers at this line
- missing RULE_STRING at 'MyStaticObjects'
- MyStaticObjectscannot be resolved to a type.
- extraneous input '::' expecting RULE_ID
- A generic type in this context must refer to a classifier or
a type parameter

I use it like this:

class Directory {
String name = MyStaticObjects::DEFAULT_NAME
}


May I know how to initialize a string to a static variable?
Re: [Xcore] Setting default value of a string [message #1735220 is a reply to message #1735188] Thu, 16 June 2016 11:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31917
Registered: July 2009
Senior Member
You can only specify a literal string value, not an arbitrary expression.


On 16.06.2016 04:34, chris yo wrote:
> I want to set the default value of a string which is defined in a
> static variable in xtend.
> But I am getting this error:
> Multiple markers at this line
> - missing RULE_STRING at 'MyStaticObjects'
> - MyStaticObjectscannot be resolved to a type.
> - extraneous input '::' expecting RULE_ID
> - A generic type in this context must refer to a classifier or
> a type parameter
>
> I use it like this:
>
>
> class Directory {
> String name = MyStaticObjects::DEFAULT_NAME
> }
>
>
> May I know how to initialize a string to a static variable?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Xcore] Setting default value of a string [message #1735288 is a reply to message #1735220] Fri, 17 June 2016 02:35 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
Is there a plan to add this feature in the future? This will be something nice to have.
Re: [Xcore] Setting default value of a string [message #1735323 is a reply to message #1735288] Fri, 17 June 2016 11:17 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31917
Registered: July 2009
Senior Member
Chris,

No, not really. In the end, an Xcore instance just maps to an Ecore and
GenModel instance, and an EStructuralFeature has a "default value"
literal attribute, i.e., a fix constant, not some expression that would
need to be evaluated at runtime...


On 16.06.2016 22:35, chris yo wrote:
> Is there a plan to add this feature in the future? This will be
> something nice to have.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Xcore] Wrong Java Generated code
Next Topic:converting the ecore model to xmi
Goto Forum:
  


Current Time: Wed Jun 23 10:12:35 GMT 2021

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

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

Back to the top