users@jaxb.java.net

Re: CodeModel : how to generate System.err.println()

From: Benoit Callebaut <benoit.callebaut_at_euphonynet.be>
Date: Tue, 12 Dec 2006 10:58:51 +0100

Kohsuke Kawaguchi a écrit :

> Benoit Callebaut wrote:
>
>> Hello,
>> While working on my plugin I was blocked on the following problem.
>>
>> I converted the following statement into XML : System.out.println(...);
>> It gives :
>> < <invocation method="*println*">
>> - <#> <namespace name="*err*">
>> <namespace name="*System*" />
>> </namespace>
>> <argument type="*String*" value="*NameService did not start
>> successfully"*" />
>> </invocation>
>>
>> I travel the XML code recursively and I can generate the CodeModel
>> elements while I enter the XML node or when I leave it.
>>
>> How can I generate the code model element for that snippet ?
>> The problems are :
>> 1) I don't know if "err" is a field of "System" or a class on which
>> I can invoke the static method "println".
>> 2) I don't know if "System" is a package or a class.
>>
>> Does it exist a way to query the CodeModel for such information ?
>
>
> Not really. I think you'd have to ask whoever typing those XML to give
> that to you.
>
> But do you really want the person to be programming by using XML?
>
That is for my plugin. Ican already parse the Java code into XML andnow
I need to transform this XML code in a CodeModel structure.
I don't plan to force people to program using XML. Rather, I want to let
them program in the usual way and afterward convert it to XML, add Jelly
tags (for pre-processing like the #ifdef in C) and use that result to
generate code.

The problem at the moment is that in my parser I cannot know if the
meaning of a qualified "thing" refers to aclass or a variable.
I need somebody for that and I don't want that.
I will dig into the Javac code to see how it is done.

Another concern: It is possible that in the "XML code", I try to refer
to a class not yet generated and thus not yet known to the model.

Does it exist a solution ? (I think to Outline)