Skip to content

Commit 5396f79

Browse files
committed
remove findRelativePath
1 parent e5bb9f5 commit 5396f79

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

tools/src/tools.ml

+2-26
Original file line numberDiff line numberDiff line change
@@ -280,32 +280,9 @@ let typeDetail typ ~env ~full =
280280
let makeId modulePath ~identifier =
281281
identifier :: modulePath |> List.rev |> SharedTypes.ident
282282

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-
306283
let getSource ~rootPath ({loc_start} : Location.t) =
307284
let line, col = Pos.ofLexing loc_start in
308-
let filepath = findRelativePath ~rootPath ~path:loc_start.pos_fname in
285+
let filepath = Files.relpath rootPath loc_start.pos_fname in
309286
{filepath; line = line + 1; col = col + 1}
310287

311288
let extractDocs ~entryPointFile ~debug =
@@ -360,8 +337,7 @@ let extractDocs ~entryPointFile ~debug =
360337
filepath =
361338
(match rootPath = "." with
362339
| true -> file.uri |> Uri.toPath
363-
| false ->
364-
findRelativePath ~rootPath ~path:(file.uri |> Uri.toPath));
340+
| false -> Files.relpath rootPath (file.uri |> Uri.toPath));
365341
line = 1;
366342
col = 1;
367343
};

0 commit comments

Comments
 (0)