Skip to content

Commit

Permalink
[metrics] Fix name of impl node
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Jun 23, 2020
1 parent 0875e97 commit 4c81990
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ impl Getter for TsxCode {
}

impl Getter for RustCode {
fn get_func_space_name<'a>(node: &Node, code: &'a [u8]) -> Option<&'a str> {
// we're in a function or in a class or an impl
// for an impl: we've 'impl ... type {...'
if let Some(name) = node
.child_by_field_name("name")
.or(node.child_by_field_name("type"))
{
let code = &code[name.start_byte()..name.end_byte()];
std::str::from_utf8(code).ok()
} else {
Some("<anonymous>")
}
}

fn get_space_kind(node: &Node) -> SpaceKind {
use Rust::*;

Expand Down

0 comments on commit 4c81990

Please sign in to comment.