Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [JET] How can I make scriptlet not occupy a new line in the generated file?
[JET] How can I make scriptlet not occupy a new line in the generated file? [message #39412] Sat, 12 January 2008 09:17 Go to next message
Eclipse UserFriend
Hi,
As we know, in the JET template file, we will embed many Java
scriplets. If a scriplet appear as a line in the template file, then, in the
generated file, a blank line is wlso resulted. I think this is not a desired
situation. I don't know how to make this happne. Please help me.
Thanks.
Michael.
Re: [JET] How can I make scriptlet not occupy a new line in the generated file? [message #39934 is a reply to message #39412] Tue, 15 January 2008 10:12 Go to previous messageGo to next message
Eclipse UserFriend
JET2 has an algorithm for removing whitespace that it figures might be
unwanted. If you are dealing only with scriptlets and expressions, it comes
down to this:

If the scriptlet starts on a line that is and it is preceded by nothing but
whitespace (blanks, tabs, etc) and ends on a line where it is trailed by
nothing but whitespace, then the JET compiler will remove the preceding
whitespace, the trailing whitespace, and the trailing new-line.

So, the following text in a JET template should have NO effect on the
output:

<% for(int i = 0; i < -1; i++) {%>
nothing
<% } %>

Nor would:

<%
for(int i = 0; i < -1; i++) {
%>
nothing
<%
}
%>

Put anything before <% or after %>, though, and you would get some text
generated (and a new line).

I have played with more sophisticated rules for stripping whitespace, but
have found that they just create confusion, and, in some cases do not do
what you want.

Paul

"Michael" <my25@macs.hw.ac.uk> wrote in message
news:fmai57$o5c$1@build.eclipse.org...
> Hi,
> As we know, in the JET template file, we will embed many Java
> scriplets. If a scriplet appear as a line in the template file, then, in
> the generated file, a blank line is wlso resulted. I think this is not a
> desired situation. I don't know how to make this happne. Please help me.
> Thanks.
> Michael.
>
Re: [JET] How can I make scriptlet not occupy a new line in the generated file? [message #40330 is a reply to message #39934] Fri, 18 January 2008 09:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
Thanks for your help.
Thanks for your ruels. I also found this rule doesn't work sometimes. I
am wandering whether this is a bug of GET.
I hope it would be solved as soon as possible.
Cheers.
Michael.
"Paul Elder" <pelder@ca.ibm.com> wrote in message
news:fmiiis$49t$1@build.eclipse.org...
> JET2 has an algorithm for removing whitespace that it figures might be
> unwanted. If you are dealing only with scriptlets and expressions, it
> comes down to this:
>
> If the scriptlet starts on a line that is and it is preceded by nothing
> but whitespace (blanks, tabs, etc) and ends on a line where it is trailed
> by nothing but whitespace, then the JET compiler will remove the preceding
> whitespace, the trailing whitespace, and the trailing new-line.
>
> So, the following text in a JET template should have NO effect on the
> output:
>
> <% for(int i = 0; i < -1; i++) {%>
> nothing
> <% } %>
>
> Nor would:
>
> <%
> for(int i = 0; i < -1; i++) {
> %>
> nothing
> <%
> }
> %>
>
> Put anything before <% or after %>, though, and you would get some text
> generated (and a new line).
>
> I have played with more sophisticated rules for stripping whitespace, but
> have found that they just create confusion, and, in some cases do not do
> what you want.
>
> Paul
>
> "Michael" <my25@macs.hw.ac.uk> wrote in message
> news:fmai57$o5c$1@build.eclipse.org...
>> Hi,
>> As we know, in the JET template file, we will embed many Java
>> scriplets. If a scriplet appear as a line in the template file, then, in
>> the generated file, a blank line is wlso resulted. I think this is not a
>> desired situation. I don't know how to make this happne. Please help me.
>> Thanks.
>> Michael.
>>
>
>
Re: [JET] How can I make scriptlet not occupy a new line in the generated file? [message #40450 is a reply to message #40330] Mon, 21 January 2008 11:04 Go to previous message
Eclipse UserFriend
Michael:

Best way to get a problem fixed is to submit a bugzilla, and attach specific
instructions on how to reproduce (or attaching actual problem templates).
Here's the link to submit a bug:

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=M2T& version=unspecified&component=Jet&priority=P3&bu g_severity=normal&bug_status=NEW&form_name=enter_bug &assigned_to=m2t.jet-inbox%40eclipse.org

Paul

"Michael" <my25@macs.hw.ac.uk> wrote in message
news:fmqcuc$orj$1@build.eclipse.org...
> Hi,
> Thanks for your help.
> Thanks for your ruels. I also found this rule doesn't work sometimes. I
> am wandering whether this is a bug of GET.
> I hope it would be solved as soon as possible.
> Cheers.
> Michael.
> "Paul Elder" <pelder@ca.ibm.com> wrote in message
> news:fmiiis$49t$1@build.eclipse.org...
>> JET2 has an algorithm for removing whitespace that it figures might be
>> unwanted. If you are dealing only with scriptlets and expressions, it
>> comes down to this:
>>
>> If the scriptlet starts on a line that is and it is preceded by nothing
>> but whitespace (blanks, tabs, etc) and ends on a line where it is trailed
>> by nothing but whitespace, then the JET compiler will remove the
>> preceding whitespace, the trailing whitespace, and the trailing new-line.
>>
>> So, the following text in a JET template should have NO effect on the
>> output:
>>
>> <% for(int i = 0; i < -1; i++) {%>
>> nothing
>> <% } %>
>>
>> Nor would:
>>
>> <%
>> for(int i = 0; i < -1; i++) {
>> %>
>> nothing
>> <%
>> }
>> %>
>>
>> Put anything before <% or after %>, though, and you would get some text
>> generated (and a new line).
>>
>> I have played with more sophisticated rules for stripping whitespace, but
>> have found that they just create confusion, and, in some cases do not do
>> what you want.
>>
>> Paul
>>
>> "Michael" <my25@macs.hw.ac.uk> wrote in message
>> news:fmai57$o5c$1@build.eclipse.org...
>>> Hi,
>>> As we know, in the JET template file, we will embed many Java
>>> scriplets. If a scriplet appear as a line in the template file, then, in
>>> the generated file, a blank line is wlso resulted. I think this is not a
>>> desired situation. I don't know how to make this happne. Please help me.
>>> Thanks.
>>> Michael.
>>>
>>
>>
>
>
Previous Topic:jet ant task
Next Topic:Ecore model to Java file
Goto Forum:
  


Current Time: Mon May 12 16:17:44 EDT 2025

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

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

Back to the top