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

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


Back to the top