@@ -92,6 +92,7 @@ type type_params_context =
9292 | FunctionTypeTP
9393 | InferTP
9494 | ObjectMappedTypeTP
95+ | RecordTP
9596
9697class ['loc ] mapper =
9798 object (this )
@@ -190,6 +191,10 @@ class ['loc] mapper =
190191 | (loc , Match x ) -> id_loc this#match_statement loc x stmt (fun x -> (loc, Match x))
191192 | (loc , OpaqueType otype ) ->
192193 id_loc this#opaque_type loc otype stmt (fun otype -> (loc, OpaqueType otype))
194+ | (loc , RecordDeclaration record ) ->
195+ id_loc this#record_declaration loc record stmt (fun record ->
196+ (loc, RecordDeclaration record)
197+ )
193198 | (loc , Return ret ) -> id_loc this#return loc ret stmt (fun ret -> (loc, Return ret))
194199 | (loc , Switch switch ) ->
195200 id_loc this#switch loc switch stmt (fun switch -> (loc, Switch switch))
@@ -3280,6 +3285,62 @@ class ['loc] mapper =
32803285 else
32813286 (loc, { argument = argument'; comments = comments' })
32823287
3288+ method record_declaration _loc (record : ('loc, 'loc) Ast.Statement.RecordDeclaration.t ) =
3289+ let open Ast.Statement.RecordDeclaration in
3290+ let { id; tparams; implements; body; comments } = record in
3291+ let id' = this#identifier id in
3292+ let tparams' = map_opt (this#type_params ~kind: RecordTP ) tparams in
3293+ let implements' = map_opt this#class_implements implements in
3294+ let body' = this#record_body body in
3295+ let comments' = this#syntax_opt comments in
3296+ if
3297+ id == id'
3298+ && tparams == tparams'
3299+ && implements == implements'
3300+ && body == body'
3301+ && comments == comments'
3302+ then
3303+ record
3304+ else
3305+ {
3306+ id = id';
3307+ tparams = tparams';
3308+ implements = implements';
3309+ body = body';
3310+ comments = comments';
3311+ }
3312+
3313+ method record_body (record_body : ('loc, 'loc) Ast.Statement.RecordDeclaration.Body.t ) =
3314+ let open Ast.Statement.RecordDeclaration.Body in
3315+ let (loc, { body; comments }) = record_body in
3316+ let body' = map_list this#record_element body in
3317+ let comments' = this#syntax_opt comments in
3318+ if body == body' && comments == comments' then
3319+ record_body
3320+ else
3321+ (loc, { body = body'; comments = comments' })
3322+
3323+ method record_element (element : ('loc, 'loc) Ast.Statement.RecordDeclaration.Body.element ) =
3324+ let open Ast.Statement.RecordDeclaration.Body in
3325+ match element with
3326+ | Method (loc , meth ) ->
3327+ id_loc this#class_method loc meth element (fun meth -> Method (loc, meth))
3328+ | Property (loc , prop ) ->
3329+ id_loc this#record_property loc prop element (fun prop -> Property (loc, prop))
3330+
3331+ method record_property _loc (prop : ('loc, 'loc) Ast.Statement.RecordDeclaration.Property.t' ) =
3332+ let open Ast.Statement.RecordDeclaration.Property in
3333+ let { key; annot; default_value; comments } = prop in
3334+ let key' = this#identifier key in
3335+ let annot' = this#type_annotation annot in
3336+ let default_value' = map_opt this#expression default_value in
3337+ let comments' = this#syntax_opt comments in
3338+ if key' == key && annot' == annot && default_value' == default_value && comments' == comments
3339+ then
3340+ prop
3341+ else
3342+ { key = key'; annot = annot'; default_value = default_value'; comments = comments' }
3343+
32833344 method return _loc (stmt : ('loc, 'loc) Ast.Statement.Return.t ) =
32843345 let open Ast.Statement.Return in
32853346 let { argument; comments; return_out } = stmt in
0 commit comments