Skip to content

Commit

Permalink
feat(lsp): hover support for the optional multi validator fn
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Nov 29, 2023
1 parent 2159053 commit 7015a9b
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions crates/aiken-lang/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,31 @@ 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
{
if let Some(located) = body.find_node(byte_index) {
return Some(located);
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) {
Expand Down

0 comments on commit 7015a9b

Please sign in to comment.