From 0c80bf126d0f37869a35f44a543feda18dd7b41a Mon Sep 17 00:00:00 2001 From: Liam Stevenson Date: Tue, 18 Nov 2025 17:27:55 -0500 Subject: [PATCH 1/2] Add test for outline with include statements --- tests/test-dirs/outline.t/foo.ml | 20 ++++++++++++++++++++ tests/test-dirs/outline.t/run.t | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) 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..758c18081 100644 --- a/tests/test-dirs/outline.t/run.t +++ b/tests/test-dirs/outline.t/run.t @@ -3,6 +3,21 @@ { "class": "return", "value": [ + { + "start": { + "line": 39, + "col": 0 + }, + "end": { + "line": 48, + "col": 3 + }, + "name": "S", + "kind": "Signature", + "type": null, + "children": [], + "deprecated": false + }, { "start": { "line": 24, @@ -261,3 +276,4 @@ Check that when we pass "-include-types false", every "type" is null. null null null + null From 8705ba61a32daa85a4c8b6869701c46775018c3c Mon Sep 17 00:00:00 2001 From: Liam Stevenson Date: Tue, 18 Nov 2025 17:28:14 -0500 Subject: [PATCH 2/2] Fix bug --- src/analysis/outline.ml | 16 ++-- tests/test-dirs/outline.t/run.t | 129 ++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 9 deletions(-) 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/run.t b/tests/test-dirs/outline.t/run.t index 758c18081..10e44e8a2 100644 --- a/tests/test-dirs/outline.t/run.t +++ b/tests/test-dirs/outline.t/run.t @@ -15,6 +15,127 @@ "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 }, @@ -277,3 +398,11 @@ Check that when we pass "-include-types false", every "type" is null. null null null + null + null + null + null + null + null + null + null