Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] Getting annotations from AdviceElement

AspectJ ASTs do not support the resolving of bindings (see bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=146528).

So, Raffi's solution may not work (but I may be wrong).

Another possibility would be to subclass AjASTVisitor, which visits an
entire pointcut.  Currently, however, the DefaultPointcut class is
used in place of most of the standard pointcuts such as execution,
calls, etc.  So, you will have to walk the AST, look for pointcut
designators and when you find one you may have to use regular
expressions to tease out any potential annotations.

Let me know if this works or if you need any more specific help.

--a

On Fri, Jun 13, 2008 at 7:53 AM, Raffi Khatchadourian
<khatchad@xxxxxxxxxxxxxxxxxx> wrote:
> On Fri 13.Jun'08 at 15:37:47 +0100, Andr? Restivo wrote:
>>
>> On Fri, Jun 13, 2008 at 2:17 PM, Raffi Khatchadourian
>> <khatchad@xxxxxxxxxxxxxxxxxx> wrote:
>>>
>>> On Fri 13.Jun'08 at 14:00:11 +0100, Andr? Restivo wrote:
>>>>
>>>> I'm developing a plugin for eclipse and I need to get all
>>>> annotations present in an Advice.
>>>>
>>> Do you want the annotations associated with the declaration of the
>>> advice, or are you looking for annotations existing within the advice
>>> body?
>>
>> With the declaration of the advice.
>
> I am not sure what the deal is with the method you pointed out, that is,
> why its returning an empty array, but it may be possible to work around
> this problem by building (subclassing) your own AsmHierarchyBuilder, and
> then replacing the default AsmHierarchyBuilder with yours. For example,
> you can override this method as follows (it works sort of like a
> visitor):
>
> public boolean visit(MethodDeclaration methodDeclaration, ClassScope
>        scope) { super.visit(methodDeclaration, scope);
>
>        if (methodDeclaration instanceof AdviceDeclaration) {
>
>                AdviceDeclaration ad = (AdviceDeclaration) methodDeclaration;
>
>                MethodBinding aBinding = ad.binding;
>
>                //You may be able to obtain annotation information using this
>                //binding, not sure but give it a shot!
>        }
>
>        return false; //don't traverse further down the tree.
>
> }
>
> As I mentioned above, you may be able to get annotation information
> using that binding but I haven't tried it myself. Its probably not the
> best way to go about things but it may work at the end. Hope this helps!
>
> Raffi
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>


Back to the top