Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Inferred enum issue(jvm inferred type enum strange exception)
Inferred enum issue [message #1097874] Fri, 30 August 2013 09:18 Go to next message
Christian Mauceri is currently offline Christian MauceriFriend
Messages: 22
Registered: May 2012
Location: Paris
Junior Member
Hi when I use this code to infer a java enumeration
 	acceptor.accept(element.toEnumerationType(qualifiedName,null)).initializeLater [
     		println("ENUM "+element.fullyQualifiedName);
      		documentation = element.documentation
      		
      		for (ec : element.enumBody.constant) {
 				literals +=	ec.toEnumerationLiteral(ec.name)
      		}
      		members += literals
  	]



I get this error :

!ENTRY org.eclipse.core.jobs 4 2 2013-08-30 11:13:24.571
!MESSAGE An internal error occurred during: "calculating highlighting".
!STACK 0
java.lang.UnsupportedOperationException
	at org.eclipse.emf.common.util.DelegatingEList$UnmodifiableEList.add(DelegatingEList.java:855)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.operator_add(JvmTypesBuilder.java:145)
	at com.ibm.jrules.xtext.iros.jvmmodel.IROSJvmModelInferrer$1.apply(IROSJvmModelInferrer.java:154)
	at com.ibm.jrules.xtext.iros.jvmmodel.IROSJvmModelInferrer$1.apply(IROSJvmModelInferrer.java:1)
	at org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:296)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:145)
	at org.eclipse.xtext.xbase.resource.BatchLinkableResource.getContents(BatchLinkableResource.java:124)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl$4.getChildren(ResourceImpl.java:519)
	at org.eclipse.emf.common.util.AbstractTreeIterator.hasAnyChildren(AbstractTreeIterator.java:97)
	at org.eclipse.emf.common.util.AbstractTreeIterator.hasNext(AbstractTreeIterator.java:85)
	at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.searchAndHighlightElements(XbaseHighlightingCalculator.java:126)
	at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.doProvideHighlightingFor(XbaseHighlightingCalculator.java:121)
	at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.provideHighlightingFor(XbaseHighlightingCalculator.java:98)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.MergingHighlightedPositionAcceptor.provideHighlightingFor(MergingHighlightedPositionAcceptor.java:51)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.reconcilePositions(HighlightingReconciler.java:92)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.modelChanged(HighlightingReconciler.java:292)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler$1$1.process(HighlightingReconciler.java:259)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler$1$1.process(HighlightingReconciler.java:1)
	at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:36)
	at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:218)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:79)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler$1.run(HighlightingReconciler.java:256)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


I use an ArrayList of JvmEnumerationLiteral instead of literals as shown below everything works fine and the java corresponding file of the enumeration id generated : do I incorrectly use literals ?
 	acceptor.accept(element.toEnumerationType(qualifiedName,null)).initializeLater [
     		println("ENUM "+element.fullyQualifiedName);
      		documentation = element.documentation
      		var test = new ArrayList<JvmEnumerationLiteral>
      		for (ec : element.enumBody.constant) {
 				test +=	ec.toEnumerationLiteral(ec.name)
      		}
      		members += test
  	]


Re: Inferred enum issue [message #1098014 is a reply to message #1097874] Fri, 30 August 2013 13:25 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevittFriend
Messages: 70
Registered: December 2012
Location: Belfast
Member
Adding the literals to members looks odd as they are both lists in the JvmDeclaredType so I'd expect only one or other should be used.

It works if you only add them to members instead of literals.
for (ec : element.enumBody.constant) {
      members += ec.toEnumerationLiteral(ec.name)
}

From the error it appears literals is read-only in this context.


Re: Inferred enum issue [message #1098166 is a reply to message #1098014] Fri, 30 August 2013 18:16 Go to previous messageGo to next message
Christian Mauceri is currently offline Christian MauceriFriend
Messages: 22
Registered: May 2012
Location: Paris
Junior Member
Thank you Ian very good point ! Do you have an idea why we have literals as they are read only ? We really lack documentation on inferring it is sometimes a real pain !
Re: Inferred enum issue [message #1098311 is a reply to message #1098166] Fri, 30 August 2013 23:24 Go to previous message
Ian McDevitt is currently offline Ian McDevittFriend
Messages: 70
Registered: December 2012
Location: Belfast
Member
No idea. A guess is literals is a filtered view of members rather than its own list.
You can have members in enums which aren't literals (for example methods) so literals may be a useful subset.
Previous Topic:Output folder
Next Topic:Modify the STRING Terminal
Goto Forum:
  


Current Time: Tue Apr 23 10:24:48 GMT 2024

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

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

Back to the top