Skip to content

Commit 268200f

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 84aa247 commit 268200f

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
@@ -121,9 +121,9 @@ let declared_for_tip ~(stamps : Stamps.t) stamp (tip : Tip.t) =
121121
Stamps.find_module stamps stamp
122122
|> Option.map (fun x -> {x with Declared.item = ()})
123123

124-
(* The type a renamed type of an applied functor comes from, whose fields
125-
and constructors have source locations. *)
126-
let original_type_stamp (file : File.t) stamp =
124+
(* The declaration a renamed member of an applied functor comes from, such
125+
as a type whose fields and constructors have source locations. *)
126+
let original_stamp (file : File.t) stamp =
127127
match Hashtbl.find_opt file.renamed_stamps stamp with
128128
| Some original -> original
129129
| None -> stamp
@@ -141,12 +141,12 @@ let constructor_of_type ({item = {kind}} : Type.t Declared.t) name =
141141
| _ -> None
142142

143143
let get_field (file : File.t) stamp name =
144-
match Stamps.find_type file.stamps (original_type_stamp file stamp) with
144+
match Stamps.find_type file.stamps (original_stamp file stamp) with
145145
| None -> None
146146
| Some declared -> field_of_type declared name
147147

148148
let get_constructor (file : File.t) stamp name =
149-
match Stamps.find_type file.stamps (original_type_stamp file stamp) with
149+
match Stamps.find_type file.stamps (original_stamp file stamp) with
150150
| None -> None
151151
| Some declared -> constructor_of_type declared name
152152

@@ -163,7 +163,7 @@ let declared_uri ~state ~package (file : File.t) (declared : _ Declared.t) =
163163
its location, among the types declared there rather than read from a
164164
signature. *)
165165
let source_type ~state ~package (file : File.t) stamp =
166-
match Stamps.find_type file.stamps (original_type_stamp file stamp) with
166+
match Stamps.find_type file.stamps (original_stamp file stamp) with
167167
| Some declared -> Some (file, declared)
168168
| None -> (
169169
match Stamps.find_type file.stamps stamp with
@@ -482,11 +482,7 @@ type references = {
482482

483483
let for_local_stamp ~state ~full:{file; extra; package} stamp (tip : Tip.t) =
484484
let env = Query_env.from_file file in
485-
let stamp =
486-
match Hashtbl.find_opt file.renamed_stamps stamp with
487-
| Some original -> original
488-
| None -> stamp
489-
in
485+
let stamp = original_stamp file stamp in
490486
match
491487
match tip with
492488
| Constructor name ->

0 commit comments

Comments
 (0)