Skip to content

Commit

Permalink
Set printing env before printing value names.
Browse files Browse the repository at this point in the history
This might help with short-paths, we should introduce tests showing it.
  • Loading branch information
voodoos committed Sep 25, 2024
1 parent 0ce4c92 commit dcfe1d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/analysis/polarity_search.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ let execute_query query env dirs =
let execute_query_as_type_search ?(limit = 100) ~env ~query ~modules () =
execute_query query env modules
|> List.map ~f:(fun (cost, path, desc) ->
let path = Printtyp.rewrite_double_underscore_paths env path in
let name = Format.asprintf "%a" Printtyp.path path in
let name =
Printtyp.wrap_printing_env env @@ fun () ->
let path = Printtyp.rewrite_double_underscore_paths env path in
Format.asprintf "%a" Printtyp.path path
in
let doc = None in
let loc = desc.Types.val_loc in
let typ = desc.Types.val_type in
Expand Down
14 changes: 5 additions & 9 deletions src/analysis/type_search.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,16 @@ let compute_value query env _ path desc acc =
let open Merlin_sherlodoc in
let d = desc.Types.val_type in
let typ = sherlodoc_type_of env d in
let path = Printtyp.rewrite_double_underscore_paths env path in
let name = Format.asprintf "%a" Printtyp.path path in
let name =
Printtyp.wrap_printing_env env @@ fun () ->
let path = Printtyp.rewrite_double_underscore_paths env path in
Format.asprintf "%a" Printtyp.path path
in
let cost = Query.distance_for query ~path:name typ in
if cost >= 1000 then acc
else
(* let doc = get_doc doc_ctx env name in *)
let doc = None in
let loc = desc.Types.val_loc in
(* let typ =
Printtyp.wrap_printing_env env @@ fun () ->
Format.asprintf "%a"
(Type_utils.Printtyp.type_scheme env)
desc.Types.val_type
in *)
let typ = desc.Types.val_type in
let constructible = make_constructible name d in
Query_protocol.{ cost; name; typ; loc; doc; constructible } :: acc
Expand Down

0 comments on commit dcfe1d6

Please sign in to comment.