Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » [EMF] "@generated NOT" does not work
[EMF] "@generated NOT" does not work [message #654302] Tue, 15 February 2011 01:04 Go to next message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi everyone,

i have a ecore model and his genmodel. Any change to ecore model automatically updates the genmodel .The problem occurs when i try to re-generate the model code. The methods and attributes marked with "@generated NOT" or without the "@generated" are still overwritten. Is there some other configuration to do?

I'm using eclipse SDK 3.6.1 with EMF 2.6.1.

Hugo Melo
Re: [EMF] "@generated NOT" does not work [message #654305 is a reply to message #654302] Tue, 15 February 2011 01:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Hugo,

Comments below.

Hugo Melo wrote:
> Hi everyone,
>
> i have a ecore model and his genmodel. Any change to ecore model
> automatically updates the genmodel .The problem occurs when i try to
> re-generate the model code. The methods and attributes marked with
> "@generated NOT" or without the "@generated" are still overwritten. Is
> there some other configuration to do?
I've never seen that happen before. I'm a bit doubtful because everyone
would notice such a problem all the time...
>
> I'm using eclipse SDK 3.6.1 with EMF 2.6.1.
>
> Hugo Melo


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] "@generated NOT" does not work [message #654418 is a reply to message #654305] Tue, 15 February 2011 16:58 Go to previous messageGo to next message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Ed,

I've created this topic because I didn't find the same behaviour anywhere. Fortunately, I found the cause and I'm sharing with you:

* This is just a example

Project name = "project"
Model name = "model"
Project source code = "project.src"

By default, the generated model code goes to "/project/src". This is defined in the property "Model -> Model Directory", on the genmodel file, as well as the edit code goes to "/project.edit/src".

But in my project, the model code should be generated in "project.src.modelcode" package and the edit code should be generated in "project.src.modelcode.provider". To accomplish this, I have appended the "Model Directory" and the "Edit Directory" properties of the genmodel to "/project/src/modelcode".

This way, the generated code goes to right place, but with some minor errors. And in this way, the "generated NOT" marked methods are still overwritten after each re-gereration action.

To solve the erros and problems, I've just edited the genmodel correctly. Instead change the model or edit directory, I've changed the root EPackage ("model") property, labelled as "Base Package", and setted his value to "modelcode".

I still dont know why the problem occurs, but I can correct and reproduce it.

Hugo Melo
Re: [EMF] "@generated NOT" does not work [message #1728322 is a reply to message #654418] Sat, 02 April 2016 00:05 Go to previous messageGo to next message
Paul Roubekas is currently offline Paul RoubekasFriend
Messages: 207
Registered: March 2012
Location: Chattanooga, TN USA
Senior Member
I am on Eclipse 4.5.2
EMF 2.11.2
Windows 7 SP1

I have a similar issue on my enum with the constructor. When "NOT" is used method is re-written. When @generate is removed the re-write does not happen.


This preserves source code changes, but add a new MyConstants with the original signature.

	/**
	 * Only this class can construct instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	private MyConstants(int value, String name, String literal, BigDecimal constantValue, BigDecimal uncertainty, String unitOfMeasure) {
		this.value = value;
		this.name = name;
		this.literal = literal;
		this.constantValue = constantValue;
		this.uncertainty = uncertainty;
		this.unitOfMeasure = unitOfMeasure;


This preserves source code changes, but add a new MyConstants with the original signature.

	/**
	 * Only this class can construct instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	private MyConstants(int value, String name, String literal, BigDecimal constantValue, BigDecimal uncertainty, String unitOfMeasure) {
		this.value = value;
		this.name = name;
		this.literal = literal;
		this.constantValue = constantValue;
		this.uncertainty = uncertainty;
		this.unitOfMeasure = unitOfMeasure;






Oxygen 3a
Windows 10
Re: [EMF] &quot;@generated NOT&quot; does not work [message #1728333 is a reply to message #1728322] Sat, 02 April 2016 06:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Paul,

I can't reproduce that. E.g., if I change an enum's constructor and
then regenerate I end up with two constructors:

/**
* Only this class can construct instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private X(int value, String name, String literal) {
this.value = value;
this.name = name;
this.literal = literal;
}

/**
* Only this class can construct instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
private X(int value, String name, String literal, float x) {
this.value = value;
this.name = name;
this.literal = literal;
}


Of course the new constructor I wrote does not have the same name and
signature as any generated constructor so marking it as @generated NOT
is misleading. Perhaps something like this is more sensible:

/**
* Only this class can construct instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private X(int value, String name, String literal) {
this.value = value;
this.name = name;
this.literal = literal;
}

/**
* Only this specialized constructor should be used.
*/
private X(int value, String name, String literal, float x) {
this(value, name, literal);
// Do something with x....
}




On 02.04.2016 02:05, Paul Roubekas wrote:
> I am on Eclipse 4.5.2
> EMF 2.11.2
> Windows 7 SP1
>
> I have a similar issue on my enum with the constructor. When "NOT" is
> used method is re-written. When @generate is removed the re-write
> does not happen.
>
>
> This preserves source code changes, but add a new MyConstants with the
> original signature.
>
> /**
> * Only this class can construct instances.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> */
> private MyConstants(int value, String name, String literal,
> BigDecimal constantValue, BigDecimal uncertainty, String unitOfMeasure) {
> this.value = value;
> this.name = name;
> this.literal = literal;
> this.constantValue = constantValue;
> this.uncertainty = uncertainty;
> this.unitOfMeasure = unitOfMeasure;
>
>
> This preserves source code changes, but add a new MyConstants with the
> original signature.
>
> /**
> * Only this class can construct instances.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated NOT
> */
> private MyConstants(int value, String name, String literal,
> BigDecimal constantValue, BigDecimal uncertainty, String unitOfMeasure) {
> this.value = value;
> this.name = name;
> this.literal = literal;
> this.constantValue = constantValue;
> this.uncertainty = uncertainty;
> this.unitOfMeasure = unitOfMeasure;
>
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] &quot;@generated NOT&quot; does not work [message #1728335 is a reply to message #1728333] Sat, 02 April 2016 08:30 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

EMF has a mostly helpful generation setting whereby unchanged files are
not rewritten. For this purpose, comment and annotation changes are not
considered changes. It is therefore possible to be thoroughly puzzled as
to why your 'improvements' are having no effect. A similar no-change
problem occurs if there is a model path typo and so you are looking in
one place while generation is generating somewhere else.

You can avoid both of these confusions by making sure that you delete
the files that you hope to generate before generating them. (Once you've
finished debugging your tooling, make sure to restore the original files
and regenerate so that any old explicit/implicit @generated NOT code is
not lost.)

NB removal of @generated is a comment change, leaving an implicitly
@generated NOT segment of code.

Regards

Ed Willink


On 02/04/2016 07:36, Ed Merks wrote:
> Paul,
>
> I can't reproduce that. E.g., if I change an enum's constructor and
> then regenerate I end up with two constructors:
>
> /**
> * Only this class can construct instances.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> private X(int value, String name, String literal) {
> this.value = value;
> this.name = name;
> this.literal = literal;
> }
>
> /**
> * Only this class can construct instances.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated NOT
> */
> private X(int value, String name, String literal, float x) {
> this.value = value;
> this.name = name;
> this.literal = literal;
> }
>
>
> Of course the new constructor I wrote does not have the same name and
> signature as any generated constructor so marking it as @generated NOT
> is misleading. Perhaps something like this is more sensible:
>
> /**
> * Only this class can construct instances.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> private X(int value, String name, String literal) {
> this.value = value;
> this.name = name;
> this.literal = literal;
> }
>
> /**
> * Only this specialized constructor should be used.
> */
> private X(int value, String name, String literal, float x) {
> this(value, name, literal);
> // Do something with x....
> }
>
>
>
>
> On 02.04.2016 02:05, Paul Roubekas wrote:
>> I am on Eclipse 4.5.2
>> EMF 2.11.2
>> Windows 7 SP1
>>
>> I have a similar issue on my enum with the constructor. When "NOT"
>> is used method is re-written. When @generate is removed the re-write
>> does not happen.
>>
>>
>> This preserves source code changes, but add a new MyConstants with
>> the original signature.
>>
>> /**
>> * Only this class can construct instances.
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> */
>> private MyConstants(int value, String name, String literal,
>> BigDecimal constantValue, BigDecimal uncertainty, String
>> unitOfMeasure) {
>> this.value = value;
>> this.name = name;
>> this.literal = literal;
>> this.constantValue = constantValue;
>> this.uncertainty = uncertainty;
>> this.unitOfMeasure = unitOfMeasure;
>>
>>
>> This preserves source code changes, but add a new MyConstants with
>> the original signature.
>>
>> /**
>> * Only this class can construct instances.
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> * @generated NOT
>> */
>> private MyConstants(int value, String name, String literal,
>> BigDecimal constantValue, BigDecimal uncertainty, String
>> unitOfMeasure) {
>> this.value = value;
>> this.name = name;
>> this.literal = literal;
>> this.constantValue = constantValue;
>> this.uncertainty = uncertainty;
>> this.unitOfMeasure = unitOfMeasure;
>>
>>
>>
>>
>>
>
Previous Topic:Markers & Quick-fixes in tree editor
Next Topic:Extension and Extension Points
Goto Forum:
  


Current Time: Tue Mar 19 10:43:05 GMT 2024

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

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

Back to the top