Skip to main content



      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 16:17 Go to next message
Eclipse UserFriend
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 16:37] by Moderator

Re: JVM model inferrer comments out type reference [message #1730997 is a reply to message #1730991] Sun, 01 May 2016 23:08 Go to previous messageGo to next message
Eclipse UserFriend
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
]
Re: JVM model inferrer comments out type reference [message #1730998 is a reply to message #1730997] Sun, 01 May 2016 23:41 Go to previous message
Eclipse UserFriend
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: Sun Jul 27 02:43:00 EDT 2025

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

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

Back to the top