feat(lsp): hover support for the optional multi validator fn

This commit is contained in:
rvcas 2023-11-28 19:18:29 -05:00
parent 2159053cb5
commit 7015a9badc
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
1 changed files with 24 additions and 9 deletions

View File

@ -426,18 +426,33 @@ impl TypedDefinition {
pub fn find_node(&self, byte_index: usize) -> Option<Located<'_>> {
// Note that the fn span covers the function head, not
// the entire statement.
if let Definition::Fn(Function { body, .. })
| Definition::Validator(Validator {
fun: Function { body, .. },
..
})
| Definition::Test(Function { body, .. }) = self
{
match self {
Definition::Fn(Function { body, .. }) | Definition::Test(Function { body, .. }) => {
if let Some(located) = body.find_node(byte_index) {
return Some(located);
}
}
Definition::Validator(Validator {
fun: Function { body, .. },
other_fun:
Some(Function {
body: other_body, ..
}),
..
}) => {
if let Some(located) = body.find_node(byte_index) {
return Some(located);
}
if let Some(located) = other_body.find_node(byte_index) {
return Some(located);
}
}
_ => (),
}
if self.location().contains(byte_index) {
Some(Located::Definition(self))
} else {