Skip to main content



      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] Thu, 07 August 2008 22:47 Go to next message
Eclipse UserFriend
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 08:07 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: How to create a prefix like fXxx or _xxx for fields in generated models? [message #421552 is a reply to message #421519] Fri, 08 August 2008 22:23 Go to previous message
Eclipse UserFriend
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 Nov 05 06:29:25 EST 2025

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

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

Back to the top