Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JVMInferrer: define a typeParameter for a generated class(I want to generate a class with the jvmInverrer which has a generic type parameter.)
JVMInferrer: define a typeParameter for a generated class [message #1734818] Mon, 13 June 2016 10:08 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
I want to generate a class with the jvmInverrer which has a generic type parameter.
How could I do that ?
Re: JVMInferrer: define a typeParameter for a generated class [message #1734825 is a reply to message #1734818] Mon, 13 June 2016 10:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13188
Registered: July 2009
Senior Member
hi i have no idea if this is a supported usecase but at least in very simple cases it seems to work

TypesFactory.eINSTANCE.createJvmTypeParameter => [
				name = "T"
			]
accept(entity.toClass( entity.fullyQualifiedName )) [
			typeParameters += t
			documentation = entity.documentation
			if (entity.superType != null)
				superTypes += entity.superType.cloneWithProxies
			
			// let's add a default constructor
			members += entity.toConstructor []
			
			members += entity.toMethod("doWithT", t.typeRef) [
				parameters += entity.toParameter("t", t.typeRef) 
				body = '''return null;'''
			]
......


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JVMInferrer: define a typeParameter for a generated class [message #1734915 is a reply to message #1734825] Mon, 13 June 2016 16:23 Go to previous message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
Thank you very much
Previous Topic:project missing necessary xtext jars while launching workbench
Next Topic:Bundle Exception - Error when launching Eclipse Application
Goto Forum:
  


Current Time: Thu Nov 14 22:40:54 GMT 2019

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

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

Back to the top