Skip to content

prevent broken locs from being added to document symbols #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2023
Merged
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
15 changes: 10 additions & 5 deletions analysis/src/DocumentSymbol.ml
Original file line number Diff line number Diff line change
@@ -27,11 +27,16 @@ let kindNumber = function
let command ~path =
let symbols = ref [] in
let addSymbol name loc kind =
let range = Utils.cmtLocToRange loc in
let symbol : Protocol.documentSymbolItem =
{name; range; kind = kindNumber kind; children = []}
in
symbols := symbol :: !symbols
if
(not loc.Location.loc_ghost)
&& loc.loc_start.pos_cnum >= 0
&& loc.loc_end.pos_cnum >= 0
then
let range = Utils.cmtLocToRange loc in
let symbol : Protocol.documentSymbolItem =
{name; range; kind = kindNumber kind; children = []}
in
symbols := symbol :: !symbols
in
let rec exprKind (exp : Parsetree.expression) =
match exp.pexp_desc with