@@ -19,6 +19,15 @@ module Ocaml_env = Env
19
19
20
20
open Names
21
21
22
+ let contains_double_underscore s =
23
+ let len = String. length s in
24
+ let rec aux i =
25
+ if i > len - 2 then false
26
+ else if s.[i] = '_' && s.[i + 1 ] = '_' then true
27
+ else aux (i + 1 )
28
+ in
29
+ aux 0
30
+
22
31
module Identifier = struct
23
32
type 'a id = 'a Paths_types .id = { iv : 'a ; ihash : int ; ikey : string }
24
33
@@ -66,7 +75,9 @@ module Identifier = struct
66
75
let rec is_internal : t -> bool =
67
76
fun x ->
68
77
match x.iv with
69
- | `Root (_ , name ) -> ModuleName. is_internal name
78
+ | `Root (_ , name ) ->
79
+ ModuleName. is_internal name
80
+ || contains_double_underscore (ModuleName. to_string name)
70
81
| `Page (_ , _ ) -> false
71
82
| `LeafPage (_ , _ ) -> false
72
83
| `Module (_ , name ) -> ModuleName. is_internal name
@@ -91,6 +102,36 @@ module Identifier = struct
91
102
| `SourceLocationInternal _ | `AssetFile _ ->
92
103
false
93
104
105
+ let rec is_internal_rec : t -> bool =
106
+ fun x ->
107
+ is_internal x
108
+ ||
109
+ match x.iv with
110
+ | `Root (_ , name ) -> ModuleName. is_internal name
111
+ | `Page (_ , _ ) -> false
112
+ | `LeafPage (_ , _ ) -> false
113
+ | `Module (parent , _ ) -> is_internal_rec (parent :> t )
114
+ | `Parameter (parent , _ ) -> is_internal_rec (parent :> t )
115
+ | `Result x -> is_internal_rec (x :> t )
116
+ | `ModuleType (parent , _ ) -> is_internal_rec (parent :> t )
117
+ | `Type (parent , _ ) -> is_internal_rec (parent :> t )
118
+ | `CoreType name -> TypeName. is_internal name
119
+ | `Constructor (parent , _ ) -> is_internal (parent :> t )
120
+ | `Field (parent , _ ) -> is_internal (parent :> t )
121
+ | `Extension (parent , _ ) -> is_internal (parent :> t )
122
+ | `ExtensionDecl (parent , _ , _ ) -> is_internal (parent :> t )
123
+ | `Exception (parent , _ ) -> is_internal (parent :> t )
124
+ | `CoreException _ -> false
125
+ | `Value (parent , _ ) -> is_internal_rec (parent :> t )
126
+ | `Class (parent , _ ) -> is_internal_rec (parent :> t )
127
+ | `ClassType (parent , _ ) -> is_internal_rec (parent :> t )
128
+ | `Method (parent , _ ) -> is_internal (parent :> t )
129
+ | `InstanceVariable (parent , _ ) -> is_internal (parent :> t )
130
+ | `Label (parent , _ ) -> is_internal (parent :> t )
131
+ | `SourceDir _ | `SourceLocationMod _ | `SourceLocation _ | `SourcePage _
132
+ | `SourceLocationInternal _ | `AssetFile _ ->
133
+ false
134
+
94
135
let name : [< t_pv ] id -> string = fun n -> name_aux (n :> t )
95
136
96
137
let rec full_name_aux : t -> string list =
@@ -671,7 +712,7 @@ module Path = struct
671
712
| `Identifier { iv = `Module (_, m); _ }
672
713
when Names.ModuleName. is_internal m ->
673
714
true
674
- | `Identifier _ -> false
715
+ | `Identifier i -> Identifier. is_internal_rec i
675
716
| `Canonical (_ , `Resolved _ ) -> false
676
717
| `Canonical (x , _ ) ->
677
718
(not weak_canonical_test) && inner (x : module_ :> any )
@@ -708,15 +749,6 @@ module Path = struct
708
749
in
709
750
inner x
710
751
711
- and contains_double_underscore s =
712
- let len = String. length s in
713
- let rec aux i =
714
- if i > len - 2 then false
715
- else if s.[i] = '_' && s.[i + 1 ] = '_' then true
716
- else aux (i + 1 )
717
- in
718
- aux 0
719
-
720
752
and is_path_hidden : Paths_types.Path.any -> bool =
721
753
let open Paths_types.Path in
722
754
function
0 commit comments