Skip to content

Commit 4eb8ed2

Browse files
Catherine Gasnierfacebook-github-bot
Catherine Gasnier
authored andcommitted
refactor: new helper path_to_relative_path
Reviewed By: mheiber Differential Revision: D71189337 fbshipit-source-id: 9c5b3292cf57256ca08718691605972bf586cf40
1 parent 2b41e2e commit 4eb8ed2

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

hphp/hack/src/client/ide_service/clientIdeDaemon.ml

+7-12
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ let get_errors_for_path (istate : istate) (path : Relative_path.t) : Errors.t =
637637
let ctx = make_singleton_ctx istate.icommon entry in
638638
get_user_facing_errors ~ctx ~error_filter:istate.error_filter ~entry
639639

640+
let path_to_relative_path path =
641+
path |> Path.to_string |> Relative_path.create_detect_prefix
642+
640643
(** handle_request invariants: Messages are only ever handled serially; we never
641644
handle one message while another is being handled. It is a bug if the client sends
642645
anything other than [Initialize_from_saved_state] as its first message. Upon
@@ -736,16 +739,12 @@ let handle_request
736739
(Initialized istate, Ok ())
737740
(* didClose *)
738741
| (During_init dstate, Did_close file_path) ->
739-
let path =
740-
file_path |> Path.to_string |> Relative_path.create_detect_prefix
741-
in
742+
let path = path_to_relative_path file_path in
742743
( During_init
743744
{ dstate with dopen_files = close_file dstate.dopen_files path },
744745
Ok [] )
745746
| (Initialized istate, Did_close file_path) ->
746-
let path =
747-
file_path |> Path.to_string |> Relative_path.create_detect_prefix
748-
in
747+
let path = path_to_relative_path file_path in
749748
let errors =
750749
Errors.get_sorted_error_list (get_errors_for_path istate path)
751750
in
@@ -763,9 +762,7 @@ let handle_request
763762
Ok diagnostics )
764763
(* didOpen or didChange *)
765764
| (During_init dstate, Did_open_or_change { file_path; file_contents }) ->
766-
let path =
767-
file_path |> Path.to_string |> Relative_path.create_detect_prefix
768-
in
765+
let path = path_to_relative_path file_path in
769766
let dstate = open_or_change_file_during_init dstate path file_contents in
770767
(During_init dstate, Ok ())
771768
| (Initialized istate, Did_open_or_change document) ->
@@ -1140,9 +1137,7 @@ let handle_request
11401137
Hence, we construct temporary entry to reflect the file which
11411138
contained the target of the resolve. *)
11421139
HackEventLogger.completion_call ~method_name:"Completion_resolve_location";
1143-
let path =
1144-
file_path |> Path.to_string |> Relative_path.create_detect_prefix
1145-
in
1140+
let path = path_to_relative_path file_path in
11461141
let ctx = make_empty_ctx istate.icommon in
11471142
let (ctx, entry) = Provider_context.add_entry_if_missing ~ctx ~path in
11481143
let result =

0 commit comments

Comments
 (0)