Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext2/Xbase] Constructors for Entities in DomainModel example are not working
[Xtext2/Xbase] Constructors for Entities in DomainModel example are not working [message #699488] Thu, 21 July 2011 16:13 Go to next message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
Hi,

I have problems with constructors for own entities.
Given the following model

package p1
{
	entity E1
	{
		op op1 () : int
		{
			val a1 = new Double('')
			val a2 = new E1()
			val a3 = new p1.E1()
		}
	}
}



the constructor for var a1 is working, but the both other are not.

Any ideas?

Ingo

[Updated on: Thu, 21 July 2011 16:14]

Report message to a moderator

Re: [Xtext2/Xbase] Constructors for Entities in DomainModel example aree not working [message #699524 is a reply to message #699488] Thu, 21 July 2011 17:19 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Ingo,

there are no constructors inferred for entities. It's not implemented.
Please have a look at the DomainmodelJvmInferrer and add support for
constructors there.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 21.07.11 18:13, Ingo Meyer wrote:
> Hi,
>
> I have problems with constructors for own entities.
> Given the following model
>
>
> package p1
> {
> entity E1
> {
> op op1 () : int
> {
> val a1 = new Double('')
> val a2 = new E1()
> val a3 = new p1.E1()
> }
> }
> }
>
>
>
> the constructor for var a1 is working, but the both other are not.
>
> Any ideas?
>
> Ingo
Re: [Xtext2/Xbase] Constructors for Entities in DomainModel example aree not working [message #699526 is a reply to message #699524] Thu, 21 July 2011 17:29 Go to previous messageGo to next message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
That was my first step and I've done that already, but maybe wrong!?

here is the method, can you please check?

	def dispatch Iterable<JvmDeclaredType> transform(Entity entity) {
		val jvmClass = typesFactory.createJvmGenericType 
		jvmClass.simpleName = entity.name
		jvmClass.packageName = entity.packageName
		entity.associatePrimary(jvmClass)
		jvmClass.visibility = JvmVisibility::PUBLIC
		
		if (entity.superType != null)
			jvmClass.superTypes += cloneWithProxies(entity.superType)
				
		val jvmConstructor = typesFactory.createJvmConstructor
		jvmConstructor.simpleName = entity.name
		jvmClass.members += jvmConstructor
		
		for(f : entity.features) {
			transform(f, jvmClass)
		} 
		
		newArrayList(jvmClass as JvmDeclaredType) 	 
	}


thanks,
Ingo
Re: [Xtext2/Xbase] Constructors for Entities in DomainModel example aree not working [message #699563 is a reply to message #699526] Thu, 21 July 2011 19:21 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Ingo,

the code looks good to me (except the missing visibility, but that
shouldn't matter for your example). I think it may be a bug in the
scoping implementation of Xbase. Could you please file a ticket?

Thanks,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 21.07.11 19:29, Ingo Meyer wrote:
> That was my first step and I've done that already, but maybe wrong!?
>
> here is the method, can you please check?
>
>
> def dispatch Iterable<JvmDeclaredType> transform(Entity entity) {
> val jvmClass = typesFactory.createJvmGenericType jvmClass.simpleName =
> entity.name
> jvmClass.packageName = entity.packageName
> entity.associatePrimary(jvmClass)
> jvmClass.visibility = JvmVisibility::PUBLIC
>
> if (entity.superType != null)
> jvmClass.superTypes += cloneWithProxies(entity.superType)
>
> val jvmConstructor = typesFactory.createJvmConstructor
> jvmConstructor.simpleName = entity.name
> jvmClass.members += jvmConstructor
>
> for(f : entity.features) {
> transform(f, jvmClass)
> }
> newArrayList(jvmClass as JvmDeclaredType) }
>
>
> thanks,
> Ingo
Re: [Xtext2/Xbase] Constructors for Entities in DomainModel example aree not working [message #699568 is a reply to message #699563] Thu, 21 July 2011 19:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you have to adapt org.eclipse.xtext.example.domainmodel.naming.DomainmodelQualifiedNameProvider too

	
QualifiedName qualifiedName(JvmConstructor type) {
    return converter.toQualifiedName(type.getQualifiedName());
}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext2/Xbase] Constructors for Entities in DomainModel example aree not working [message #699848 is a reply to message #699568] Fri, 22 July 2011 13:12 Go to previous message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
That does the trick,

Many Thanks
Previous Topic:getting started with xdoc
Next Topic:standalone parser and generator
Goto Forum:
  


Current Time: Thu Apr 25 21:24:59 GMT 2024

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

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

Back to the top