[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: How to create a prefix like fXxx or _xxx for fields in generated models?

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