From 86549ed970f8ec4e258fa3525fd5988343ec3873 Mon Sep 17 00:00:00 2001 From: 0xSwapFeeder Date: Tue, 16 Apr 2024 17:17:59 -0400 Subject: [PATCH] fix(libs/references): try fix function params getter from spi --- libs/references/src/scope_finder.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/references/src/scope_finder.rs b/libs/references/src/scope_finder.rs index 3625a9f..0f92c34 100644 --- a/libs/references/src/scope_finder.rs +++ b/libs/references/src/scope_finder.rs @@ -3,6 +3,7 @@ use std::vec; use crate::types::InteractableNode; use crate::utils::is_node_in_range; use crate::Position; +use osmium_libs_solidity_ast_extractor::kw::is; use solc_ast_rs_types::types::*; use solc_ast_rs_types::visit; use solc_ast_rs_types::visit::*; @@ -65,6 +66,17 @@ impl<'ast> Visit<'ast> for ScopeFinder { } } + fn visit_function_definition(&mut self, function: &'ast FunctionDefinition) { + if is_node_in_range(&function.src, &self.position, &self.source) { + self.spi.push(InteractableNode::FunctionDefinition(function.clone())); + } + else if let Some(body) = &function.body { + if is_node_in_range(&body.src, &self.position, &self.source) { + self.spi.push(InteractableNode::Block(body.clone())); + } + } + } + fn visit_try(&mut self, r#try: &'ast TryStatement) { if is_node_in_range(&r#try.src, &self.position, &self.source) { self.spi.push(InteractableNode::TryStatement(r#try.clone()));