Skip to content

Commit

Permalink
Use Ast_helper.Sg.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
liam923 committed Nov 15, 2024
1 parent 27af03d commit 35e3fdb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
5 changes: 1 addition & 4 deletions src/analysis/ppx_expand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ let get_ppxed_source ~ppxed_parsetree ~pos ppx_kind_with_attr :
| Sig_item _, attr_loc ->
let exp =
Pprintast.signature Format.str_formatter
{ psg_modalities = [];
psg_items = List.rev !signature;
psg_loc = Location.none
};
(Ast_helper.Sg.mk (List.rev !signature));
Format.flush_str_formatter ()
in
{ code = exp; attr_start = attr_loc.loc_start; attr_end = attr_loc.loc_end }
Expand Down
12 changes: 4 additions & 8 deletions src/analysis/ptyp_of_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,10 @@ and signature_item (str_item : Types.signature_item) =
Sig.text [ Docstrings.docstring str Location.none ] |> List.hd

and signature (items : Types.signature) =
{ psg_modalities = [];
psg_items =
List.map (group_items items) ~f:(function
| Item item -> signature_item item
| Type (rec_flag, type_decls) ->
Ast_helper.Sig.type_ rec_flag type_decls);
psg_loc = Location.none
}
Ast_helper.Sg.mk
(List.map (group_items items) ~f:(function
| Item item -> signature_item item
| Type (rec_flag, type_decls) -> Ast_helper.Sig.type_ rec_flag type_decls))

and group_items (items : Types.signature_item list) =
let rec read_type type_acc items =
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/extension.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ let combine_sigs sigs : Parsetree.signature =
psig_loc = Location.none
})
in
{ psg_modalities = []; psg_items = items; psg_loc = Location.none }
Ast_helper.Sg.mk items

let register exts env =
(* Log errors ? *)
Expand Down
9 changes: 4 additions & 5 deletions src/kernel/mtyper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ let[@tail_mod_cons] rec type_signature caught env sg psg_modalities psg_loc =
sig_sloc = _
} =
Typemod.merlin_transl_signature env sg
{ psg_modalities; psg_items = [ parsetree_item ]; psg_loc }
(Ast_helper.Sg.mk ~loc:psg_loc ~modalities:psg_modalities
[ parsetree_item ])
in
let part_rev_sg = List.rev_append sig_type sg in
let item =
Expand Down Expand Up @@ -269,10 +270,8 @@ let type_interface config caught (parsetree : Parsetree.signature) =
}
: Typedtree.signature) =
Typemod.merlin_transl_signature Env.empty []
{ psg_modalities = parsetree.psg_modalities;
psg_items = [];
psg_loc = parsetree.psg_loc
}
(Ast_helper.Sg.mk ~modalities:parsetree.psg_modalities
~loc:parsetree.psg_loc [])
in
let value =
Interface_items
Expand Down

0 comments on commit 35e3fdb

Please sign in to comment.