Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » Merging of import statements not working?
Merging of import statements not working? [message #33742] Thu, 13 September 2007 14:16 Go to next message
Eclipse UserFriend
Given that I have a JET template that uses <java:import> to add the import
statements for classes that are in the emitted code, and merging is turned
on (i'm using jmerge), the transformed file will always contain the import
statements of the existing file, not the ones from the emitted and merged
code from JET. I tried to use <merge:pull sourceGet="Import/getName"
targetPut="Import/setName"/> but to no avail. Is there a merge rule that I
need to add to be able to merge the import statements? Btw, I'm using JET
0.7.3 and JMerge (org.eclipse.emf.codegen) 2.2.2.

Thanks,
Francis
Re: Merging of import statements not working? [message #33843 is a reply to message #33742] Fri, 14 September 2007 11:21 Go to previous messageGo to next message
Eclipse UserFriend
I was able to make this work by having the following declarations in the
template in this order:
1. package declaration
2. java:importsLocation tag
3. java:merge tag
However, the import statements are not sorted alphabetically anymore. I
tried using <merge:sort select="Import"/> but it didn't work...


Francis wrote:

> Given that I have a JET template that uses <java:import> to add the import
> statements for classes that are in the emitted code, and merging is turned
> on (i'm using jmerge), the transformed file will always contain the import
> statements of the existing file, not the ones from the emitted and merged
> code from JET. I tried to use <merge:pull sourceGet="Import/getName"
> targetPut="Import/setName"/> but to no avail. Is there a merge rule that I
> need to add to be able to merge the import statements? Btw, I'm using JET
> 0.7.3 and JMerge (org.eclipse.emf.codegen) 2.2.2.

> Thanks,
> Francis
Re: Merging of import statements not working? [message #33884 is a reply to message #33843] Mon, 17 September 2007 09:06 Go to previous message
Eclipse UserFriend
Francis:

Some observations...

1) the position of java:merge in your template should have no impact - it is
merely a marker that indicates the final buffer contents should be passed
through JMerge.

2) The standard JMerge rule for imports would add any imports from the
expanded template into the imports of the existing file. No imports would
ever be removed. There is some logic to this, as the existing files inputs
could arise from user written code.

3) Sorting in jmerge is controlled by <merge:sort> elements in the rules
file. There is not one for Imports in the standard rules file
( http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/templates /emf-merge.xml?revision=1.12&root=Modeling_Project&v iew=markup),
but if sorting is important, I'd experiment with

<merge:sort select="Import"/>

Paul

"Francis" <fgavino@gmail.com> wrote in message
news:42368279bc8da4b460aa765f94a63394$1@www.eclipse.org...
>I was able to make this work by having the following declarations in the
>template in this order:
> 1. package declaration
> 2. java:importsLocation tag
> 3. java:merge tag
> However, the import statements are not sorted alphabetically anymore. I
> tried using <merge:sort select="Import"/> but it didn't work...
>
> Francis wrote:
>
>> Given that I have a JET template that uses <java:import> to add the
>> import statements for classes that are in the emitted code, and merging
>> is turned on (i'm using jmerge), the transformed file will always contain
>> the import statements of the existing file, not the ones from the emitted
>> and merged code from JET. I tried to use <merge:pull
>> sourceGet="Import/getName" targetPut="Import/setName"/> but to no avail.
>> Is there a merge rule that I need to add to be able to merge the import
>> statements? Btw, I'm using JET 0.7.3 and JMerge (org.eclipse.emf.codegen)
>> 2.2.2.
>
>> Thanks,
>> Francis
>
>
Previous Topic:[JET2] Custom XPath to access stereotypes.
Next Topic:[JET] Returning a List from a custom XPath function.
Goto Forum:
  


Current Time: Tue Jul 15 06:49:30 EDT 2025

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

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

Back to the top