From 11bc49a89ef036009e7c31d29c56ee02edb110d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Mon, 13 May 2024 16:48:30 +0200 Subject: [PATCH] Remove old occurrences code --- src/analysis/browse_tree.ml | 81 ------------------------------------ src/analysis/browse_tree.mli | 7 ---- 2 files changed, 88 deletions(-) diff --git a/src/analysis/browse_tree.ml b/src/analysis/browse_tree.ml index 2f5b78b22b..65f205b544 100644 --- a/src/analysis/browse_tree.ml +++ b/src/analysis/browse_tree.ml @@ -60,87 +60,6 @@ let dummy = { t_children = lazy [] } -let rec normalize_type_expr env type_expr = - match Types.get_desc type_expr with - | Types.Tconstr (path,_,_) -> - normalize_type_decl env (Env.find_type path env) - | _ -> raise Not_found - -and normalize_type_decl env decl = match decl.Types.type_manifest with - | Some expr -> normalize_type_expr env expr - | None -> decl - -let id_of_constr_decl c = `Id c.Types.cd_id - -let same_constructor env a b = - let name = function - | `Description d -> d.Types.cstr_name - | `Declaration d -> Ident.name d.Typedtree.cd_id - | `Extension_constructor ec -> Ident.name ec.Typedtree.ext_id - in - if name a <> name b then false - else begin - let get_decls = function - | `Description d -> - let ty = normalize_type_expr env d.Types.cstr_res in - begin match ty.Types.type_kind with - | Types.Type_variant (decls, _) -> - List.map decls ~f:id_of_constr_decl - | Type_open -> - [`Uid d.cstr_uid] - | _ -> assert false - end - | `Declaration d -> - [`Id d.Typedtree.cd_id] - | `Extension_constructor ext_cons -> - let des = Env.find_ident_constructor ext_cons.Typedtree.ext_id env in - [`Uid des.cstr_uid] - in - let a = get_decls a in - let b = get_decls b in - let same a b = match a, b with - | `Id a, `Id b -> Ident.same a b - | `Uid a, `Uid b -> Shape.Uid.equal a b - | _, _ -> false - in - List.exists a ~f:(fun id -> List.exists b ~f:(same id)) - end - -let all_occurrences path = - let rec aux acc t = - let acc = - let paths = Browse_raw.node_paths t.t_node in - let same l = Path.same path l.Location.txt in - match List.filter ~f:same paths with - | [] -> acc - | paths -> (t, paths) :: acc - in - if Browse_raw.has_attr ~name:"merlin.hide" t.t_node then - acc - else - List.fold_left ~f:aux ~init:acc (Lazy.force t.t_children) - in - aux [] - -let all_constructor_occurrences ({t_env = env; _},d) t = - let rec aux acc t = - let acc = - match Browse_raw.node_is_constructor t.t_node with - | Some d' when ( - (* Don't try this at home kids. *) - try same_constructor env d d'.Location.txt - with Not_found -> same_constructor t.t_env d d'.Location.txt - ) -> - {d' with Location.txt = t} :: acc - | _ -> acc - in - if Browse_raw.has_attr ~name:"merlin.hide" t.t_node then - acc - else - List.fold_left ~f:aux ~init:acc (Lazy.force t.t_children) - in - aux [] t - let all_occurrences_of_prefix path node = let rec path_prefix ~prefix path = Path.same prefix path || diff --git a/src/analysis/browse_tree.mli b/src/analysis/browse_tree.mli index 66713bba13..48c1c33d3c 100644 --- a/src/analysis/browse_tree.mli +++ b/src/analysis/browse_tree.mli @@ -45,12 +45,5 @@ val of_browse : Mbrowse.t -> t val dummy : t -val all_occurrences : Path.t -> t -> (t * Path.t Location.loc list) list -val all_constructor_occurrences : - t * [ `Description of Types.constructor_description - | `Declaration of Typedtree.constructor_declaration - | `Extension_constructor of Typedtree.extension_constructor ] - -> t -> t Location.loc list - val all_occurrences_of_prefix : Path.t -> Browse_raw.node -> (Path.t Location.loc * Longident.t) list