Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Annotation values generation 2.4 vs 2.5(I can't generate annotations values after switching to Xtext 2.5 because annotation values are implemented using UnmodifiableEList)
Annotation values generation 2.4 vs 2.5 [message #1273760] Thu, 20 March 2014 13:55 Go to next message
boris michalko is currently offline boris michalkoFriend
Messages: 2
Registered: March 2014
Junior Member
I'm trying to add annotation with values to method in my inferrer. It is working fine under 2.4 but under 2.5 I'm getting this error :
1024 [Worker-6] ERROR org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder  - Error initializing JvmElement
java.lang.UnsupportedOperationException
	at org.eclipse.emf.common.util.ECollections$UnmodifiableEList.add(ECollections.java:354)

Problems come from this piece of code:
anno.values+=annoValue

It look like annotation values are implemented using UnmodifiableEList
How should I generate annotations values under Xtext 2.5?

In my example is based on example in documentation http://www.eclipse.org/Xtext/documentation.html#JvmDomainmodel. In toMethod function I just added code to generate annotation and annotation values.
val anno = feature.toAnnotation(typeof(javax.xml.bind.annotation.XmlElement))
val annoValue = TypesFactory::eINSTANCE.createJvmTypeAnnotationValue
annoValue.operation = anno.annotation.getDeclaredOperations().filter(o|o.simpleName == "type").head
val jvmType = typeReferences.getTypeForName(java.lang.String, feature).type as JvmGenericTypeImplCustom
val literal = typeReferences.createTypeRef(jvmType)
annoValue.values += literal
anno.values+=annoValue
annotations+=anno
Re: Annotation values generation 2.4 vs 2.5 [message #1273923 is a reply to message #1273760] Thu, 20 March 2014 18:51 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13313
Registered: July 2009
Senior Member
hi,

the editable collection has changed its name

http://www.eclipse.org/forums/index.php/mv/msg/666933/1265742/#msg_1265742


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Annotation values generation 2.4 vs 2.5 [message #1274334 is a reply to message #1273923] Fri, 21 March 2014 10:09 Go to previous message
boris michalko is currently offline boris michalkoFriend
Messages: 2
Registered: March 2014
Junior Member
Thank you, it works now.
Previous Topic:mwe2 fragment documentation
Next Topic:formatting generated java-files after build
Goto Forum:
  


Current Time: Mon Jan 20 06:40:19 GMT 2020

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

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

Back to the top