[stringtemplate-interest] StringTemplateGroup attribute renderer
bug + fix
Terence Parr
parrt at cs.usfca.edu
Fri Oct 14 09:33:55 PDT 2005
On Oct 14, 2005, at 1:49 AM, VAUCHER Laurent wrote:
> This morning (UTC+1) I tried to add my own AttributeRenderer to a
> StringTemplateGroup, and had the unpleasant suprise to receive a
> NullPointerException. After reading the code, it seems that a group
> where one attribute renderer is registered must either define renderes
> for all possible attribute types, or have a super group that does. I
> would have thought that in this case, the standard default renderer
> would be used, and since the result is an NPE, it might only be an
> edge-case that escaped.
Ack! Sorry about that. It's a bug...fixing now.
>
> Therefore, I successfully made a patch to StringTemplateGroup.java,
> around line 594 :
>
>
> if ( renderer==null ) {
> + if ( superGroup==null ) {
> + return null; // no parent? Stop.
> + }
> // no renderer registered for this class, check super
> group
> renderer =
> superGroup.getAttributeRenderer(attributeClassType);
> }
I did it slightly differently:
if ( renderer==null ) {
if ( superGroup!=null ) {
// no renderer registered for this class, check
super group
renderer = superGroup.getAttributeRenderer
(attributeClassType);
}
}
Anyway, thanks!
Ter
More information about the stringtemplate-interest
mailing list