Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Value of a field for an IAnnotation with K_QUALIFIED_NAME pair value
Value of a field for an IAnnotation with K_QUALIFIED_NAME pair value [message #258197] Tue, 20 January 2009 12:49
Eclipse UserFriend
Hi,
I have the following scenarion

public class MyClass {
public static final String NAME ="constant name";

@MyAnnotation(name =NAME)
private void method() {
}
}

I am parsing this code using IAnnotation.
What I have is an instance of IAnnotaiton and array of IMemberValuePair.
The valuePair contains one pair with
getMemberName() = MyAnnotation
getValueKind() = K_QUALIFIED_NAME
getValue() = "MyClass.NAME"

for (IMemberValuePair pair : pairs) {

if (pair.getMemberName().equals("name")) { //$NON-NLS-1$

if (pair.getValueKind() == IMemberValuePair.K_STRING) {

result = pair.getValue().toString();

} else if (pair.getValueKind() == IMemberValuePair.K_QUALIFIED_NAME)
{

// TODO: do something with this result. Resolve the value.

}

break;

}

}

If the annotation is @MyAnnotation(name = "constant name") I can get the
value "constant name".

But does anyone know how can I get the value "constant name" if the
annotatio is @MyAnnotation(name = NAME)? How could I determine the value of
NAME and property handle K_QUALIFIED_NAME?

Thank you in advance.

Best Regards,
Kiril
Previous Topic:Follow up on Java 6 blog on in.relation.to about Java 6 processors
Next Topic:How to get affected IJavaElements for rename refactorings?
Goto Forum:
  


Current Time: Tue Apr 22 15:45:25 EDT 2025

Powered by FUDForum. Page generated in 0.02520 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top