antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
955 stars 231 forks source link

I think that STGroupDir should delegate all file loading to STGroupFile instances, before mapping the CompiledSTs. #272

Closed rwperrott closed 3 years ago

rwperrott commented 3 years ago

My problem is a ST::groupThatCreatedThisInstance reference, for CompiledSTs loaded by a STGroupDir, is frankly useless for logging and debugging, because to get the actual file URL, requires stupidly redundant and costly re-testing, with url.openStream(), for the actual .stg or .st file URL.

If STGroupDir delegated all file loading to STGroupFile instances, the CompiledSTs could still be stored in the STGroupDir ::templates map, but would have useful ST::groupThatCreatedThisInstance references, to support this an STTemplateFile class could be created, including optional header for use by RawGroupDir.

An alternative would be to add a file URL to all CompiledST objects, this could be possibly be null if groupThatCreatedThisInstance is an STGroupString instance.

rwperrott commented 3 years ago

I'll post a different way to fix this.