Skip to content

Commit b01a587

Browse files
cknittclaude
andcommitted
Share the lookup of a renamed member's original stamp
Simplification: Find References repeated the lookup that fields and constructors already used to reach the declaration a renamed member of an applied functor comes from; both now use one helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent eecb764 commit b01a587

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

‎analysis/src/references.ml‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ let declared_for_tip ~(stamps : Stamps.t) stamp (tip : Tip.t) =
124124
Stamps.find_module stamps stamp
125125
|> Option.map (fun x -> {x with Declared.item = ()})
126126

127-
(* The type a renamed type of an applied functor comes from, whose fields
128-
and constructors have source locations. *)
129-
let original_type_stamp (file : File.t) stamp =
127+
(* The declaration a renamed member of an applied functor comes from, such
128+
as a type whose fields and constructors have source locations. *)
129+
let original_stamp (file : File.t) stamp =
130130
match Hashtbl.find_opt file.renamed_stamps stamp with
131131
| Some original -> original
132132
| None -> stamp
@@ -144,12 +144,12 @@ let constructor_of_type ({item = {kind}} : Type.t Declared.t) name =
144144
| _ -> None
145145

146146
let get_field (file : File.t) stamp name =
147-
match Stamps.find_type file.stamps (original_type_stamp file stamp) with
147+
match Stamps.find_type file.stamps (original_stamp file stamp) with
148148
| None -> None
149149
| Some declared -> field_of_type declared name
150150

151151
let get_constructor (file : File.t) stamp name =
152-
match Stamps.find_type file.stamps (original_type_stamp file stamp) with
152+
match Stamps.find_type file.stamps (original_stamp file stamp) with
153153
| None -> None
154154
| Some declared -> constructor_of_type declared name
155155

@@ -166,7 +166,7 @@ let declared_uri ~state ~package (file : File.t) (declared : _ Declared.t) =
166166
its location, among the types declared there rather than read from a
167167
signature. *)
168168
let source_type ~state ~package (file : File.t) stamp =
169-
match Stamps.find_type file.stamps (original_type_stamp file stamp) with
169+
match Stamps.find_type file.stamps (original_stamp file stamp) with
170170
| Some declared -> Some (file, declared)
171171
| None -> (
172172
match Stamps.find_type file.stamps stamp with
@@ -485,11 +485,7 @@ type references = {
485485

486486
let for_local_stamp ~state ~full:{file; extra; package} stamp (tip : Tip.t) =
487487
let env = Query_env.from_file file in
488-
let stamp =
489-
match Hashtbl.find_opt file.renamed_stamps stamp with
490-
| Some original -> original
491-
| None -> stamp
492-
in
488+
let stamp = original_stamp file stamp in
493489
match
494490
match tip with
495491
| Constructor name ->

0 commit comments

Comments
 (0)