From 55489f0ae6b159e0f033864789c1cf89102f4cda Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Thu, 20 Jul 2023 16:29:08 -0400 Subject: [PATCH 1/4] feat(lsp): Support goto definition on exceptions --- compiler/src/language_server/sourcetree.re | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/compiler/src/language_server/sourcetree.re b/compiler/src/language_server/sourcetree.re index 5c662ed28c..7f83962c0f 100644 --- a/compiler/src/language_server/sourcetree.re +++ b/compiler/src/language_server/sourcetree.re @@ -394,6 +394,20 @@ module Sourcetree: Sourcetree = { }, ] @ segments^; + | TExpConstruct(_, desc, _) => + segments := + [ + ( + loc_to_interval(exp.exp_loc), + Value({ + env: exp.exp_env, + value_type: desc.cstr_res, + loc: exp.exp_loc, + definition: Some(desc.cstr_loc), + }), + ), + ...segments^, + ] | _ => segments := [ @@ -428,7 +442,10 @@ module Sourcetree: Sourcetree = { | Some(path) => let decl = Env.find_type(path, pat.pat_env); if (decl.type_loc == Location.dummy_loc) { - None; + switch (pat.pat_desc) { + | TPatConstruct(_, desc, _) => Some(desc.cstr_loc) + | _ => None + }; } else { Some(decl.type_loc); }; From 7ce2fc9e475694f2be514f0618c2a3f49eebb1b7 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Tue, 29 Aug 2023 22:44:02 -0400 Subject: [PATCH 2/4] chore: Remove unneccessairy code --- compiler/src/language_server/sourcetree.re | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/compiler/src/language_server/sourcetree.re b/compiler/src/language_server/sourcetree.re index 7f83962c0f..f79dd8a280 100644 --- a/compiler/src/language_server/sourcetree.re +++ b/compiler/src/language_server/sourcetree.re @@ -441,14 +441,7 @@ module Sourcetree: Sourcetree = { switch (get_type_path(pat.pat_type)) { | Some(path) => let decl = Env.find_type(path, pat.pat_env); - if (decl.type_loc == Location.dummy_loc) { - switch (pat.pat_desc) { - | TPatConstruct(_, desc, _) => Some(desc.cstr_loc) - | _ => None - }; - } else { - Some(decl.type_loc); - }; + Some(decl.type_loc); | _ => None }; segments := From 9a6d3128afd706367d32175ead8a1f7b7db66e7f Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Tue, 29 Aug 2023 22:44:02 -0400 Subject: [PATCH 3/4] Revert "chore: Remove unneccessairy code" This reverts commit 7ce2fc9e475694f2be514f0618c2a3f49eebb1b7. --- compiler/src/language_server/sourcetree.re | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/src/language_server/sourcetree.re b/compiler/src/language_server/sourcetree.re index f79dd8a280..7f83962c0f 100644 --- a/compiler/src/language_server/sourcetree.re +++ b/compiler/src/language_server/sourcetree.re @@ -441,7 +441,14 @@ module Sourcetree: Sourcetree = { switch (get_type_path(pat.pat_type)) { | Some(path) => let decl = Env.find_type(path, pat.pat_env); - Some(decl.type_loc); + if (decl.type_loc == Location.dummy_loc) { + switch (pat.pat_desc) { + | TPatConstruct(_, desc, _) => Some(desc.cstr_loc) + | _ => None + }; + } else { + Some(decl.type_loc); + }; | _ => None }; segments := From 75702287dfef0a1b3c96f07d12c08f6eafcdcecf Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 11 Sep 2023 22:07:44 -0700 Subject: [PATCH 4/4] Update compiler/src/language_server/sourcetree.re --- compiler/src/language_server/sourcetree.re | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/src/language_server/sourcetree.re b/compiler/src/language_server/sourcetree.re index 7f83962c0f..df8382a28e 100644 --- a/compiler/src/language_server/sourcetree.re +++ b/compiler/src/language_server/sourcetree.re @@ -442,10 +442,7 @@ module Sourcetree: Sourcetree = { | Some(path) => let decl = Env.find_type(path, pat.pat_env); if (decl.type_loc == Location.dummy_loc) { - switch (pat.pat_desc) { - | TPatConstruct(_, desc, _) => Some(desc.cstr_loc) - | _ => None - }; + None; } else { Some(decl.type_loc); };