Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » instantiate object with type parameter(instantiate generic objects with xtext)
instantiate object with type parameter [message #1783870] Mon, 19 March 2018 18:00 Go to next message
Christian Deussen is currently offline Christian DeussenFriend
Messages: 2
Registered: March 2018
Junior Member
Hi,

I have a simple model with a generic class.
I want to create an xtext grammar which can instantiate the class with a type parameter.

TestClass returns TestClass:
        {TestClass}
        'TestClass'
        '{'
                ('typedAClass' typedAClass=[TypedClass<CustomTypeA>])?
                ('typedBClass' typedBClass=[TypedClass<CustomTypeB>])?
        '}';

TypedClass<T> returns TypedClass<T>:
        {TypedClass<T>}
        'TypedClass'
        ;


Is this possible with xtext? I havent been able to find an example using generic objects.

Thank you.
  • Attachment: model.png
    (Size: 95.96KB, Downloaded 20 times)
Re: instantiate object with type parameter [message #1783878 is a reply to message #1783870] Mon, 19 March 2018 19:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12388
Registered: July 2009
Senior Member
Can you please give more context

I would have expected something like (pseudo code)

GT: ref=Type (‚<‚ params+=Gt (‚,' params +=GT)*'<‚)?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: instantiate object with type parameter [message #1783879 is a reply to message #1783878] Mon, 19 March 2018 19:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12388
Registered: July 2009
Senior Member
And no xtext has no support for Emf generics if that is what you are looking for

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 19 March 2018 19:24]

Report message to a moderator

Re: instantiate object with type parameter [message #1783882 is a reply to message #1783879] Mon, 19 March 2018 20:38 Go to previous message
Christian Deussen is currently offline Christian DeussenFriend
Messages: 2
Registered: March 2018
Junior Member
Christian Dietrich wrote on Mon, 19 March 2018 19:23
And no xtext has no support for Emf generics if that is what you are looking for


Thank you. This answers my question.

I wonder if there is another way to to get emf generics to work.
Will binding the type parameter in concrete classes work?

TestClass returns TestClass:
	{TestClass}
	'TestClass'
	'{'
		('typedAClass' typedAClass=[ConcreteAClass])?
		('typedBClass' typedBClass=[ConcreteAClass])?
	'}';

ConcreteAClass returns ConcreteAClass:
	{ConcreteAClass}
	'ConcreteAClass'
;
  • Attachment: model2.png
    (Size: 12.84KB, Downloaded 16 times)
Previous Topic:Specifying Java version when running xtext.generator.GeneratorComponent from mwe2
Next Topic:Editor to outline view linking
Goto Forum:
  


Current Time: Fri Nov 16 12:44:16 GMT 2018

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

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

Back to the top