Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/analysis/outline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
20 changes: 20 additions & 0 deletions tests/test-dirs/outline.t/foo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
145 changes: 145 additions & 0 deletions tests/test-dirs/outline.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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