How to infer an annotation with a key-value pair [message #1064262] |
Tue, 18 June 2013 09:16  |
Eclipse User |
|
|
|
Hi all,
I'm using the model inferrer to infer an annotation, e.g., as follows:
...
annotations += model.toAnnotation("org.my.MyAnnotation")
...
I also managed to infer an annotation with a String value:
...
annotations += model.toAnnotation("org.my.MyAnnotation", "MyValue")
...
My question is, how to infer an annotation that has a key-value pair, e.g., @MyAnnotation(id = "MyId").
Thanks,
Oren
|
|
|
Re: How to infer an annotation with a key-value pair [message #1064302 is a reply to message #1064262] |
Tue, 18 June 2013 11:00   |
Eclipse User |
|
|
|
There is no helper method for that so far. You have to create the
appropriate Jvm<Type>AnnotationValue using the types factory, assign the
value and add it to the annotation as in
org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toAnnotation(EObject,
String, Object)
The name of the parameter is indeed a cross reference to a method of the
annotation type. So in addition, you have to find the operation with the
given name in the methods of the annotation type and set that as the
operation of the annotation value.
18.06.13 15:16, schrieb Oren Mishali:
> Hi all,
> I'm using the model inferrer to infer an annotation, e.g., as follows:
>
>
> ..
> annotations += model.toAnnotation("org.my.MyAnnotation")
> ..
>
>
> I also managed to infer an annotation with a String value:
>
>
> ..
> annotations += model.toAnnotation("org.my.MyAnnotation", "MyValue")
> ..
>
>
> My question is, how to infer an annotation that has a key-value pair,
> e.g., @MyAnnotation(id = "MyId").
>
> Thanks,
> Oren
>
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25923 seconds