I think Forge only uses the parser - not the typechecker/resolver in JDT so he doesn't
have this context.
Also explains why forge is fast to parse since it doesn't resolve ;)
/max
On Jan 13, 2012, at 18:59, Xavier Coulon wrote:
Hi,
Maybe this could help: I've written the JAX-RS Tooling in JBossTools and as far as I
know, Forge also relies on Eclipse/JDT to parse the source code.
So, if that's actually the case, then you may want to look at the code here:
In the JAX-RS plugin, the JdtUtils is a utility class that provides some methods to
abstract the JDT stuff:
http://anonsvn.jboss.org/repos/jbosstools/trunk/ws/plugins/org.jboss.tool...
You may be interested in the following methods in particular:
public static Annotation resolveAnnotation(IAnnotation javaAnnotation, CompilationUnit
ast)
public static Annotation resolveAnnotation(IMember member, CompilationUnit ast, String
annotationName)
depending on what you have in your hands: an IAnnotation object or just a name (in your
example: "Column").
You'll get a result of type 'Annotation' which contains the fully qualified
name of the annotation, whatever its package. Under the hood, those utility methods use an
AST Visitor with bindings enabled. All JDT stuff ;-)
Also, if you need an AST and don't have one yet, use this method:
public static CompilationUnit parse(final ICompilationUnit compilationUnit, final
IProgressMonitor progressMonitor)
HTH !
Best regards,
/Xavier (twitter:@xcoulon)
On Jan 13, 2012, at 6:41 PM, Lincoln Baxter, III wrote:
> Hey Richard,
>
> There is a method in JavaSource called resolveType(); This method will return the
fully qualified type of the given Class name; however, there is a big issue here at the
moment. We cannot resolve wildcards, or classes from the same package that are in the
'package' visibility scope.
>
>
https://issues.jboss.org/browse/FORGE-424
>
> In these two cases, resolveType() will actually return the class name unchanged,
which is your signal to take desperate measures, because I don't think that we will be
fixing this in time for .Final. In the case of Column.class, I would start by assuming
that the class is what you expect, and in the case of other unknown types, at this point -
unfortunately - it's going to be up to you to figure out what that type is, and if
reasonable assumptions can be made.
>
> Sorry about this, I know it's a big gap, but it's going to take a lot of work
to fix this as you might be able to see in the issue. But definitely call resolveType() as
a first step, then you'll have to "worry" about handling potential issues
where the type information is not available.
>
> We also can't tell if a Class literal is a class, interface, enum, etc...
>
> ~Lincoln
>
> On Thu, Jan 12, 2012 at 11:46 PM, Richard Kennard
<richard(a)kennardconsulting.com> wrote:
> Lincoln,
>
> As you may recall, the new 'static Metawidget' scaffolding tries to reuse
Inspectors between the runtime/static worlds. To do this, it needs to reify the
> annotations from org.jboss.forge.parser.java.Annotations into 'proper'
java.lang.annotation.Annotations.
>
> This is mostly working, but I am struggling with reifying two things:
>
> 1. If the annotation's value is a Class
> 2. If the annotation's value is another annotation
>
> The problem is the same in both cases - I am lacking the qualified name of the
class/annotation. If they user enters:
>
> @MyAnnotation( Column.class )
>
> Then I need to know that it's actually a javax.persistence.Column.class. This is
a bit beyond me! I have left a couple of TODOs in ForgePropertyStyle and
> in ForgePropertyStyleTest. Could you take a look?
>
> Regards,
>
> Richard.
> _______________________________________________
> forge-dev mailing list
> forge-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/forge-dev
>
>
>
> --
> Lincoln Baxter, III
>
http://ocpsoft.com
>
http://scrumshark.com
> "Keep it Simple"
> _______________________________________________
> forge-dev mailing list
> forge-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/forge-dev
_______________________________________________
forge-dev mailing list
forge-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev