Skip to content

Commit

Permalink
[flow] deriving eq, show from autocomplete_service_result
Browse files Browse the repository at this point in the history
Summary:
`eq` will be used in the next diff. `show` is useful for debugging.

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D55231179

fbshipit-source-id: e8723c9f1df1a13e032b261540ee5c21be89e873
  • Loading branch information
panagosg7 authored and facebook-github-bot committed Mar 22, 2024
1 parent 2488b95 commit b2831b1
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/hack_forked/utils/lsp/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
flow_exit_status
utils_core)
(preprocess
(pps lwt_ppx ppx_deriving.std ppx_deriving.enum)))
(pps lwt_ppx ppx_deriving.show ppx_deriving.std ppx_deriving.enum ppx_deriving.eq)))

(dirs
(:standard __tests__))
6 changes: 3 additions & 3 deletions src/hack_forked/utils/lsp/lsp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ module CodeActionClientCapabilities = struct
end

module CompletionItemTag = struct
type t = Deprecated [@value 1] [@@deriving enum]
type t = Deprecated [@value 1] [@@deriving enum, eq, show]
end

module CompletionClientCapabilities = struct
Expand Down Expand Up @@ -927,15 +927,15 @@ module Completion = struct
| Event [@value 23]
| Operator [@value 24]
| TypeParameter [@value 25]
[@@deriving enum]
[@@deriving enum, eq, show]

(* These numbers should match
* https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
*)
type insertTextFormat =
| PlainText [@value 1] (** the insertText/textEdits are just plain strings *)
| SnippetFormat [@value 2] (** wire: just "Snippet" *)
[@@deriving enum]
[@@deriving enum, eq, show]

type completionTriggerKind =
| Invoked [@value 1]
Expand Down
6 changes: 3 additions & 3 deletions src/hack_forked/utils/lsp/lsp.mli
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ module CodeActionClientCapabilities : sig
end

module CompletionItemTag : sig
type t = Deprecated [@value 1] [@@deriving enum]
type t = Deprecated [@value 1] [@@deriving enum, eq, show]
end

module CompletionClientCapabilities : sig
Expand Down Expand Up @@ -745,12 +745,12 @@ module Completion : sig
| Event (** 23 *)
| Operator (** 24 *)
| TypeParameter (** 25 *)
[@@deriving enum]
[@@deriving enum, eq, show]

type insertTextFormat =
| PlainText (** 1 -- the insertText/textEdits are just plain strings *)
| SnippetFormat (** 2 -- wire: just "Snippet" *)
[@@deriving enum]
[@@deriving enum, eq, show]

type completionTriggerKind =
| Invoked [@value 1]
Expand Down
4 changes: 3 additions & 1 deletion src/server/protocol/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
flow_server_utils
flow_typing
lsp ; hack
flow_exit))
flow_exit)
(preprocess
(pps ppx_deriving.eq ppx_deriving.show)))
5 changes: 4 additions & 1 deletion src/server/protocol/serverProt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ module Response = struct
return_ty: string;
}

type textedit = Loc.t * string
type textedit = Loc.t * string [@@deriving eq, show]

type insert_replace_edit = {
newText: string;
insert: Loc.t;
replace: Loc.t;
}
[@@deriving eq, show]

module Completion = struct
type completion_item = {
Expand All @@ -223,11 +224,13 @@ module Response = struct
log_info: string;
insert_text_format: Lsp.Completion.insertTextFormat;
}
[@@deriving eq, show]

type t = {
items: completion_item list;
is_incomplete: bool;
}
[@@deriving eq, show]
end

(** Which "type" of autocomplete this was. e.g. identifier vs type vs member.
Expand Down
3 changes: 3 additions & 0 deletions src/services/autocomplete/autocompleteService_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,17 @@ type 'r ac_result = {
result: 'r;
errors_to_log: string list;
}
[@@deriving eq, show]

type 'r autocomplete_service_result_generic =
| AcResult of 'r ac_result
| AcEmpty of string
| AcFatalError of string
[@@deriving eq, show]

type autocomplete_service_result =
ServerProt.Response.Completion.t autocomplete_service_result_generic
[@@deriving eq, show]

let jsdoc_of_def_loc { reader; ast; _ } def_loc =
loc_of_aloc ~reader def_loc |> Find_documentation.jsdoc_of_getdef_loc ~ast ~reader
Expand Down
3 changes: 3 additions & 0 deletions src/services/autocomplete/autocompleteService_js.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type 'r ac_result = {
result: 'r;
errors_to_log: string list;
}
[@@deriving eq, show]

type typing

Expand All @@ -34,9 +35,11 @@ type 'r autocomplete_service_result_generic =
| AcResult of 'r ac_result
| AcEmpty of string
| AcFatalError of string
[@@deriving eq, show]

type autocomplete_service_result =
ServerProt.Response.Completion.t autocomplete_service_result_generic
[@@deriving eq, show]

val autocomplete_get_results :
typing ->
Expand Down
2 changes: 1 addition & 1 deletion src/services/autocomplete/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
collections ; hack
flow_code_action)
(preprocess
(pps ppx_let)))
(pps ppx_deriving.eq ppx_deriving.show ppx_let)))

0 comments on commit b2831b1

Please sign in to comment.