Skip to content

Commit 9f30b6b

Browse files
committed
refactor
1 parent 14dd477 commit 9f30b6b

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

analysis/src/ProcessCmt.ml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -981,10 +981,8 @@ let getIterator (extra : extra) (file : File.t) =
981981
typ;
982982
}
983983

984-
let extraForStructureItems ~(file : File.t)
984+
let extraForStructureItems ~(iterator : Tast_iterator.iterator)
985985
(items : Typedtree.structure_item list) parts =
986-
let extra = extraForFile ~file in
987-
let iterator = getIterator extra file in
988986
items |> List.iter (iterator.structure_item iterator);
989987

990988
(* Log.log("Parts " ++ string_of_int(Array.length(parts))); *)
@@ -998,13 +996,10 @@ let extraForStructureItems ~(file : File.t)
998996
| Partial_class_expr () -> ()
999997
| Partial_module_type module_type ->
1000998
iterator.module_type iterator module_type
1001-
| Partial_structure _ | Partial_structure_item _ -> ());
1002-
extra
999+
| Partial_structure _ | Partial_structure_item _ -> ())
10031000

1004-
let extraForSignatureItems ~(file : File.t)
1001+
let extraForSignatureItems ~(iterator : Tast_iterator.iterator)
10051002
(items : Typedtree.signature_item list) parts =
1006-
let extra = extraForFile ~file in
1007-
let iterator = getIterator extra file in
10081003
items |> List.iter (iterator.signature_item iterator);
10091004
(* Log.log("Parts " ++ string_of_int(Array.length(parts))); *)
10101005
parts
@@ -1017,13 +1012,12 @@ let extraForSignatureItems ~(file : File.t)
10171012
| Partial_class_expr () -> ()
10181013
| Partial_module_type module_type ->
10191014
iterator.module_type iterator module_type
1020-
| Partial_structure _ | Partial_structure_item _ -> ());
1021-
extra
1015+
| Partial_structure _ | Partial_structure_item _ -> ())
10221016

1023-
let extraForCmt ~file ({cmt_annots} : Cmt_format.cmt_infos) =
1017+
let extraForCmt ~iterator ({cmt_annots} : Cmt_format.cmt_infos) =
10241018
match cmt_annots with
10251019
| Implementation structure ->
1026-
extraForStructureItems ~file structure.str_items [||]
1020+
extraForStructureItems ~iterator structure.str_items [||]
10271021
| Partial_implementation parts ->
10281022
let items =
10291023
parts |> Array.to_list
@@ -1035,8 +1029,9 @@ let extraForCmt ~file ({cmt_annots} : Cmt_format.cmt_infos) =
10351029
| _ -> None)
10361030
|> List.concat
10371031
in
1038-
extraForStructureItems ~file items parts
1039-
| Interface signature -> extraForSignatureItems ~file signature.sig_items [||]
1032+
extraForStructureItems ~iterator items parts
1033+
| Interface signature ->
1034+
extraForSignatureItems ~iterator signature.sig_items [||]
10401035
| Partial_interface parts ->
10411036
let items =
10421037
parts |> Array.to_list
@@ -1047,15 +1042,17 @@ let extraForCmt ~file ({cmt_annots} : Cmt_format.cmt_infos) =
10471042
| _ -> None)
10481043
|> List.concat
10491044
in
1050-
extraForSignatureItems ~file items parts
1051-
| _ -> extraForStructureItems ~file [] [||]
1045+
extraForSignatureItems ~iterator items parts
1046+
| _ -> extraForStructureItems ~iterator [] [||]
10521047

10531048
let fullForCmt ~moduleName ~package ~uri cmt =
10541049
match Shared.tryReadCmt cmt with
10551050
| None -> None
10561051
| Some infos ->
10571052
let file = forCmt ~moduleName ~uri infos in
1058-
let extra = extraForCmt ~file infos in
1053+
let extra = extraForFile ~file in
1054+
let iterator = getIterator extra file in
1055+
extraForCmt ~iterator infos;
10591056
Some {file; extra; package}
10601057

10611058
open SharedTypes

0 commit comments

Comments
 (0)