Groups
Sign in
Groups
Xtend Programming Language
Conversations
About
Send feedback
Help
Templates geneating aligned comments
14 views
Skip to first unread message
fab...@gmail.com
unread,
Jul 5, 2015, 3:06:07 PM
7/5/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xtend...@googlegroups.com
Hi,
I want to use Xtend templates to generate C-Code with comments. I want to generate a initializer for a structure like this:
const testStruct bla =
{
1, /* id */
bool /* type */
}
And the comments should be aligned without knowing the size of the initialization field.
Currently my template looks like this:
'''
const const testStruct bla =
{
«getId()», /*id */
«getType()» /*id */
}
'''
I would appreciate a good idea. I love Xtend and its capabilities with the templates, but I need a solution to produce nice, readable code.
Sven Efftinge
unread,
Jul 5, 2015, 3:23:34 PM
7/5/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xtend...@googlegroups.com
You could use guavas Strings#padEnd like this;
import static extension com.google.common.base.Strings.*
> '''
> const const testStruct bla =
> {
> «(getId()+’,’).padEnd(42,‘ ‘)»/* id */
> «getType().padEnd(42,‘ ‘)»/* type */
> }
> '''
Reply all
Reply to author
Forward
0 new messages