Community
Participate
Working Groups
Build Identifier: M20101215-0800 I have a method like this: @Inject public Test(@Default Test1 processor) {...} I can get annotation (@Inject) for the method (Test) by calling ((IAnnotatable)method).getAnnotations(), but I didn't see a way to get @Default annotation from the same JDT model. Reproducible: Always
ILocalVariable implements IAnnotatable and so you should be able to use that route ?
You should be able to get it using the following code: ((ICodeAssist) this.compilationUnit).codeSelect(startPositionOfProcessor, "processor".length()) => this returns a ILocalVariable from which you can simply ask for getAnnotations(). Closing as INVALID.
If there is no "direct" way to get this ILocalVariable object from the existing model (IMethod), for the recommended API, what's the best way to get the offset for each parameter (I have to do my own scan?)? Thanks for the help.
(In reply to comment #3) > If there is no "direct" way to get this ILocalVariable object from the existing > model (IMethod), for the recommended API, what's the best way to get the offset > for each parameter (I have to do my own scan?)? Thanks for the help. Alternatively, you can try the DOM/AST route and (in particular org.eclipse.jdt.core.dom.IMethodBinding.getParameterAnnotations(int)) Olivier, do you have firm recommendation for Benson ?
(In reply to comment #4) > Alternatively, you can try the DOM/AST route and (in particular > org.eclipse.jdt.core.dom.IMethodBinding.getParameterAnnotations(int)) > > Olivier, do you have firm recommendation for Benson ? Not really. I think we should ease the retrieval of such annotations. I opened bug 334783 to request an API addition to ease this process.
Verified for 3.7M5
Benson, we are planning to add a new API on IMethod to ease the retrieval of such annotations. Let us know how you like it inside bug 334783.
(In reply to comment #7) > Benson, we are planning to add a new API on IMethod to ease the retrieval of > such annotations. Let us know how you like it inside bug 334783. Hi Olivier and Jay, Thanks for helping on this, the API looks good to me, since Kim is taking over the role, she will take a quick look as well, anyway, Thanks again.