Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to create a prefix like fXxx or _xxx for fields in generated models?
How to create a prefix like fXxx or _xxx for fields in generated models? [message #421500] Fri, 08 August 2008 02:47 Go to next message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
Hi,

is there a way to specify a prefix or the name for the field generated?

Example (using emfatic syntax):

class MyClass {
attr int fooBar;
}

I want to specify the name of the fooBar
field to be _fooBar or fFooBar. Instead of
protected int fooBar = FOO_BAR_EDEFAULT;
I want
protected int _fooBar = FOO_BAR_EDEFAULT;
or
protected int fFooBar = FOO_BAR_EDEFAULT;
or
protected int fooBar_ = FOO_BAR_EDEFAULT;

Is thre a magic annotation like the @GenModel(documentation="my doc")
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=152481#c1)?

class MyClass {
@GenModel(filedName="fFooBar") // would be nice :-)
attr int fooBar;
}


Why? Because often without the escape it is all to easy
to accidentally assign to the fooBar variable in "@generated NO"
methods.

Another option I would like is to make members private to the
class.....

Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: How to create a prefix like fXxx or _xxx for fields in generated models? [message #421519 is a reply to message #421500] Fri, 08 August 2008 12:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.


Michael Scharf wrote:
> Hi,
>
> is there a way to specify a prefix or the name for the field generated?
No the field name is computed directly from the feature name.
>
> Example (using emfatic syntax):
>
> class MyClass {
> attr int fooBar;
> }
>
> I want to specify the name of the fooBar
> field to be _fooBar or fFooBar. Instead of
> protected int fooBar = FOO_BAR_EDEFAULT;
> I want
> protected int _fooBar = FOO_BAR_EDEFAULT;
> or
> protected int fFooBar = FOO_BAR_EDEFAULT;
> or
> protected int fooBar_ = FOO_BAR_EDEFAULT;
>
> Is thre a magic annotation like the @GenModel(documentation="my doc")
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=152481#c1)?
>
> class MyClass {
> @GenModel(filedName="fFooBar") // would be nice :-)
> attr int fooBar;
> }
>
>
> Why? Because often without the escape it is all to easy
> to accidentally assign to the fooBar variable in "@generated NO"
> methods.
I'm not keen on adding yet more complexity because you have a tendency
to assign variables without considering if that's a good idea.
>
> Another option I would like is to make members private to the
> class.....
You'd still have the same problem in that class then. Some of the
generation patterns require access to the field in derived classes.

Feature requests arrive faster than the shrinking team can address them
so I'm not going to suggest a feature request for this, but if you feel
strongly about it, a patch to implement it will be considered.
>
> Michael


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to create a prefix like fXxx or _xxx for fields in generated models? [message #421552 is a reply to message #421519] Sat, 09 August 2008 02:23 Go to previous message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
Ed,

thanks for the quick reply. I was hoping, that there is
already a magic annotation that does the trick.

Maybe, I'll do a patch when it annoys me too much...

Michael

> Michael,
>
> Comments below.
>
>
> Michael Scharf wrote:
>> Hi,
>>
>> is there a way to specify a prefix or the name for the field generated?
> No the field name is computed directly from the feature name.
>>
>> Example (using emfatic syntax):
>>
>> class MyClass {
>> attr int fooBar;
>> }
>>
>> I want to specify the name of the fooBar
>> field to be _fooBar or fFooBar. Instead of
>> protected int fooBar = FOO_BAR_EDEFAULT;
>> I want
>> protected int _fooBar = FOO_BAR_EDEFAULT;
>> or
>> protected int fFooBar = FOO_BAR_EDEFAULT;
>> or
>> protected int fooBar_ = FOO_BAR_EDEFAULT;
>>
>> Is thre a magic annotation like the @GenModel(documentation="my doc")
>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=152481#c1)?
>>
>> class MyClass {
>> @GenModel(filedName="fFooBar") // would be nice :-)
>> attr int fooBar;
>> }
>>
>>
>> Why? Because often without the escape it is all to easy
>> to accidentally assign to the fooBar variable in "@generated NO"
>> methods.
> I'm not keen on adding yet more complexity because you have a tendency
> to assign variables without considering if that's a good idea.
>>
>> Another option I would like is to make members private to the
>> class.....
> You'd still have the same problem in that class then. Some of the
> generation patterns require access to the field in derived classes.
>
> Feature requests arrive faster than the shrinking team can address them
> so I'm not going to suggest a feature request for this, but if you feel
> strongly about it, a patch to implement it will be considered.
>>
>> Michael


--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Previous Topic:Databinding and mixed/any type
Next Topic:[CDO] New packages
Goto Forum:
  


Current Time: Wed Apr 24 17:05:17 GMT 2024

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

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

Back to the top