users@jaxb.java.net

Re: Generating inline comments from plugins

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Thu, 10 Jan 2008 13:20:52 +0000

Thanks Aleksei.

I'm trying to use this to generate code along this following lines:

new MyType[] {
        new MyType(a,b,c), /* comment */
        new MyType(d,e,f), /* comment */
        new MyType(g,h,i), /* comment */
}

If I add the comment to the JArray using

array.add(direct("/* comment */"));

then of course it adds the comment as an expression, so I get this (note
the trailing commas):

new MyType[] {
        new MyType(a,b,c), /* comment */,
        new MyType(d,e,f), /* comment */,
        new MyType(g,h,i), /* comment */,
}

which doesn't compile.

It seems I need to construct a JExpression which contains both the new
MyType(..) and then the comment.

Any ideas how to achieve that?

kenny


Aleksei Valikov wrote:
> Hi.
>
>> In a JAXB2 plugin, does the codemodel api provide any means to generate
>> inline comments? It only seems to offer support for javadoc comments,
>> via the JDocComment class. I can't find any other comment-related
>> classes in the API.
>
> You can user directStatement("// my comment) in blocks for this purpose.
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>