Skip to content

Commit 43e76d8

Browse files
committed
Support exception declarations.
1 parent 413672c commit 43e76d8

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

analysis/src/DocumentSymbol.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
type kind =
44
| Module
55
| Property
6+
| Constructor
67
| Function
78
| Variable
89
| Constant
@@ -14,6 +15,7 @@ type kind =
1415
let kindNumber = function
1516
| Module -> 2
1617
| Property -> 7
18+
| Constructor -> 9
1719
| Function -> 12
1820
| Variable -> 13
1921
| Constant -> 14
@@ -59,6 +61,9 @@ let command ~path =
5961
let processModuleDeclaration (md : Parsetree.module_declaration) =
6062
symbols := (md.pmd_name.txt, md.pmd_loc, Module) :: !symbols
6163
in
64+
let processExtensionConstructor (et : Parsetree.extension_constructor) =
65+
symbols := (et.pext_name.txt, et.pext_loc, Constructor) :: !symbols
66+
in
6267
let value_binding (iterator : Ast_iterator.iterator)
6368
(vb : Parsetree.value_binding) =
6469
(match vb.pvb_pat.ppat_desc with
@@ -73,6 +78,7 @@ let command ~path =
7378
symbols :=
7479
(txt, {e.pexp_loc with loc_end = modExpr.pmod_loc.loc_end}, Module)
7580
:: !symbols
81+
| Pexp_letexception (ec, _) -> processExtensionConstructor ec
7682
| _ -> ());
7783
Ast_iterator.default_iterator.expr iterator e
7884
in
@@ -84,6 +90,7 @@ let command ~path =
8490
| Pstr_type (_, typDecls) -> typDecls |> List.iter processTypeDeclaration
8591
| Pstr_module mb -> processModuleBinding mb
8692
| Pstr_recmodule mbs -> mbs |> List.iter processModuleBinding
93+
| Pstr_exception ec -> processExtensionConstructor ec
8794
| _ -> Ast_iterator.default_iterator.structure_item iterator item);
8895
Ast_iterator.default_iterator.structure_item iterator item
8996
in
@@ -94,6 +101,7 @@ let command ~path =
94101
| Psig_type (_, typDecls) -> typDecls |> List.iter processTypeDeclaration
95102
| Psig_module md -> processModuleDeclaration md
96103
| Psig_recmodule mds -> mds |> List.iter processModuleDeclaration
104+
| Psig_exception ec -> processExtensionConstructor ec
97105
| _ -> ());
98106
Ast_iterator.default_iterator.signature_item iterator item
99107
in

analysis/tests/src/Completion.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@ let foo = {
117117
type z = int
118118
let v = 44
119119
}
120+
exception MyException (int, string, float, array<Js.Json.t>)
121+
let _ = raise(MyException(2, "", 1.0, []))
120122
add((x: Inner.z), Inner.v + y)
121123
}
124+
125+
exception MyOtherException

analysis/tests/src/expected/Completion.res.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ DocumentSymbol tests/src/Completion.res
593593
{
594594
"name": "foo",
595595
"kind": 13,
596-
"location": {"uri": "Completion.res", "range": {"start": {"line": 103, "character": 0}, "end": {"line": 120, "character": 1}}}
596+
"location": {"uri": "Completion.res", "range": {"start": {"line": 103, "character": 0}, "end": {"line": 122, "character": 1}}}
597597
},
598598
{
599599
"name": "x",
@@ -629,6 +629,16 @@ DocumentSymbol tests/src/Completion.res
629629
"name": "v",
630630
"kind": 16,
631631
"location": {"uri": "Completion.res", "range": {"start": {"line": 117, "character": 4}, "end": {"line": 117, "character": 14}}}
632+
},
633+
{
634+
"name": "MyException",
635+
"kind": 9,
636+
"location": {"uri": "Completion.res", "range": {"start": {"line": 119, "character": 2}, "end": {"line": 119, "character": 62}}}
637+
},
638+
{
639+
"name": "MyOtherException",
640+
"kind": 9,
641+
"location": {"uri": "Completion.res", "range": {"start": {"line": 124, "character": 0}, "end": {"line": 124, "character": 26}}}
632642
}
633643
]
634644

0 commit comments

Comments
 (0)