Skip to content

Commit 2ea454b

Browse files
committed
fix to shape lookup of missing items
1 parent a97ee80 commit 2ea454b

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/model/names.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ module Name : Name = struct
5656
type t = Internal of string * int | Std of string
5757

5858
let to_string = function
59-
| Std s -> s
59+
| Std s -> parenthesise s
6060
| Internal (s, i) -> Printf.sprintf "{%s}%d" s i
6161

6262
let to_string_unsafe = function Std s -> s | Internal (s, _i) -> s
6363

64-
let make_std s =
65-
let s = parenthesise s in
66-
Std s
64+
let make_std s = Std s
6765

6866
let of_ident id = make_std (Ident.name id)
6967

src/xref2/shape_tools.cppo.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ let rec shape_of_id env :
1818
| None -> None
1919
in
2020
fun id ->
21+
if Identifier.is_internal id then None else
2122
match id.iv with
2223
| `Root (_, name) -> begin
23-
match Env.lookup_unit (ModuleName.to_string name) env with
24+
match Env.lookup_unit (ModuleName.to_string_unsafe name) env with
2425
| Some (Env.Found unit) -> (
2526
match unit.shape_info with | Some (shape, _) -> Some shape | None -> None)
2627
| _ -> None
2728
end
2829
| `Module (parent, name) ->
29-
proj parent Kind.Module (ModuleName.to_string name)
30+
proj parent Kind.Module (ModuleName.to_string_unsafe name)
3031
| `Result parent ->
3132
(* Apply the functor to an empty signature. This doesn't seem to cause
3233
any problem, as the shape would stop resolve on an item inside the
@@ -35,18 +36,18 @@ let rec shape_of_id env :
3536
>>= fun parent ->
3637
Some (Shape.app parent ~arg:(Shape.str Shape.Item.Map.empty))
3738
| `ModuleType (parent, name) ->
38-
proj parent Kind.Module_type (ModuleTypeName.to_string name)
39-
| `Type (parent, name) -> proj parent Kind.Type (TypeName.to_string name)
40-
| `Value (parent, name) -> proj parent Kind.Value (ValueName.to_string name)
39+
proj parent Kind.Module_type (ModuleTypeName.to_string_unsafe name)
40+
| `Type (parent, name) -> proj parent Kind.Type (TypeName.to_string_unsafe name)
41+
| `Value (parent, name) -> proj parent Kind.Value (ValueName.to_string_unsafe name)
4142
| `Extension (parent, name) ->
4243
proj parent Kind.Extension_constructor (ExtensionName.to_string name)
4344
| `ExtensionDecl (parent, name, _) ->
4445
proj parent Kind.Extension_constructor (ExtensionName.to_string name)
4546
| `Exception (parent, name) ->
4647
proj parent Kind.Extension_constructor (ExceptionName.to_string name)
47-
| `Class (parent, name) -> proj parent Kind.Class (ClassName.to_string name)
48+
| `Class (parent, name) -> proj parent Kind.Class (ClassName.to_string_unsafe name)
4849
| `ClassType (parent, name) ->
49-
proj parent Kind.Class_type (ClassTypeName.to_string name)
50+
proj parent Kind.Class_type (ClassTypeName.to_string_unsafe name)
5051
| `Page _ | `LeafPage _ | `Label _ | `CoreType _ | `CoreException _
5152
| `Constructor _ | `Field _ | `Method _ | `InstanceVariable _ | `Parameter _
5253
->

test/sources/source.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Source links generated in the documentation:
229229
--
230230
<div class="spec value anchored" id="val-(*.+%)">
231231
<a href="#val-(*.+%)" class="anchor"></a>
232-
<a href="../root/source/a.ml.html" class="source_link">Source</a>
232+
<a href="../root/source/a.ml.html#val-(*.+%)" class="source_link">Source
233233
--
234234
<div class="spec value anchored" id="val-a">
235235
<a href="#val-a" class="anchor"></a>

0 commit comments

Comments
 (0)