@@ -136,9 +136,9 @@ public class ${class.name}
136
136
final ${type} $field.name;
137
137
#end
138
138
#if ( $locationTracking )
139
- #if ( ! $class.superClass )
140
139
/** Locations */
141
140
final Map<Object, InputLocation> locations;
141
+ #if ( ! $class.superClass )
142
142
/** Location tracking */
143
143
final InputLocation importedFrom;
144
144
#end
@@ -170,14 +170,16 @@ public class ${class.name}
170
170
#if ( $locationTracking )
171
171
Map<Object, InputLocation> newlocs = builder.locations != null ? builder.locations : Collections.emptyMap();
172
172
Map<Object, InputLocation> oldlocs = builder.base != null && builder.base.locations != null ? builder.base.locations : Collections.emptyMap();
173
+ this.locations = Map.ofEntries(
174
+ Map.entry("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get("")),
175
+ #foreach ( $field in $allFields )
176
+ #set ( $sep = "#if($field!=${allFields[${allFields.size()} - 1]}),#end" )
177
+ Map.entry("${field.name}", newlocs.containsKey("${field.name}") ? newlocs.get("${field.name}") : oldlocs.get("${field.name}"))${sep}
178
+ #end
179
+ );
173
180
#if ( ! $class.superClass )
174
- this.locations = new HashMap<>();
175
181
this.importedFrom = builder.importedFrom;
176
- this.locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
177
182
#end
178
- #foreach ( $field in $class.getFields($version) )
179
- this.locations.put("${field.name}", newlocs.containsKey("${field.name}") ? newlocs.get("${field.name}") : oldlocs.get("${field.name}"));
180
- #end
181
183
#end
182
184
}
183
185
0 commit comments