Just in case you are interested in yet another improvement :-)
«const.findFirst[name==âfooâ].value.toString»
⊠will do it as well.
.into(new ArrayList) didn't work for me. I removed .into(new ArrayList), changed to get(0) and used the iterator returned by the filter method directly, it worked, thank you, guys!
"«consts.filter[name == "foo"].get(0).getValue().toString()»"
There is no "[0]" syntax in Xtend. Please use ".head" or ".get(0)"
Oh, it complained about ".into(new ArrayList)[0]". Thanks.
Thank you very much for your tips! I troubleshooted, the value itself does not contain newline. We need to convert the code into one liner to avoid the new line.
I have tried to translate my code into one-liner, however, it generated compilation error. Do you know how to fix it? Thanks! I am not sure how to use "before, after, and separator", please let me know. Thanks!
I need to get the constant with its name equals to "foo", and then get value of this constant.
'''
«IF !consts.empty»
«FOR c : consts»
«IF c.name <http://c.name/> == "foo"»
"«c.value.toString()»"
«ENDIF»
«ENDFOR»
«ENDIF»
'''
"«consts.filter[name == "foo"].into(new ArrayList)[0].getValue().toString()»"
My bad, I didn't recognize the quotes around your «c.value.toString» thus the join won't work as described but you'd have to provide before, after, and separator, too.
Hi,
your template has a newline after «c.value.toString()» thus it will always emit the newline. If you want to drop that, you'd need to make it a one-liner, e.g. «c.consts.filter[name == 'foo'].join[c.value.toString]». If you see more than one newline char for each c, that it's the value itself, that contains it.
Best,
Sebastian
Sebastian Zarnekow
Xtext Committer
mobile: +49 (0) 151 / 1739 6724 <>
web: http://www.itemis.de <http://www.itemis.de/>
xing: http://www.xing.com/profile/Sebastian_Zarnekow <http://www.xing.com/profile/Sebastian_Zarnekow>
blog: http://zarnekow.blogspot.com <http://zarnekow.blogspot.com/>
itemis AG
Am Germaniahafen 1
24143 Kiel
Germany
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter, Sebastian Neus
Aufsichtsrat: Prof. Dr. Burkhard Igel (Vors.), Michael Neuhaus, Jennifer Fiorentino
Hi Sven and Lorenzo,
I have the following code, xtend always generates a new line after c.value.toString(), do you know how can I avoid that new line? Thanks!
'''
«IF !consts.empty»
«FOR c : consts»
«IF c.name <http://c.name/> == "foo"»
"«c.value.toString()»"
«ENDIF»
«ENDFOR»
«ENDIF»
'''
Hi
If I have a multi line string
'''
foo.
bar
'''
is there a way of escaping the newline char so that the result is actually
foo.bar
?
I'm asking since in my xtend2 based generator I'd like to split the
multi line string just for formatting purposes, but I don't want the
newline appear in the result
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it <http://www.lorenzobettini.it/> MUSIC: http://www.purplesucker.com <http://www.purplesucker.com/>
BLOGS: http://tronprog.blogspot.com <http://tronprog.blogspot.com/> http://longlivemusic.blogspot.com <http://longlivemusic.blogspot.com/>
--
You received this message because you are subscribed to the Google Groups "Xtend Programming Language" group.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to a topic in the Google Groups "Xtend Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xtend-lang/WlM7qzaeyis/unsubscribe <https://groups.google.com/d/topic/xtend-lang/WlM7qzaeyis/unsubscribe>.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
Best Regards,
Minna Hu
--
Best Regards,
Minna Hu
--
Best Regards,
Minna Hu
--
You received this message because you are subscribed to the Google Groups "Xtend Programming Language" group.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups "Xtend Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xtend-lang+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.