Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge minus13 changes #60

Merged
merged 13 commits into from
May 6, 2024
12 changes: 4 additions & 8 deletions src/analysis/locate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ module Utils = struct
let files =
List.concat_map ~f:(fun synonym_pair ->
find_all_in_path_uncap ~src_suffix_pair:synonym_pair ~with_fallback
(Mconfig.source_path config) file
(Mconfig.source_path config @ Mconfig.hidden_source_path config) file
) Mconfig.(config.merlin.suffixes)
in
List.dedup_adjacent files ~cmp:String.compare
Expand Down Expand Up @@ -434,13 +434,9 @@ module Utils = struct
let find_file ~config ?with_fallback (file : File.t) =
find_file_with_path ~config ?with_fallback file @@
match file with
| ML _ | MLI _ | MLL _ -> Mconfig.source_path config
| CMT _ | CMTI _ ->
let Mconfig.{ visible; hidden } = Mconfig.build_path config in
visible @ hidden
| CMS _ | CMSI _ ->
let Mconfig.{ visible; hidden } = Mconfig.build_path config in
visible @ hidden
| ML _ | MLI _ | MLL _ -> Mconfig.source_path config @ Mconfig.hidden_source_path config
| CMT _ | CMTI _ -> Mconfig.build_path config @ Mconfig.hidden_build_path config
| CMS _ | CMSI _ -> Mconfig.build_path config @ Mconfig.hidden_build_path config
end

let move_to filename artifact =
Expand Down
8 changes: 7 additions & 1 deletion src/dot-merlin/dot_merlin_reader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ module Cache = File_cache.Make (struct
tell (`B (String.drop 2 line))
else if String.is_prefixed ~by:"S " line then
tell (`S (String.drop 2 line))
else if String.is_prefixed ~by:"BH " line then
tell (`BH (String.drop 3 line))
else if String.is_prefixed ~by:"SH " line then
tell (`SH (String.drop 3 line))
else if String.is_prefixed ~by:"SRC " line then
tell (`S (String.drop 4 line))
else if String.is_prefixed ~by:"CMI " line then
Expand Down Expand Up @@ -326,7 +330,7 @@ let empty_config = {
let prepend_config ~cwd ~cfg =
List.fold_left ~init:cfg ~f:(fun cfg (d : Merlin_dot_protocol.Directive.Raw.t) ->
match d with
| `B _ | `S _ | `CMI _ | `CMT _ | `INDEX _ as directive ->
| `B _ | `S _ | `BH _ | `SH _ | `CMI _ | `CMT _ | `INDEX _ as directive ->
{ cfg with to_canonicalize = (cwd, directive) :: cfg.to_canonicalize }
| `EXT _ | `SUFFIX _ | `FLG _ | `READER _
| (`EXCLUDE_QUERY_DIR | `USE_PPX_CACHE | `UNKNOWN_TAG _) as directive ->
Expand Down Expand Up @@ -455,6 +459,8 @@ let postprocess cfg =
match directive with
| `B path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `B p)
| `S path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `S p)
| `BH path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `BH p)
| `SH path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `SH p)
| `CMI path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `CMI p)
| `CMT path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `CMT p)
| `INDEX path ->
Expand Down
12 changes: 11 additions & 1 deletion src/dot-protocol/merlin_dot_protocol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ open Merlin_utils.Std.Result

module Directive = struct
type include_path =
[ `B of string | `S of string | `CMI of string | `CMT of string | `INDEX of string ]
[ `B of string
| `S of string
| `BH of string
| `SH of string
| `CMI of string
| `CMT of string
| `INDEX of string ]

type no_processing_required =
[ `EXT of string list
Expand Down Expand Up @@ -82,6 +88,8 @@ module Sexp = struct
begin match tag with
| "S" -> `S value
| "B" -> `B value
| "SH" -> `SH value
| "BH" -> `BH value
| "CMI" -> `CMI value
| "CMT" -> `CMT value
| "INDEX" -> `INDEX value
Expand Down Expand Up @@ -113,6 +121,8 @@ module Sexp = struct
match t with
| `B s -> ("B", single s)
| `S s -> ("S", single s)
| `BH s -> ("BH", single s)
| `SH s -> ("SH", single s)
| `CMI s -> ("CMI", single s)
| `CMT s -> ("CMT", single s)
| `INDEX s -> ("INDEX", single s)
Expand Down
8 changes: 7 additions & 1 deletion src/dot-protocol/merlin_dot_protocol.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ really do not want to load them. *)

module Directive : sig
type include_path =
[ `B of string | `S of string | `CMI of string | `CMT of string | `INDEX of string ]
[ `B of string
| `S of string
| `BH of string
| `SH of string
| `CMI of string
| `CMT of string
| `INDEX of string ]

type no_processing_required =
[ `EXT of string list
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/ocamlmerlin/new/new_commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ The return value has the shape:
command "dump"
~spec:[
arg "-what" "<source|parsetree|ppxed-source|ppxed-parsetree|typedtree\
|env|fullenv|browse|tokens|flags|warnings|exn|paths> \
|env|fullenv|browse|tokens|flags|warnings|exn|paths|hidden-paths> \
Information to dump ()"
(Marg.param "string" (fun what _ -> what));
]
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/ocamlmerlin/old/old_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ let customize config =
let merlin = config.merlin in
let merlin =
match var with
| `Build -> {merlin with build_path =
{ visible = f merlin.build_path.visible;
hidden = f merlin.build_path.hidden }}
| `Build -> {merlin with build_path = f merlin.build_path}
| `Source -> {merlin with source_path = f merlin.source_path}
in
{config with merlin}
Expand Down
20 changes: 11 additions & 9 deletions src/frontend/query_commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ let dump pipeline = function

| [`String "paths"] ->
let paths = Mconfig.build_path (Mpipeline.final_config pipeline) in
`Assoc [ "visible", `List (List.map paths.visible ~f:(fun s -> `String s));
"hidden", `List (List.map paths.hidden ~f:(fun s -> `String s)) ]
`List (List.map paths ~f:(fun s -> `String s))

| [`String "hidden-paths"] ->
let paths = Mconfig.hidden_build_path (Mpipeline.final_config pipeline) in
`List (List.map paths ~f:(fun s -> `String s))

| [`String "typedtree"] ->
let tree =
Expand All @@ -199,8 +202,8 @@ let dump pipeline = function
`String (to_string ())

| _ -> failwith "known dump commands: \
paths, exn, warnings, flags, tokens, browse, source, \
parsetree, ppxed-source, ppxed-parsetree, typedtree, \
paths, hidden-paths, exn, warnings, flags, tokens, browse, \
source, parsetree, ppxed-source, ppxed-parsetree, typedtree, \
env/fullenv (at {col:, line:})"

let reconstruct_identifier pipeline pos = function
Expand Down Expand Up @@ -809,10 +812,9 @@ let dispatch pipeline (type a) : a Query_protocol.t -> a =
| [] -> raise Not_found
| x :: xs ->
try
find_in_path_uncap (Mconfig.source_path config) x
find_in_path_uncap (Mconfig.source_path config @ Mconfig.hidden_source_path config) x
with Not_found -> try
let Mconfig.{visible; hidden} = Mconfig.build_path config in
find_in_path_uncap (visible @ hidden) x
find_in_path_uncap (Mconfig.build_path config @ Mconfig.hidden_build_path config) x
with Not_found ->
aux xs
in
Expand Down Expand Up @@ -840,11 +842,11 @@ let dispatch pipeline (type a) : a Query_protocol.t -> a =

| Path_list `Build ->
let config = Mpipeline.final_config pipeline in
Mconfig.(config.merlin.build_path.visible @ config.merlin.build_path.hidden)
Mconfig.(config.merlin.build_path @ config.merlin.hidden_build_path)

| Path_list `Source ->
let config = Mpipeline.final_config pipeline in
Mconfig.(config.merlin.source_path)
Mconfig.(config.merlin.source_path @ config.merlin.hidden_source_path)

| Occurrences (`Ident_at pos, scope) ->
let config = Mpipeline.final_config pipeline in
Expand Down
Loading
Loading