Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JVM model inferrer comments out type reference
JVM model inferrer comments out type reference [message #1730991] Sun, 01 May 2016 20:17 Go to next message
Scott Forbes is currently offline Scott ForbesFriend
Messages: 4
Registered: February 2016
Junior Member
I'm using Xtext 2.9.2 and have come across an issue - if a generated class has a field or method parameter whose typeArgs refer to another generated class, then the type reference is correct, but is commented out and replaced with Object. The same code works fine in a method body. You can reproduce the issue with:

acceptor.accept(ele.toClass('main.Class1')
[
	members += ele.toField('listField', typeRef(List, typeRef('main.Class2')))
	members += ele.toConstructor
	[
		parameters += ele.toParameter('listParam',  typeRef(List, typeRef('main.Class2')))
		body = '''«typeRef(List, typeRef('main.Class2'))» listBody;'''
	]
])
acceptor.accept(ele.toClass('main.Class2') [])


This will generate Class1:

package main;

import java.util.List;
import main.Class2;

@SuppressWarnings("all")
public class Class1
{
	private /* List<main.Class2> */Object listField;

	public Class1(final /* List<main.Class2> */Object listParam)
	{
		List<Class2> listBody;
	}
}


Am I doing something wrong? I thought the toClass() initializer was called post indexing, or is something else going on?

I've just found that generating Class2 before Class1 works around the issue in this case, so it does seem to be something to do with indexing.

[Updated on: Sun, 01 May 2016 20:37]

Report message to a moderator

Re: JVM model inferrer comments out type reference [message #1730997 is a reply to message #1730991] Mon, 02 May 2016 03:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you should respect the two phases the inferrer has by moving the field stuff to the second closure

Acceptor.accept(xyz.toClass("name")) [
// add members here
]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JVM model inferrer comments out type reference [message #1730998 is a reply to message #1730997] Mon, 02 May 2016 03:41 Go to previous message
Scott Forbes is currently offline Scott ForbesFriend
Messages: 4
Registered: February 2016
Junior Member
Thanks, I knew I was doing something wrong - all that trouble caused by a misplaced bracket!
Previous Topic:Accessing Class annotation values from JvmDeclaredType?
Next Topic:Incorporating Validations at Runtime
Goto Forum:
  


Current Time: Fri Apr 26 03:31:20 GMT 2024

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

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

Back to the top