Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error on retrieval of features in *Generator.xtend(Features can be retrieved fine in validator, but not in the generator for a certain rule)
Error on retrieval of features in *Generator.xtend [message #1818693] Mon, 23 December 2019 12:50 Go to next message
Ebert Schoofs is currently offline Ebert SchoofsFriend
Messages: 2
Registered: December 2019
Junior Member
I'm trying to generate an DSL written in xtext to java using the provided classes and files, but can't retrieve one specific future of one specific rule.

The xtext rule of a Room looks as follows:
Room :
	'Room' name=ID
	'{'
		('cells' ':' '[' cells+=[Cell] (',' cells+=[Cell])* ']')
	'}'
;


But when I try to retrieve the cells in *Generator.xtend, it returns an empty array.
My code:
Room «room.name» = new Room();
	«FOR cell : room.cells»
		Cell «cell.name» = this.getCellFromLoc(«cell.loc_x»,«cell.loc_y»);
		«room.name».addCell(«cell.name»);
		«cell.name».setRoom(«room.name»);
        «ENDFOR»


A room is defined in my DSL as follows:
Room r0
{
	cells : [c00,c01,c02]
}


Other features like the name, or the cells of other rules can be retrieved fine. The cells are surely added to the room, because in the validator we can retrieve them fine.

I'm sorry of this is a duplicate question, but I couldn't find it anywhere, not even in the FAQ.
Re: Error on retrieval of features in *Generator.xtend [message #1818830 is a reply to message #1818693] Mon, 30 December 2019 07:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi,

are you sure the model you test with dont have any errors

can you please provide a minimal but complete model and grammar?
are you sure you dont have any other code not shown here that removes the cells from its lists.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Error on retrieval of features in *Generator.xtend [message #1818834 is a reply to message #1818830] Mon, 30 December 2019 09:23 Go to previous message
Ebert Schoofs is currently offline Ebert SchoofsFriend
Messages: 2
Registered: December 2019
Junior Member
I'm sorry, this thread can be closed.

I found the culprit, there was a function in Validator which indeed deleted the elements of the list.
This is my first project in Java, and I forgot objects are passed by reference.
Previous Topic:Xtext Beginner Scoping/Referencing Problem
Next Topic:The future of Xtend ?
Goto Forum:
  


Current Time: Thu Mar 28 08:10:28 GMT 2024

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

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

Back to the top