<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>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.</div><div>So, if that's actually the case, then you may want to look at the code here:</div><div>In the JAX-RS plugin, the JdtUtils is a utility class that provides some methods to abstract the JDT stuff:</div><div><a href="http://anonsvn.jboss.org/repos/jbosstools/trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java">http://anonsvn.jboss.org/repos/jbosstools/trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java</a>&nbsp;</div><div><br></div><div>You may be interested in the following methods in particular:</div><div><pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; ">public static Annotation resolveAnnotation(IAnnotation javaAnnotation, CompilationUnit ast)</pre><div><pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; ">public static Annotation resolveAnnotation(IMember member, CompilationUnit ast, String annotationName)</pre><div>depending on what you have in your hands: an IAnnotation object or just a name (in your example: "Column").</div></div></div><div>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 ;-)</div><div><br></div><div>Also, if you need an AST and don't have one yet, use this method:</div><div>&nbsp;<span class="Apple-style-span" style="font-family: monospace; white-space: pre-wrap; ">public static CompilationUnit parse(final ICompilationUnit compilationUnit, final IProgressMonitor progressMonitor)</span></div><div><br></div><div>HTH !</div><div><br></div><div>Best regards,<br><div>
/Xavier &nbsp;(twitter:@xcoulon)</div><div><br><br>
</div>
<br><div><div>On Jan 13, 2012, at 6:41 PM, Lincoln Baxter, III wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hey Richard,<br><br>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. <br>
<br><a href="https://issues.jboss.org/browse/FORGE-424">https://issues.jboss.org/browse/FORGE-424</a><br><br>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.<br>
<br>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.<br>
<br>We also can't tell if a Class literal is a class, interface, enum, etc... <br><br>~Lincoln<br><br><div class="gmail_quote">On Thu, Jan 12, 2012 at 11:46 PM, Richard Kennard <span dir="ltr">&lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Lincoln,<br>
<br>
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<br>
annotations from org.jboss.forge.parser.java.Annotations into 'proper' java.lang.annotation.Annotations.<br>
<br>
This is mostly working, but I am struggling with reifying two things:<br>
<br>
1. If the annotation's value is a Class<br>
2. If the annotation's value is another annotation<br>
<br>
The problem is the same in both cases - I am lacking the qualified name of the class/annotation. If they user enters:<br>
<br>
 &nbsp; &nbsp; @MyAnnotation( Column.class )<br>
<br>
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<br>
in ForgePropertyStyleTest. Could you take a look?<br>
<br>
Regards,<br>
<br>
Richard.<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.com/">http://ocpsoft.com</a><br><a href="http://scrumshark.com/">http://scrumshark.com</a><br>"Keep it Simple"<br>
_______________________________________________<br>forge-dev mailing list<br><a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/forge-dev<br></blockquote></div><br></div></body></html>