Ah. Nested annotations. Now I get it. I guess we don't support nested annotations at the moment.

JIRA this?

Until then, you may have to parse it yourself if you *really* need it, but hopefully we can get the JavaParser updated. Curious. Why do you need this?

~Lincoln

On Tue, Jan 17, 2012 at 5:40 PM, Richard Kennard <richard@kennardconsulting.com> wrote:
Lincoln,

Sorry if I'm being dumb! Calling...

    javaSource.getAnnotation(resolvedType)

...returns null. I'm not sure how it could work anyway, as we're talking about a *specific instance* of a *nested* annotation here, not just instantiating
any old annotation from its class name. So presumably it needs to parse something? Here's the JavaSource:

public class MockAnnotatedMethod
{
   @MockAnnotation( anAnnotation = @AnotherMockAnnotation(43)),
   public MockAnnotatedMethod()
   {
   }
}

So I can get @MockAnnotation just fine. But then...

    annotationSource.getLiteralValue("anAnnotation")

...returns the String...

    "@AnotherMockAnnotation(43)"

How can I parse that back into an AnnotationImpl? Maybe I need some method other than 'getLiteralValue', 'getStringValue' and 'getEnumValue'?

Regards,

Richard.

On 18/01/2012 3:37 AM, Lincoln Baxter, III wrote:
> I'm a bit confused here. You have the JavaSource where the annotation is located, so can't you call field/method/class.getAnnotation(type), which should
> then give you an AnnotationImpl that you can query?
>
> What am I missing?
> ~Lincoln
>
> On Sun, Jan 15, 2012 at 9:28 PM, Richard Kennard <richard@kennardconsulting.com <mailto:richard@kennardconsulting.com>> wrote:
>
>     Lincoln,
>
>     Okay that may work for me. I tried it and Class seems okay. However Annotations are still tricky. I can do...
>
>              if (Annotation.class.isAssignableFrom(returnType))
>              {
>                 String resolvedType = StringUtils.substringAfter(literalValue, "@");
>                 resolvedType = ((JavaSource<?>) this.annotationSource.getOrigin()).resolveType(resolvedType);
>
>     ...and 'resolvedType' is a fully qualified String. But how can I turn that String into a 'proper' AnnotationImpl Object? I need this so I can call
>     .getLiteralValue(...attribute...) on it.
>
>     Richard.
>
>     On 14/01/2012 4:41 AM, 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@kennardconsulting.com <mailto:richard@kennardconsulting.com>
>     <mailto:richard@kennardconsulting.com <mailto:richard@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@lists.jboss.org <mailto:forge-dev@lists.jboss.org> <mailto:forge-dev@lists.jboss.org <mailto:forge-dev@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@lists.jboss.org <mailto:forge-dev@lists.jboss.org>
>     > https://lists.jboss.org/mailman/listinfo/forge-dev
>
>     _______________________________________________
>     forge-dev mailing list
>     forge-dev@lists.jboss.org <mailto:forge-dev@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@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev



--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"