Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCore] Compiler overrides code tagged as not generated([XCore] Compiler overrides code tagged as not generated)
[XCore] Compiler overrides code tagged as not generated [message #1060282] Thu, 23 May 2013 20:41 Go to next message
Regent LArcheveque is currently offline Regent LArchevequeFriend
Messages: 94
Registered: May 2010
Member
Hi,

I recently upgraded to Eclipse 4.3RC1 I20130516-2200 and XCore 1.1.0.v20130508-0449. I realized different code generation behavior. Code tagged as @generated_NOT gets overwritten. In fact even custom code gets overwritten. I created a simple that reflects this issue.

@GenModel(prefix="EMFTest", modelName="EMFTest")
package emftest
class ClassA{
	String name
	op void printStatus()
}


Then I modify ClassAImpl.java
  private String message = "Hello";
  
  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated_NOT
   */
  public void printStatus()
  {
	  System.out.println("ClassAImpl.printStatus()");
  }


If I modify the .xcore meta-model, the previous code gets overwritten?

Thanks for your help.
Re: [XCore] Compiler overrides code tagged as not generated [message #1060315 is a reply to message #1060282] Fri, 24 May 2013 06:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33139
Registered: July 2009
Senior Member
Régent,

If you generated into the default src-gen folder, then all the files are
marked as derived and you get behaviors such as doing a Clean build
removes all your generated files in the src-gen folder. Given such
behavior, it's not a good idea to rely on merging to accomplish anything
that needs to be preserved because you can end up losing them anyway if
and when you do a clean build. So as part of
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404419 I changed the
behavior so it doesn't merge at all; that also makes regeneration
significantly faster. As such, if you want to change that behavior to
also support merging, you can add a @GenModel annotation to the package
declaration in the Xcore source:

@GenModel(modelDirectory="/<your-project-name>/src")


On 23/05/2013 10:41 PM, Régent L Archevêque wrote:
> Hi,
>
> I recently upgraded to Eclipse 4.3RC1 I20130516-2200 and XCore
> 1.1.0.v20130508-0449. I realized different code generation behavior.
> Code tagged as @generated_NOT gets overwritten. In fact even custom
> code gets overwritten. I created a simple that reflects this issue.
>
>
> @GenModel(prefix="EMFTest", modelName="EMFTest")
> package emftest
> class ClassA{
> String name
> op void printStatus()
> }
>
>
> Then I modify ClassAImpl.java
>
> private String message = "Hello";
>
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated_NOT
> */
> public void printStatus()
> {
> System.out.println("ClassAImpl.printStatus()");
> }
>
>
> If I modify the .xcore meta-model, the previous code gets overwritten?
>
> Thanks for your help.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [XCore] Compiler overrides code tagged as not generated [message #1060410 is a reply to message #1060315] Fri, 24 May 2013 14:12 Go to previous messageGo to next message
Regent LArcheveque is currently offline Regent LArchevequeFriend
Messages: 94
Registered: May 2010
Member
Thanks Ed for the quick answer.

As you mentioned, I renamed the modelDirectory source directory and it works now.

I know it is not the preferred way to add custom code in the generated-code. In general, we implement basic operations in XCore and complex operations in Java. Sometimes we carefully use <functionName>Gen() pattern to provide additional functionality to getters. We use EMF since the last 10 years, we do not see how we can change our modeling/programming strategy in these particular cases. Do you have tips / tricks that we could explore? We try to stay on-the-edge with EMF but we may miss some important features / guidelines. On our side, the meta-model serves not only as data-model. I think most of the community uses EMF for that purpose.

Regent Wink
Re: [XCore] Compiler overrides code tagged as not generated [message #1060424 is a reply to message #1060410] Fri, 24 May 2013 15:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33139
Registered: July 2009
Senior Member
Régent,

Comments below.

On 24/05/2013 4:12 PM, Régent L Archevêque wrote:
> Thanks Ed for the quick answer.
>
> As you mentioned, I renamed the modelDirectory source directory and it
> works now.
>
> I know it is not the preferred way to add custom code in the
> generated-code. In general, we implement basic operations in XCore and
> complex operations in Java.
In terms of Xcore's block expressions, Xbase (as extended by Xcore) is
sufficiently expressive that there isn't really anything that you can do
in Java that can't be expressed in Xbase, and often more
concisely/elegantly...
> Sometimes we carefully use <functionName>Gen() pattern to provide
> additional functionality to getters.
Yes, there's an outstanding bugzilla about being able to express logic
for a getter without marking it as derived, but I've had no time for that.
> We use EMF since the last 10 years, we do not see how we can change
> our modeling/programming strategy in these particular cases.
Yes, there are still limitations with Xcore, one of the most important
ones being the inability to declare fields for the implementation classes...
> Do you have tips / tricks that we could explore?
No, not really.
> We try to stay on-the-edge with EMF but we may miss some important
> features / guidelines.
It's nice to see Xcore being used. It's so much simpler than using the
Sample Ecore Editor and gives such a nice complete overview of the model
structure...
> On our side, the meta-model serves not only as data-model. I think
> most of the community uses EMF for that purpose.
It's also very common to add behavior to a model, but I have no
statistics as to what percentage of the use cases that that approach.
>
> Regent ;)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [XCore] Compiler overrides code tagged as not generated [message #1060451 is a reply to message #1060424] Fri, 24 May 2013 17:15 Go to previous message
Regent LArcheveque is currently offline Regent LArchevequeFriend
Messages: 94
Registered: May 2010
Member
Thanks Ed.

Don't take me wrong. I really appreciate XCore and EMF.

Thanks for your support.

Previous Topic:[Teneo] Diasbling Two Phase Load Hibernate
Next Topic:[Teneo] Default Value in DDL Generation
Goto Forum:
  


Current Time: Tue Apr 23 06:55:52 GMT 2024

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

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

Back to the top