@@ -280,32 +280,9 @@ let typeDetail typ ~env ~full =
280
280
let makeId modulePath ~identifier =
281
281
identifier :: modulePath |> List. rev |> SharedTypes. ident
282
282
283
- (* *
284
- Get relative path to res/resi file
285
- *)
286
- let findRelativePath ~rootPath ~path =
287
- let open Filename in
288
- let realPath =
289
- match rootPath = " ." with
290
- | true -> Sys. getcwd ()
291
- | false ->
292
- if is_relative rootPath then concat (Sys. getcwd () ) rootPath else rootPath
293
- in
294
- let rec loop dirPath acc =
295
- match dirname dirPath = realPath with
296
- | true -> basename dirPath :: acc |> String. concat " /"
297
- | false -> (
298
- match dirPath with
299
- | "/" -> failwith " Failed to find relative path of package"
300
- | "." -> path
301
- | _ -> loop (dirname dirPath) (basename dirPath :: acc))
302
- in
303
-
304
- loop path []
305
-
306
283
let getSource ~rootPath ({loc_start} : Location.t ) =
307
284
let line, col = Pos. ofLexing loc_start in
308
- let filepath = findRelativePath ~ root Path ~path: loc_start.pos_fname in
285
+ let filepath = Files. relpath rootPath loc_start.pos_fname in
309
286
{filepath; line = line + 1 ; col = col + 1 }
310
287
311
288
let extractDocs ~entryPointFile ~debug =
@@ -360,8 +337,7 @@ let extractDocs ~entryPointFile ~debug =
360
337
filepath =
361
338
(match rootPath = " ." with
362
339
| true -> file.uri |> Uri. toPath
363
- | false ->
364
- findRelativePath ~root Path ~path: (file.uri |> Uri. toPath));
340
+ | false -> Files. relpath rootPath (file.uri |> Uri. toPath));
365
341
line = 1 ;
366
342
col = 1 ;
367
343
};
0 commit comments