[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.jdt] Re: some puzzles about processing annotation by eclipse

"yangbo " <aximo.yang@xxxxxxxxxxxx> wrote in message 
news:24873c109b179e2119cb7d2bf0443862$1@xxxxxxxxxxxxxxxxxx
> Hello everybody£º
>    As me know,java has a annotation of "@Deprecated", when a method is 
> annotated by the "annotation",the text of method name in code editor has a 
> middle line .How can eclipse do that?
>    In our company ,somebody(A) develop basal codes,somebody(B) develop 
> business codes.However,B always use the public method of the class in 
> basal codes,but A don't exptect B to use the method. E.g: one class in 
> basal code named Util.class ,has doPost() and doGet(),which must be 
> public,A just want B to use doPost() nor doGet().
>    If,i(a member if A ) develop an annotation of "@open",and use this 
> annotation to method doPost(),then ,as soon as B to use the doGet() in 
> eclipse£¬some wrong will be throw,or by the Syntax Coloring£¬the doGet is 
> show with Bold font.of course £¬there must be a config to mask this effect 
> in some eclipse IDE£¬such as me.
>    The idea can be implement? If i plan to ,what do i need to learn?Is 
> there any links?

My first thought was to implement it as an annotation processor (APT) but 
that won't work, because you need to be analyzing the AST, not just the 
typesystem, in order to have access to every single method call.

One idea might be to implement it as a "validator".  There's an example at 
http://www.ddj.com/184405940, or you can just Google for "eclipse 
validator".

You might also explore using the JDT CompilationParticipant API, but this is 
fairly low level and you can easily burn your fingers :-)