Skip to content

Commit a2c8eff

Browse files
committed
Refactor getSrc
1 parent 1708213 commit a2c8eff

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

analysis/src/References.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,9 @@ let allReferencesForLocItem ~full:({file; package} as full) locItem =
477477
let targetModuleReferences =
478478
match Hashtbl.find_opt package.pathsForModule moduleName with
479479
| None -> []
480-
| Some paths -> (
480+
| Some paths ->
481481
let moduleSrcToRef src = (Uri2.fromPath src, [Utils.topLoc src]) in
482-
match paths with
483-
| Impl {res} -> [moduleSrcToRef res]
484-
| IntfAndImpl {resi; res} -> [moduleSrcToRef resi; moduleSrcToRef res]
485-
| Namespace _ -> [])
482+
getSrc paths |> List.map moduleSrcToRef
486483
in
487484
List.append targetModuleReferences otherModulesReferences
488485
| Typed (_, _, NotFound) | LModule NotFound | Constant _ -> []

analysis/src/SharedTypes.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ let showPaths paths =
130130
| IntfAndImpl {cmti; resi; cmt; res} ->
131131
Printf.sprintf "IntfAndImpl(%s, %s, %s, %s)" cmti resi cmt res
132132

133+
let getSrc p =
134+
match p with
135+
| Impl {res} -> [res]
136+
| Namespace _ -> []
137+
| IntfAndImpl {resi; res} -> [resi; res]
138+
133139
let getUri p =
134140
match p with
135141
| Impl {res} -> Uri2.fromPath res

0 commit comments

Comments
 (0)