From a85e0583bd562d2cfb86ce7f46a2f05ea1ac2154 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Tue, 22 Feb 2022 12:44:46 -0800 Subject: [PATCH] Show Vector/Map/Set doc comments when hovering over literals Summary: Previously we would should hover information on type hints, but not on literals. Add hover information for literals too. Differential Revision: D33826160 fbshipit-source-id: 3105627f8bc7b19e51a60af831f2940971f12003 --- hphp/hack/src/server/identifySymbolService.ml | 6 +++++ hphp/hack/test/hover/immmap_literal.php | 6 +++++ hphp/hack/test/hover/immmap_literal.php.exp | 24 +++++++++++++++++++ hphp/hack/test/hover/map_literal.php | 6 +++++ hphp/hack/test/hover/map_literal.php.exp | 33 +++++++++++++++++++++++++++ hphp/hack/test/hover/vector_literal.php | 6 +++++ hphp/hack/test/hover/vector_literal.php.exp | 24 +++++++++++++++++++ 7 files changed, 105 insertions(+) create mode 100644 hphp/hack/test/hover/immmap_literal.php create mode 100644 hphp/hack/test/hover/immmap_literal.php.exp create mode 100644 hphp/hack/test/hover/map_literal.php create mode 100644 hphp/hack/test/hover/map_literal.php.exp create mode 100644 hphp/hack/test/hover/vector_literal.php create mode 100644 hphp/hack/test/hover/vector_literal.php.exp diff --git a/hphp/hack/src/server/identifySymbolService.ml b/hphp/hack/src/server/identifySymbolService.ml index 0454322d25c..c62e866cfd4 100644 --- a/hphp/hack/src/server/identifySymbolService.ml +++ b/hphp/hack/src/server/identifySymbolService.ml @@ -253,6 +253,12 @@ let visitor = (remove_apostrophes_from_function_eval mid) ~is_method:true ~is_const:false + | Aast.ValCollection (kind, _, _) -> + let type_name = Aast.show_vc_kind kind in + process_class_id (pos, "\\HH\\" ^ type_name) + | Aast.KeyValCollection (kind, _, _) -> + let type_name = Aast.show_kvc_kind kind in + process_class_id (pos, "\\HH\\" ^ type_name) | Aast.EnumClassLabel (enum_name, label_name) -> begin match enum_name with diff --git a/hphp/hack/test/hover/immmap_literal.php b/hphp/hack/test/hover/immmap_literal.php new file mode 100644 index 00000000000..e24b5fd39fb --- /dev/null +++ b/hphp/hack/test/hover/immmap_literal.php @@ -0,0 +1,6 @@ + 1, 'b' => 2]; +$fm = new ImmMap($a); +``` + +or use the literal syntax + +``` +$fm = ImmMap {'a' => 1, 'b' => 2}; +``` + +@guide /hack/collections/introduction +@guide /hack/collections/classes diff --git a/hphp/hack/test/hover/map_literal.php b/hphp/hack/test/hover/map_literal.php new file mode 100644 index 00000000000..565bde1e5fd --- /dev/null +++ b/hphp/hack/test/hover/map_literal.php @@ -0,0 +1,6 @@ +