3

I am using ST-4.0.7.jar and my template looks like this:

backtrack_result(btresult) ::=<<
    <backtrack-result>
        <pattern id="$btresult.pattern.id$">$btresult.pattern.description$</pattern>
        <file>$btresult.file.file.path$</file>
        <line>$btresult.codeline.lineNr$</line>
        <method>$btresult.codeline.method.name$</method>        
    </backtrack-result>
>>

However when I look into my output file I just get

<method></method>

In BTResult:

public CodeLineInterface getCodeline() {
    return cl;
} 

In CodeLine:

public MethodInterface getMethod() {
    return method;
}

In Method:

public String getName() {
    return name;
}

I set a breakpoint in the codeline object for the getMethod Method and it is never called. So I conclude that somehow stringtemplate has a problem resolving the correct getter.

I added an STErrorListener an found that ST throws the following error:

STReportGenerator  - context [/report /backtrack_results /backtrack_result] 5:19 no such property or can't access: ju.no.need.toknow.BTResult.method
Caused by: org.stringtemplate.v4.misc.STNoSuchPropertyException: no such property: ju.no.need.toknow.BTResult.method
    at org.stringtemplate.v4.misc.ObjectModelAdaptor.throwNoSuchProperty(ObjectModelAdaptor.java:106)
    at org.stringtemplate.v4.misc.ObjectModelAdaptor.lookupMethod(ObjectModelAdaptor.java:99)
    at org.stringtemplate.v4.misc.ObjectModelAdaptor.getProperty(ObjectModelAdaptor.java:67)
    at org.stringtemplate.v4.Interpreter.getObjectProperty(Interpreter.java:1158)

What especially puzzles me about this: Why does it try to resolve to BTReult.method when the template says it should get btresult.codeline.method.name?

er4z0r
  • 4,711
  • 8
  • 42
  • 62
  • 1
    Just to make sure: your `getMethod` is a public instance method, right? – Sergey Kalinichenko Mar 01 '13 at 17:10
  • If you set a breakpoint in `getLineNr()`, is it hit? If not, I would set the breakpoint in `getCodeline()` to see what that is returning. – monty0 Mar 02 '13 at 06:06
  • getLineNr is apparently hit since I can see the correct value in my xml document. I was starting to wonder if it has something to do with the name of the method. Maybe some weird cornercase in conjunction with reflection that ST uses to guess the getter. – er4z0r Mar 02 '13 at 18:33

1 Answers1

2

OK. It was my own stupidity: while I did fix my template the code actually used an old template so it appeared to me that all my fixes did not work. OSI Layer 8 Problem ;-)

er4z0r
  • 4,711
  • 8
  • 42
  • 62