Skip to main content



      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 07:50 Go to next message
Eclipse UserFriend
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 02:45 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Error on retrieval of features in *Generator.xtend [message #1818834 is a reply to message #1818830] Mon, 30 December 2019 04:23 Go to previous message
Eclipse UserFriend
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: Tue Jul 15 01:01:35 EDT 2025

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

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

Back to the top