diff --git a/src/analysis/outline.ml b/src/analysis/outline.ml index 8f8566f56..ec44f989a 100644 --- a/src/analysis/outline.ml +++ b/src/analysis/outline.ml @@ -179,20 +179,18 @@ and get_mod_children ~include_types node = and remove_mod_indir ~include_types node = match node.t_node with - | Module_expr _ | Module_type _ -> - List.concat_map - (Lazy.force node.t_children) - ~f:(remove_mod_indir ~include_types) + | Module_expr _ | Module_type _ -> get_mod_children ~include_types node | _ -> remove_top_indir ~include_types node and remove_top_indir ~include_types t = match t.t_node with - | Structure _ | Signature _ -> - List.concat_map - ~f:(remove_top_indir ~include_types) - (Lazy.force t.t_children) + | Structure _ | Signature _ -> get_mod_children ~include_types t | Signature_item _ | Structure_item _ -> - List.filter_map (Lazy.force t.t_children) ~f:(summarize ~include_types) + List.concat_map (Lazy.force t.t_children) ~f:(fun child -> + match child.t_node with + | Include_declaration _ | Include_description _ -> + get_mod_children ~include_types child + | _ -> summarize ~include_types child |> Option.to_list) | _ -> [] let get ~include_types browses = diff --git a/tests/test-dirs/outline.t/foo.ml b/tests/test-dirs/outline.t/foo.ml index cd2624174..dbf70103b 100644 --- a/tests/test-dirs/outline.t/foo.ml +++ b/tests/test-dirs/outline.t/foo.ml @@ -26,3 +26,23 @@ type 'a point = ; y : 'a ; z : 'a } + +include struct + type t + let x = 1 + include struct + type u + let y = "y" + end +end + +module type S = sig + include sig + type t + val x : int + include sig + type u + val y : string + end + end +end diff --git a/tests/test-dirs/outline.t/run.t b/tests/test-dirs/outline.t/run.t index d46613e7b..10e44e8a2 100644 --- a/tests/test-dirs/outline.t/run.t +++ b/tests/test-dirs/outline.t/run.t @@ -3,6 +3,142 @@ { "class": "return", "value": [ + { + "start": { + "line": 39, + "col": 0 + }, + "end": { + "line": 48, + "col": 3 + }, + "name": "S", + "kind": "Signature", + "type": null, + "children": [ + { + "start": { + "line": 45, + "col": 6 + }, + "end": { + "line": 45, + "col": 20 + }, + "name": "y", + "kind": "Value", + "type": "string", + "children": [], + "deprecated": false + }, + { + "start": { + "line": 44, + "col": 6 + }, + "end": { + "line": 44, + "col": 12 + }, + "name": "u", + "kind": "Type", + "type": null, + "children": [], + "deprecated": false + }, + { + "start": { + "line": 42, + "col": 4 + }, + "end": { + "line": 42, + "col": 15 + }, + "name": "x", + "kind": "Value", + "type": "int", + "children": [], + "deprecated": false + }, + { + "start": { + "line": 41, + "col": 4 + }, + "end": { + "line": 41, + "col": 10 + }, + "name": "t", + "kind": "Type", + "type": null, + "children": [], + "deprecated": false + } + ], + "deprecated": false + }, + { + "start": { + "line": 35, + "col": 4 + }, + "end": { + "line": 35, + "col": 15 + }, + "name": "y", + "kind": "Value", + "type": "string", + "children": [], + "deprecated": false + }, + { + "start": { + "line": 34, + "col": 4 + }, + "end": { + "line": 34, + "col": 10 + }, + "name": "u", + "kind": "Type", + "type": null, + "children": [], + "deprecated": false + }, + { + "start": { + "line": 32, + "col": 2 + }, + "end": { + "line": 32, + "col": 11 + }, + "name": "x", + "kind": "Value", + "type": "int", + "children": [], + "deprecated": false + }, + { + "start": { + "line": 31, + "col": 2 + }, + "end": { + "line": 31, + "col": 8 + }, + "name": "t", + "kind": "Type", + "type": null, + "children": [], + "deprecated": false + }, { "start": { "line": 24, @@ -261,3 +397,12 @@ Check that when we pass "-include-types false", every "type" is null. null null null + null + null + null + null + null + null + null + null + null