Skip to content

Commit 14fdf47

Browse files
committed
Refactor forLocalStamp
1 parent 090c6fb commit 14fdf47

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

analysis/src/Commands.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,12 @@ let references ~path ~line ~col =
124124
let result =
125125
match ProcessCmt.getFullFromCmt ~uri with
126126
| None -> Protocol.null
127-
| Some {package; file; extra} -> (
127+
| Some ({extra} as full) -> (
128128
let pos = Utils.protocolLineColToCmtLoc ~line ~col in
129129
match References.locItemForPos ~extra pos with
130130
| None -> Protocol.null
131131
| Some locItem ->
132-
let allReferences =
133-
References.allReferencesForLocItem ~package ~file ~extra locItem
134-
in
132+
let allReferences = References.allReferencesForLocItem ~full locItem in
135133
let allLocs =
136134
allReferences
137135
|> List.fold_left

analysis/src/References.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ let rec pathFromVisibility visibilityPath current =
359359
let pathFromVisibility visibilityPath tipName =
360360
pathFromVisibility visibilityPath (Tip tipName)
361361

362-
let forLocalStamp ~package ~file ~extra stamp tip =
362+
let forLocalStamp ~full:{file; extra; package} stamp tip =
363363
let env = ProcessCmt.fileEnv file in
364364
let open Infix in
365365
match
@@ -436,17 +436,16 @@ let forLocalStamp ~package ~file ~extra stamp tip =
436436
in
437437
(file.uri, local) :: externals)
438438

439-
let allReferencesForLocItem ~package ~file ~extra locItem =
439+
let allReferencesForLocItem ~full:({file; package} as full) locItem =
440440
match locItem.locType with
441441
| Typed (_, NotFound) | LModule NotFound | TopLevelModule _ | Constant _ -> []
442-
| TypeDefinition (_, _, stamp) ->
443-
forLocalStamp ~package ~file ~extra stamp Type
442+
| TypeDefinition (_, _, stamp) -> forLocalStamp ~full stamp Type
444443
| Typed (_, (LocalReference (stamp, tip) | Definition (stamp, tip)))
445444
| LModule (LocalReference (stamp, tip) | Definition (stamp, tip)) ->
446445
maybeLog
447446
("Finding references for " ^ Uri2.toString file.uri ^ " and stamp "
448447
^ string_of_int stamp ^ " and tip " ^ tipToString tip);
449-
forLocalStamp ~package ~file ~extra stamp tip
448+
forLocalStamp ~full stamp tip
450449
| LModule (GlobalReference (moduleName, path, tip))
451450
| Typed (_, GlobalReference (moduleName, path, tip)) -> (
452451
match ProcessCmt.fileForModule ~package moduleName with
@@ -461,10 +460,10 @@ let allReferencesForLocItem ~package ~file ~extra locItem =
461460
| Some stamp -> (
462461
match ProcessCmt.getFullFromCmt ~uri:env.qFile.uri with
463462
| None -> []
464-
| Some {file; extra} ->
463+
| Some full ->
465464
maybeLog
466465
("Finding references for (global) "
467466
^ Uri2.toString env.qFile.uri
468467
^ " and stamp " ^ string_of_int stamp ^ " and tip "
469468
^ tipToString tip);
470-
forLocalStamp ~package ~file ~extra stamp tip))))
469+
forLocalStamp ~full stamp tip))))

0 commit comments

Comments
 (0)