Search code examples
xtend

Displaying Xtend source line numbers in stack traces


Because Xtend code is compiled to Java, the stack trace contains the line numbers of the generated Java source, not the original Xtend source:

package test

class Main
{
    def static void main(String[] args)
    {
        method // line #7
    }

    def static method()
    {
        throw new RuntimeException // Line #12
    }
}

The stack trace:

Exception in thread "main" java.lang.RuntimeException
    at test.Main.method(Main.java:10)
    at test.Main.main(Main.java:6)

My question: is it somehow possible to display the Xtend line numbers in the stack trace?

I ask it because it is not too comfortable to browse the Java code first, followed by figuring out the corresponding Xtend code (especially without an IDE).
Besides (in theory) the generated Java code may not be checked in to an SCM system.


Solution

  • Unfortunately, there is no way to do it currently without IDE. If you use Eclipse, you can copy/paste stack trace into Java Stack Trace Console (dropdown next to open consol button in console view) and then, when you click on any part of stacktrace, it will take you to proper place in xtend source - no need to manually backtrace it from generated java source.