Skip to content

Commit 2877f55

Browse files
committed
Define getUri on paths, and make the returned value not optional.
1 parent e808b50 commit 2877f55

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

analysis/src/ProcessCmt.ml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,9 +1256,8 @@ let getFullFromCmt ~uri =
12561256
let extraForModule ~package modname =
12571257
if Hashtbl.mem package.pathsForModule modname then
12581258
let paths = Hashtbl.find package.pathsForModule modname in
1259-
match SharedTypes.getSrc paths with
1260-
| None -> None
1261-
| Some src -> getFullFromCmt ~uri:(Uri2.fromPath src)
1259+
let uri = SharedTypes.getUri paths in
1260+
getFullFromCmt ~uri
12621261
else None
12631262

12641263
let fileForCmt ~moduleName ~cmt ~uri state =
@@ -1287,11 +1286,7 @@ let fileForModule modname ~package =
12871286
let paths = Hashtbl.find package.pathsForModule modname in
12881287
(* TODO: do better *)
12891288
let cmt = SharedTypes.getCmt ~interface:false paths in
1290-
let uri =
1291-
match SharedTypes.getSrc paths with
1292-
| Some sourcePath -> Uri2.fromPath sourcePath
1293-
| None -> Uri2.fromPath cmt
1294-
in
1289+
let uri = SharedTypes.getUri paths in
12951290
Log.log ("FINDING docs for module " ^ SharedTypes.showPaths paths);
12961291
Log.log ("FINDING " ^ cmt ^ " uri " ^ Uri2.toString uri);
12971292
match fileForCmt ~moduleName:modname ~cmt ~uri state with

analysis/src/References.ml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,6 @@ let definition ~file ~package stamp tip =
305305
maybeLog ("Inner uri " ^ Uri2.toString uri);
306306
Some (uri, loc))
307307

308-
let orLog message v =
309-
match v with
310-
| None ->
311-
maybeLog message;
312-
None
313-
| _ -> v
314-
315308
let definitionForLocItem ~full:{file; package} locItem =
316309
match locItem.locType with
317310
| Typed (_, _, Definition (stamp, tip)) -> (
@@ -335,13 +328,11 @@ let definitionForLocItem ~full:{file; package} locItem =
335328
None
336329
| TopLevelModule name -> (
337330
maybeLog ("Toplevel " ^ name);
338-
let open Infix in
339-
match
340-
Hashtbl.find_opt package.pathsForModule name
341-
|> orLog "No paths found" |?> getSrc |> orLog "No src found"
342-
with
331+
match Hashtbl.find_opt package.pathsForModule name with
343332
| None -> None
344-
| Some src -> Some (Uri2.fromPath src, Utils.topLoc src))
333+
| Some paths ->
334+
let uri = getUri paths in
335+
Some (uri, Utils.topLoc (Uri2.toPath uri)))
345336
| LModule (LocalReference (stamp, tip))
346337
| Typed (_, _, LocalReference (stamp, tip)) ->
347338
maybeLog ("Local defn " ^ tipToString tip);

analysis/src/SharedTypes.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ 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 =
133+
let getUri p =
134134
match p with
135-
| Impl {res} -> Some res
136-
| Namespace _ -> None
137-
| IntfAndImpl {resi} -> Some resi
135+
| Impl {res} -> Uri2.fromPath res
136+
| Namespace {cmt} -> Uri2.fromPath cmt
137+
| IntfAndImpl {resi} -> Uri2.fromPath resi
138138

139139
let getCmt ~interface p =
140140
match p with

0 commit comments

Comments
 (0)