yep ```sb``` is the StringBuilder used internally by the ```CompactPrinter```. So I let the ```CompactPrinter``` do its job and when I need to insert a java expression, I just have to get the string builded by the ```CompactPrinter```, escaped it, do the concatenation and then reset the state of the internal StringBuilder (by creating a new one) and I let the ```CompactPrinter``` continue to do its job.

My goal was really to avoid to reimplement the ```CompactPrinter``` and decrease the maintenance cost of this class. If the closure team does changes in the ```CompactPrinter``` (support for new rules or bug fixing), we don't have to worry to update our printer to reflect these changes