Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » @Traced generate method returning string instead of a IGeneratorNode
@Traced generate method returning string instead of a IGeneratorNode [message #1779459] Mon, 08 January 2018 10:18 Go to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello guys,

in the following code
expr.expression.generate(context)

@Traced def dispatch  generate(FindExpression expr, GeneratorContext context) {

		
		val stream = if (expr.expression !== null) {
				'''«expr.expression.generate(context)».stream()«IF expr.condition !== null».filter(«expr.alias.name» -> «expr.condition.generate(context)»)«ENDIF»'''
			} else {
				// Table access case, the for all will iterate over a dao
				val table = expr.table
				if (expr.condition !== null) {					'''«table.daoName».«table.daoFind»(«generateWhereClause(expr.condition, expr.alias, context)»)''' 
				} else {
					'''«table.daoName».«table.daoGetAll»()'''
				}
			}

//more code using stream
	


returns a String whereas if do not use it within a assignment the return type is correct. It also work If I move the assignment within the '''«...»'''

Is this a bug? Or am I missing something?
Re: @Traced generate method returning string instead of a IGeneratorNode [message #1779460 is a reply to message #1779459] Mon, 08 January 2018 10:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you give the val an explict type.
maybe the type inference is not that strong


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: @Traced generate method returning string instead of a IGeneratorNode [message #1779465 is a reply to message #1779460] Mon, 08 January 2018 10:35 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
val stream ... as IGeneratorNode fails with a ClassCastException. So no...
My solution is to externalize the the content of the val in another method and to call that method, it is ok in this case because it is a small amount of code.
I investigated a bit and yes I think it is a type inference problem. Will try to build a small test case and file a bug.
Re: @Traced generate method returning string instead of a IGeneratorNode [message #1779476 is a reply to message #1779465] Mon, 08 January 2018 12:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
val IGeneratorNode stream = ....

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: @Traced generate method returning string instead of a IGeneratorNode [message #1779486 is a reply to message #1779476] Mon, 08 January 2018 15:01 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
nope it does not work same error as with the as
Re: @Traced generate method returning string instead of a IGeneratorNode [message #1779489 is a reply to message #1779486] Mon, 08 January 2018 15:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
ahh yes the active annotation cannot do that.
can you try

@Traced
def xxxx(Greeting g) {
val StringConcatenationClient node = if (1==1) '''''' else ''''''
return node
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: @Traced generate method returning string instead of a IGeneratorNode [message #1779521 is a reply to message #1779489] Tue, 09 January 2018 07:52 Go to previous message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hey Cristian,

sorry for the late reply. That indeed solved the problem.
Thank you for your help.
Previous Topic:Deploying xtext features
Next Topic:UI Content Assist Issue
Goto Forum:
  


Current Time: Thu Apr 18 04:16:06 GMT 2024

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

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

Back to the top