Skip to content

Commit eff807f

Browse files
committed
Simplify dump code
1 parent 2c2e5b7 commit eff807f

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

tools/src/tools.ml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -641,42 +641,27 @@ let extractEmbedded ~extensionPoints ~filename =
641641
])
642642
|> List.rev |> array
643643

644+
(** Dump the contents of a typed tree file *)
644645
let dump entryPointFile =
645646
let path =
646-
match Filename.is_relative entryPointFile with
647-
| true -> Unix.realpath entryPointFile
648-
| false -> entryPointFile
647+
if Filename.is_relative entryPointFile then Unix.realpath entryPointFile
648+
else entryPointFile
649649
in
650650
let result =
651-
match
651+
if
652652
FindFiles.isImplementation path = false
653653
&& FindFiles.isInterface path = false
654-
with
655-
| false -> (
656-
let path =
657-
if FindFiles.isImplementation path then
658-
let pathAsResi =
659-
(path |> Filename.dirname) ^ "/"
660-
^ (path |> Filename.basename |> Filename.chop_extension)
661-
^ ".resi"
662-
in
663-
if Sys.file_exists pathAsResi then (
664-
Printf.printf "preferring found resi file for impl: %s\n" pathAsResi;
665-
pathAsResi)
666-
else path
667-
else path
668-
in
654+
then
655+
Error
656+
(Printf.sprintf
657+
"error: failed to read %s, expected an .res or .resi file" path)
658+
else
669659
match Cmt.loadFullCmtFromPath ~path with
670660
| None ->
671661
Error
672662
(Printf.sprintf
673-
"error: failed to generate doc for %s, try to build the project"
674-
path)
675-
| Some full -> Ok (Print_tast.print_full full))
676-
| true ->
677-
Error
678-
(Printf.sprintf
679-
"error: failed to read %s, expected an .res or .resi file" path)
663+
"error: failed to dump for %s, try to build the project" path)
664+
| Some full -> Ok (Print_tast.print_full full)
680665
in
681666

682667
result

0 commit comments

Comments
 (0)