@@ -1073,7 +1073,8 @@ struct
1073
1073
| _ -> ()
1074
1074
end
1075
1075
1076
- let forStructureItems ~(file : File.t ) items parts =
1076
+ let forStructureItems ~(file : File.t ) (items : Typedtree.structure_item list )
1077
+ parts =
1077
1078
let extra = extraForFile ~file in
1078
1079
let extent = itemsExtent items in
1079
1080
let extent =
@@ -1109,8 +1110,46 @@ let forStructureItems ~(file : File.t) items parts =
1109
1110
| Partial_structure _ | Partial_structure_item _ -> () );
1110
1111
extra
1111
1112
1113
+ let forSignatureItems ~(file : File.t ) (items : Typedtree.signature_item list )
1114
+ parts =
1115
+ let extra = extraForFile ~file in
1116
+ let extent = sigItemsExtent items in
1117
+ let extent =
1118
+ {
1119
+ extent with
1120
+ loc_end =
1121
+ {
1122
+ extent.loc_end with
1123
+ pos_lnum = extent.loc_end.pos_lnum + 1000000 ;
1124
+ pos_cnum = extent.loc_end.pos_cnum + 100000000 ;
1125
+ };
1126
+ }
1127
+ in
1128
+ (* TODO look through parts and extend the extent *)
1129
+ let module Iter = TypedtreeIter. MakeIterator (F (struct
1130
+ let scopeExtent = ref [extent]
1131
+
1132
+ let extra = extra
1133
+
1134
+ let file = file
1135
+ end )) in
1136
+ List. iter Iter. iter_signature_item items;
1137
+ (* Log.log("Parts " ++ string_of_int(Array.length(parts))); *)
1138
+ parts
1139
+ |> Array. iter (fun part ->
1140
+ match part with
1141
+ | Cmt_format. Partial_signature str -> Iter. iter_signature str
1142
+ | Partial_signature_item str -> Iter. iter_signature_item str
1143
+ | Partial_expression expression -> Iter. iter_expression expression
1144
+ | Partial_pattern pattern -> Iter. iter_pattern pattern
1145
+ | Partial_class_expr class_expr -> Iter. iter_class_expr class_expr
1146
+ | Partial_module_type module_type -> Iter. iter_module_type module_type
1147
+ | Partial_structure _ | Partial_structure_item _ -> () );
1148
+ extra
1149
+
1112
1150
let extraForCmt ~file ({cmt_annots} : Cmt_format.cmt_infos ) =
1113
1151
match cmt_annots with
1152
+ | Implementation structure -> forStructureItems ~file structure.str_items [||]
1114
1153
| Partial_implementation parts ->
1115
1154
let items =
1116
1155
parts |> Array. to_list
@@ -1123,8 +1162,18 @@ let extraForCmt ~file ({cmt_annots} : Cmt_format.cmt_infos) =
1123
1162
|> List. concat
1124
1163
in
1125
1164
forStructureItems ~file items parts
1126
- | Implementation structure -> forStructureItems ~file structure.str_items [||]
1127
- | Partial_interface _ | Interface _ -> forStructureItems ~file [] [||]
1165
+ | Interface signature -> forSignatureItems ~file signature.sig_items [||]
1166
+ | Partial_interface parts ->
1167
+ let items =
1168
+ parts |> Array. to_list
1169
+ |> Utils. filterMap (fun (p : Cmt_format.binary_part ) ->
1170
+ match p with
1171
+ | Partial_signature s -> Some s.sig_items
1172
+ | Partial_signature_item str -> Some [str]
1173
+ | _ -> None )
1174
+ |> List. concat
1175
+ in
1176
+ forSignatureItems ~file items parts
1128
1177
| _ -> forStructureItems ~file [] [||]
1129
1178
1130
1179
let fullForCmt ~moduleName ~package ~uri cmt =
0 commit comments