Skip to content

Commit

Permalink
Add code to detect super method invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Sep 5, 2024
1 parent 6f72dda commit 214de5e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/metaslang/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,37 @@ impl<'a, KT: KindTypes + 'static> Reference<'a, KT> {
.all(|other| !other.shadows(&mut partials, reference_path))
{
results.push(reference_path.clone());

if path_pushes_super(reference_path, &mut partials, &self.owner.stack_graph) {
println!(
"Found push `super` in path ending at {}",
self.owner.to_definition(reference_path.end_node).unwrap()
);
}
}
}
results
}
}

fn path_pushes_super(
path: &PartialPath,
partials: &mut PartialPaths,
stack_graph: &StackGraph,
) -> bool {
for edge in path.edges.iter(partials) {
let source_node_handle = stack_graph.node_for_id(edge.source_node_id).unwrap();
let source_node = &stack_graph[source_node_handle];
if matches!(source_node, Node::PushScopedSymbol(_) | Node::PushSymbol(_)) {
let symbol = &stack_graph[source_node.symbol().unwrap()];
if "super" == symbol {
return true;
}
}
}
false
}

impl<KT: KindTypes + 'static> Display for Reference<'_, KT> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(cursor) = self.get_cursor() {
Expand Down

0 comments on commit 214de5e

Please sign in to comment.