Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Trace and TemplateNode
Xtext Trace and TemplateNode [message #1779354] Fri, 05 January 2018 17:20 Go to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello,

while generalizing the @Traced annotation to all my generators I encountered the following phenomenon:
			if ((java.util.Arrays.asList("foo", "bar").contains((TraceNode {
				TemplateNode {
					TextNode "value"
				}


The code is generated with these "TemplateNode" which seems to be the result of a toString on a GeneratedNode. The problem is that I did triple check my code and do not see a single method returning a String.

Any clue on how to debug this (I am using Xtext 2.12.0)

thanks
Re: Xtext Trace and TemplateNode [message #1779357 is a reply to message #1779354] Fri, 05 January 2018 17:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12322
Registered: July 2009
Senior Member
can you please give some more context?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Trace and TemplateNode [message #1779362 is a reply to message #1779357] Fri, 05 January 2018 17:39 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello Cristian thanks for replying.
Let me try to give more context:

the dispatch methods are of the form
Quote:

@Traced def dispatch generate(OrExpression expression, GeneratorContext context) {
'''«expression.left.generate(context)» || «expression.right.generate(context)»'''
}


As you can see no return type and the use of '''«...»'''

If I replace

Quote:

@Traced def dispatch generate(OrExpression expression, GeneratorContext context) {
'''«expression.left.generate(context)» || «expression.right.generate(context)»'''
}


by

Quote:

@Traced def dispatch generate(OrExpression expression, GeneratorContext context) {
'''true'''
}


then the produced code is correct otherwise I get
TraceNode {
				TemplateNode {
					TextNode "value"

which looks like a toString but I cannot figure where this is happening.
Would forcing the return type to StringConcatenationClient help?
Re: Xtext Trace and TemplateNode [message #1779369 is a reply to message #1779362] Fri, 05 January 2018 17:54 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
found it, there was deep inside the recursivity a call to a method with a String return type that itseld called a @Traced method. Solved by changing the return type of the String method to StringConcatenationClient.
Re: Xtext Trace and TemplateNode [message #1779370 is a reply to message #1779362] Fri, 05 January 2018 18:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12322
Registered: July 2009
Senior Member
i am asking on how to reproduce. return type should be IGeneratorNode i think.
neither do i see how you call the traced stuff from your doGenerate Method


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Trace and TemplateNode [message #1779384 is a reply to message #1779370] Fri, 05 January 2018 19:52 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hey Cristian,

let me try to describe the problem

	def generate(Activity activity, IFileSystemAccess2 fsa, GeneratorContext context) {
		fsa.generateTracedFile(activity.toClassFileName, activity, activity.generateBody(context))
	}


def StringConcatenationClient generateBody(Activity activity, GeneratorContext context) {
...

'''«statement.generate(context)»'''

....
}

@Traced def dispatch  generate(Statement statement, GeneratorContext context) {
		'''«statementGenerator.generate(statement, context)»'''
}


@Traced def dispatch  generate(AddStatement statement, GeneratorContext context) {
'''«faulty_method_generate(statement, context)»'''
}

def String faulty_method_generate(AddStatement statement, GeneratorContext context) {
'''«statementGenerator.generate(statement, context)»'''
}



The problem was that faulty_method_generate called in turn a @Traced method inducing a toString
Re: Xtext Trace and TemplateNode [message #1779385 is a reply to message #1779384] Fri, 05 January 2018 20:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12322
Registered: July 2009
Senior Member
So problem solved now?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Trace and TemplateNode [message #1779398 is a reply to message #1779385] Sat, 06 January 2018 08:10 Go to previous message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Yes as said in my message of 17:54. Problem solved :)
Thanks for the help
Previous Topic:BIRT Pie Chart
Next Topic:Unit Test with @Traced
Goto Forum:
  


Current Time: Wed Oct 17 11:55:01 GMT 2018

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

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

Back to the top