users@jaxb.java.net

Re: Generating inline comments from plugins

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Thu, 10 Jan 2008 15:15:43 +0000

ah, splendid. works a treat, thanks again.


Aleksei Valikov wrote:
> Hi.
>
>> 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?
>
> I'd simply implement JCommentedExpression which outputs a comment
> before the expression text. Take a look how J* classes are
> implemented, there's nothing difficult there.
>
> 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
>