extending the compiler to add an error [message #201097] |
Fri, 15 April 2005 17:12  |
Eclipse User |
|
|
|
Originally posted by: jon.nall.gmail.com
Hello.
I'd like to know if it's possible to extend the eclipse compiler such
that I can add a new error. Specifically, I want to flag an error when
a class field has a given annotation and is marked as final. For
instance if my annotation was of type NonFinalAnnotation, the following
would produce a compiler error:
class Bar
{
@NonFinalAnnotation final int foo;
}
I don't mind having a checkbox somewhere to enable this checking, but
I'd like for the check to occur without user intervention.
What are my options (if any)?
Thanks,
nall.
|
|
|
|
Re: extending the compiler to add an error [message #203153 is a reply to message #202342] |
Wed, 11 May 2005 13:00  |
Eclipse User |
|
|
|
Basically, with APT you can get all of the of the Declarations annotated
with your Annotation Type. Then for each Declaration get its Modifiers. Then
see if the Modifiers contains Modifer.FINAL. If it does, use the
Messager.printError() to add whatever error message you like.
Right now this requires your build to run the apt tool from sun that comes
with the JDK. In the near future this will be a part of the JDT.
Tim
"Philippe Mulet" <philippe_mulet@fr.ibm.com> wrote in message
news:d57kmb$foj$1@news.eclipse.org...
> This feels like this task could be eased by using the ongoing APT effort.
> Maybe someone from APT team could comment on this.
> Basically, APT stands for annotation processing tools, and allows you to
> describe and plug custom annotation processors.
> http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted .html#ggviewer-offsite-nav-8991528
>
> There is an ongoing effort to leverage APT on top of Eclipse JDT.
>
> "Jon Nall" <jon.nall@gmail.com> wrote in message
> news:d3pb5e$3eh$1@news.eclipse.org...
>> Hello.
>> I'd like to know if it's possible to extend the eclipse compiler such
>> that I can add a new error. Specifically, I want to flag an error when
>> a class field has a given annotation and is marked as final. For
>> instance if my annotation was of type NonFinalAnnotation, the following
>> would produce a compiler error:
>>
>> class Bar
>> {
>> @NonFinalAnnotation final int foo;
>> }
>>
>>
>> I don't mind having a checkbox somewhere to enable this checking, but
>> I'd like for the check to occur without user intervention.
>>
>> What are my options (if any)?
>>
>> Thanks,
>> nall.
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03914 seconds