I have been working on debug support for GSPs inside of STS. In order to make this happen, I needed to make some changes to the way the GroovyPageParser creates GSPs. The change I made causes GroovyPageParser to add an empty dummy class at the end of the generated Groovy ModuleNode. This empty class has an @LineNumber annotation attached to it that describes the line numbers and sets the source name.
This annotation is attached to a LineNumberTransform AST Transform, which will walk the ClassNodes and update line number attributes for all expressions so that they map back to the line numbers of the original GSP file.
This transformation also updates the Source Name attribute of the generated class file so that debuggers will have an easier time to map back to the original source code.
Also, this extra dummy class, annotation, and AST transform are only enabled if the environment variable "GROOVY_PAGE_ADD_LINE_NUMBERS=true" is set. This ensures backwards compatibility and no performance impact.