Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Component/s: View technologies
-
Labels:None
Description
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.
I wanted to create a patch, but I am not familiar enough with git and so it was much easier to create a zip file that contains the updates and new files.
I changed GroovyPageParser and added LineNumber.java (the annotation) and LineNumberTransform.groovy (the associated AST Transform). I also include a few tests. These tests are for the transform only. They do not test the changes I made to GroovyPageParser.