[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.jdt] Re: Annotations in Eclipse (Europa)
|
"David Goodenough" <david.goodenough@xxxxxxxxxxxxx> wrote in message
news:fbpt81$29d$1@xxxxxxxxxxxxxxxxxxxx
>I am trying to use annotations in Eclipse, and I am stuck.
>
> I have a workplace with a project within which I have defined a couple
> of annotation processors, the annotation classes, and some classes which
> use the annotations. I have made sure that I have started Eclipse with
> a Version 6 JVM (a Sun one) and I have enabled annotation processing for
> this project. But nothing happens, and the processor is never invoked
> (as far as I can tell - at least there are no errors and nothing gets
> generated).
Heh. I was just in the process of writing up an enhancement request for
features to support this situation :-)
You're right, it can be quite hard to debug what's going on when processing
isn't happening.
But I think you may have gotten off on the wrong foot here, by putting your
processors, annotations, and annotated code all in the same project. If I
correctly understand what you mean, that will not, in general, work.
Think of the processors as being part of the compiler, not part of what is
being compiled. So you can't put the processor code in the same project as
the code to be processed. Typically if you are just using a readymade
processor, it is in a plug-in or a jar file of its own; you would then refer
to that in the Factory Path of the project containing the annotated code to
be processed.
If you are developing annotation processors, you would typically have one
workspace (or at least a separate project) for your processors, and a
separate workspace containing the projects with annotated code.
> I did come across a reference to having to enable something specific to
> allow new classes to be generated while I am editing so that new classes
> can be generated by annotations and then referenced in the class I am
> editing, but I do not understand exactly what I am supposed to do to
> enable
> this.
I would avoid this for now. Stick with generating types during *build*,
which is the default. The distinction is simply that if type generation
during reconcile is enabled, then your annotation processors are able to
generate types as you work in the editor, rather than only when you build.
This is rarely necessary.
> Does anyone have a worked example of writing an annotation processor in
> Eclipse, and then using it - I guess I am missing some simple stage in
> the process.
You can take a look at our EclipseCon 2007 presentation on writing
processors at http://www.eclipsecon.org/2007/index.php?page=sub/&id=3618 .
The presentation file there contains a PowerPoint presentation and some
worked example code.
If you still have questions after looking at that I'd be delighted to help.
Feel free to post more questions to this newsgroup.
Thanks,
-Walter Harley
JDT APT team