@@ -32,7 +32,7 @@ let () =
3232 }
3333 });
3434
35- let enumerate_exports = stmts => {
35+ let enumerate_provides = program => {
3636 let id_tbl = ref (Ident . empty);
3737
3838 let rec pattern_ids = ({pat_desc, pat_loc}: Typedtree . pattern ) => {
@@ -48,7 +48,7 @@ let enumerate_exports = stmts => {
4848 };
4949 };
5050
51- module ExportIterator =
51+ module ProvideIterator =
5252 TypedtreeIter . MakeIterator ({
5353 include TypedtreeIter . DefaultIteratorArgument ;
5454
@@ -89,13 +89,14 @@ let enumerate_exports = stmts => {
8989 };
9090 });
9191
92- List . iter( ExportIterator . iter_toplevel_stmt , stmts );
92+ ProvideIterator . iter_typed_program(program );
9393
9494 id_tbl^;
9595};
9696
97- let location_for_ident = (~exports, ident) => {
98- snd(Ident . find_name(Ident . name(ident), exports));
97+ let location_for_ident =
98+ (~provides: Ident . tbl (Grain_parsing . Location . t ), ident) => {
99+ snd(Ident . find_name(Ident . name(ident), provides));
99100};
100101
101102let title_for_api = (~module_name, ident: Ident . t ) => {
@@ -145,11 +146,12 @@ let lookup_type_expr = (~idx, type_exprs) => {
145146let for_value_description =
146147 (
147148 ~comments,
148- ~loc : Grain_parsing . Location . t ,
149+ ~provides ,
149150 ~module_name,
150151 ~ident: Ident . t ,
151152 vd: Types . value_description ,
152153 ) => {
154+ let loc = location_for_ident(~provides, ident);
153155 let name = title_for_api(~module_name, ident);
154156 let type_sig = Printtyp . string_of_value_description(~ident, vd);
155157 let comment =
@@ -185,11 +187,12 @@ let for_value_description =
185187let for_type_declaration =
186188 (
187189 ~comments,
188- ~loc : Grain_parsing . Location . t ,
190+ ~provides ,
189191 ~module_name,
190192 ~ident: Ident . t ,
191193 td: Types . type_declaration ,
192194 ) => {
195+ let loc = location_for_ident(~provides, ident);
193196 let name = title_for_api(~module_name, ident);
194197 let type_sig = Printtyp . string_of_type_declaration(~ident, td);
195198 let comment =
@@ -204,45 +207,6 @@ let for_type_declaration =
204207 {module_name, name, type_sig, description, attributes};
205208};
206209
207- let for_signature_item =
208- (
209- ~comments,
210- ~exports: Ident . tbl (Grain_parsing . Location . t ),
211- ~module_name,
212- sig_item: Types . signature_item ,
213- ) => {
214- switch (sig_item) {
215- | TSigValue (ident , vd ) =>
216- let loc = location_for_ident(~exports, ident);
217- let docblock =
218- for_value_description(~comments, ~module_name, ~ident, ~loc, vd);
219- Some (docblock);
220- | TSigType (ident , td , _rec ) =>
221- let loc = location_for_ident(~exports, ident);
222- let docblock =
223- for_type_declaration(~comments, ~module_name, ~ident, ~loc, td);
224- Some (docblock);
225- | _ => None
226- };
227- };
228-
229- let signature_item_in_range =
230- (
231- ~exports: Ident . tbl (Grain_parsing . Location . t ),
232- sig_item: Types . signature_item ,
233- range: Grain_utils . Range . t ,
234- ) => {
235- switch (sig_item) {
236- | TSigValue (ident , vd ) =>
237- let loc = location_for_ident(~exports, ident);
238- Grain_utils . Range . inRange(loc. loc_start. pos_lnum, range);
239- | TSigType (ident , td , _rec ) =>
240- let loc = location_for_ident(~exports, ident);
241- Grain_utils . Range . inRange(loc. loc_start. pos_lnum, range);
242- | _ => false
243- };
244- };
245-
246210// Used for joining multiple `@throws` annotations with the exact same type
247211module StringMap = Map . Make (String );
248212
0 commit comments