Skip to content

Commit da0841c

Browse files
committed
prevent broken locs from being added to document symbols
1 parent d0de60b commit da0841c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

analysis/src/DocumentSymbol.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ let kindNumber = function
2727
let command ~path =
2828
let symbols = ref [] in
2929
let addSymbol name loc kind =
30-
let range = Utils.cmtLocToRange loc in
31-
let symbol : Protocol.documentSymbolItem =
32-
{name; range; kind = kindNumber kind; children = []}
33-
in
34-
symbols := symbol :: !symbols
30+
if
31+
(not loc.Location.loc_ghost)
32+
&& loc.loc_start.pos_cnum >= 0
33+
&& loc.loc_end.pos_cnum >= 0
34+
then
35+
let range = Utils.cmtLocToRange loc in
36+
let symbol : Protocol.documentSymbolItem =
37+
{name; range; kind = kindNumber kind; children = []}
38+
in
39+
symbols := symbol :: !symbols
3540
in
3641
let rec exprKind (exp : Parsetree.expression) =
3742
match exp.pexp_desc with

0 commit comments

Comments
 (0)