[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.tools.jdt] How to make work this very simple example
|
- From: richard.fagot@xxxxxxxxx (Richard Fagot)
- Date: Wed, 16 Sep 2009 09:00:52 +0000 (UTC)
- Newsgroups: eclipse.tools.jdt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hi all,
I've just discover JDT-APT and I've tried to make my first annotation
which always print error message. Unfortunatelly it does not work. Can you
help me make it worked (I generate a simple jar with these three classes)
### Annotation ###
public @interface NoDuplicatedReturnType
{
}
### Processor ###
public class NoDuplicatedReturnTypeProcessor implements AnnotationProcessor
{
public NoDuplicatedReturnTypeProcessor(AnnotationProcessorEnvironment env)
{
_env = env;
}
public void process()
{
Messager messager = _env.getMessager();
messager.printError("houhou");
}
public AnnotationProcessorEnvironment getEnvironment()
{
return _env;
}
AnnotationProcessorEnvironment _env;
}
### Factory ###
public class NoDuplicatedReturnTypeProcessorFactory implements
AnnotationProcessorFactory
{
public Collection<String> supportedOptions() {
return Collections.emptyList();
}
public Collection<String> supportedAnnotationTypes() {
return annotations;
}
public AnnotationProcessor getProcessorFor(
Set<AnnotationTypeDeclaration> atds,
AnnotationProcessorEnvironment env)
{
return new NoDuplicatedReturnTypeProcessor( env );
}
private static ArrayList<String> annotations = new ArrayList<String>();
{
annotations.add( NoDuplicatedReturnType.class.getName() );
}
}