From b2831b1387297839ed003be6aad81791c8f5aee9 Mon Sep 17 00:00:00 2001 From: Panos Vekris Date: Fri, 22 Mar 2024 13:06:51 -0700 Subject: [PATCH] [flow] deriving eq, show from autocomplete_service_result 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 --- src/hack_forked/utils/lsp/dune | 2 +- src/hack_forked/utils/lsp/lsp.ml | 6 +++--- src/hack_forked/utils/lsp/lsp.mli | 6 +++--- src/server/protocol/dune | 4 +++- src/server/protocol/serverProt.ml | 5 ++++- src/services/autocomplete/autocompleteService_js.ml | 3 +++ src/services/autocomplete/autocompleteService_js.mli | 3 +++ src/services/autocomplete/dune | 2 +- 8 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/hack_forked/utils/lsp/dune b/src/hack_forked/utils/lsp/dune index aa7d9def8ea..d602de326f4 100644 --- a/src/hack_forked/utils/lsp/dune +++ b/src/hack_forked/utils/lsp/dune @@ -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__)) diff --git a/src/hack_forked/utils/lsp/lsp.ml b/src/hack_forked/utils/lsp/lsp.ml index 03d18eac48f..67b67de07a4 100644 --- a/src/hack_forked/utils/lsp/lsp.ml +++ b/src/hack_forked/utils/lsp/lsp.ml @@ -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 @@ -927,7 +927,7 @@ 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 @@ -935,7 +935,7 @@ module Completion = struct 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] diff --git a/src/hack_forked/utils/lsp/lsp.mli b/src/hack_forked/utils/lsp/lsp.mli index 93cc404d8b7..61a60094faf 100644 --- a/src/hack_forked/utils/lsp/lsp.mli +++ b/src/hack_forked/utils/lsp/lsp.mli @@ -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 @@ -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] diff --git a/src/server/protocol/dune b/src/server/protocol/dune index 383596493eb..1a77ad8aebd 100644 --- a/src/server/protocol/dune +++ b/src/server/protocol/dune @@ -12,4 +12,6 @@ flow_server_utils flow_typing lsp ; hack - flow_exit)) + flow_exit) + (preprocess + (pps ppx_deriving.eq ppx_deriving.show))) diff --git a/src/server/protocol/serverProt.ml b/src/server/protocol/serverProt.ml index 3a430d38ff4..766db88c806 100644 --- a/src/server/protocol/serverProt.ml +++ b/src/server/protocol/serverProt.ml @@ -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 = { @@ -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. diff --git a/src/services/autocomplete/autocompleteService_js.ml b/src/services/autocomplete/autocompleteService_js.ml index ef317153108..a2efa76241f 100644 --- a/src/services/autocomplete/autocompleteService_js.ml +++ b/src/services/autocomplete/autocompleteService_js.ml @@ -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 diff --git a/src/services/autocomplete/autocompleteService_js.mli b/src/services/autocomplete/autocompleteService_js.mli index dadf98971e0..09546aa703d 100644 --- a/src/services/autocomplete/autocompleteService_js.mli +++ b/src/services/autocomplete/autocompleteService_js.mli @@ -17,6 +17,7 @@ type 'r ac_result = { result: 'r; errors_to_log: string list; } +[@@deriving eq, show] type typing @@ -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 -> diff --git a/src/services/autocomplete/dune b/src/services/autocomplete/dune index a15598f8a6b..a084348a27e 100644 --- a/src/services/autocomplete/dune +++ b/src/services/autocomplete/dune @@ -10,4 +10,4 @@ collections ; hack flow_code_action) (preprocess - (pps ppx_let))) + (pps ppx_deriving.eq ppx_deriving.show ppx_let)))