From a46a7e82b723cbf6c2995b93d857efbd2ede3aec Mon Sep 17 00:00:00 2001 From: rvcas Date: Tue, 28 Nov 2023 16:13:08 -0500 Subject: [PATCH] feat: implement hover on when clause patterns --- crates/aiken-lang/src/ast.rs | 6 ++++-- crates/aiken-lang/src/expr.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 0940857c..60732b8b 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -1169,8 +1169,10 @@ impl TypedClause { } } - pub fn find_node(&self, byte_index: usize) -> Option> { - self.then.find_node(byte_index) + pub fn find_node(&self, byte_index: usize, subject_type: &Rc) -> Option> { + self.pattern + .find_node(byte_index, subject_type) + .or_else(|| self.then.find_node(byte_index)) } } diff --git a/crates/aiken-lang/src/expr.rs b/crates/aiken-lang/src/expr.rs index dce523c5..65f7480c 100644 --- a/crates/aiken-lang/src/expr.rs +++ b/crates/aiken-lang/src/expr.rs @@ -378,7 +378,7 @@ impl TypedExpr { .or_else(|| { clauses .iter() - .find_map(|clause| clause.find_node(byte_index)) + .find_map(|clause| clause.find_node(byte_index, &subject.tipo())) }) .or(Some(Located::Expression(self))),