[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jdt-apt-dev] Re: APT as api and tools.jar
|
>
> Yep. I wonder, if I were to reach into apt and call
> EnvironmentFactory.getEnvironment() would that be usable? (I have yet
> to test this I'm still learning about apt and the mirror api).
To answer my own question... yes! it works great! I made a crappy
little project builder and added it onto the demo project...
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException {
IProject project = getProject();
IJavaProject jproject = JavaCore.create(project);
IType fooType = jproject.findType("foo.Foo");
AnnotationProcessorEnvironment env
= EnvironmentFactory.getEnvironment(
fooType.getCompilationUnit(), jproject);
AnnotationTypeDeclaration demo
= (AnnotationTypeDeclaration)
env.getTypeDeclaration"demo.DemoAnnotation");
Collection foo = env.getDeclarationsAnnotatedWith(demo);
ClassDeclaration decl = (ClassDeclaration) env.getTypeDeclaration("foo.Foo");
ClassType type = decl.getSuperclass();
Collection mirrors = decl.getAnnotationMirrors();
Collection parameters = decl.getFormalTypeParameters();
return new IProject [] {};
}
>
> And what if I passed into EnvironmentFactory.getEnvironment() a java
> project that targeted 1.4? Would things degrade nicely (annotation and
> generic related methods return null) or would the whole thing be blow
> up in my face? I ask because if it's the case that I can go Eclipse
> independent using the mirror api on a 1.5 project it would be
> disappointing if I had to forgo the nice api for projects targeting
> say 1.4.
again it works but it doesn't degrade at all. Same builder above and I
changed the project compiler target to 1.4. The results were exactly
the same.
Fantastic tool!
Geoff