Extracts the macro name from a macro invocation node (e.g. `assert!`). Looks for the first identifier child, stripping a trailing `!` if present.
(node: TsNode<'_>, source: &[u8])
| 238 | /// |
| 239 | /// Looks for the first identifier child, stripping a trailing `!` if present. |
| 240 | fn extract_macro_name(node: TsNode<'_>, source: &[u8]) -> Option<String> { |
| 241 | let mut cursor = node.walk(); |
| 242 | if cursor.goto_first_child() { |
| 243 | loop { |
| 244 | let child = cursor.node(); |
| 245 | let ck = child.kind(); |
| 246 | if ck == "identifier" || ck == "scoped_identifier" { |
| 247 | if let Ok(text) = child.utf8_text(source) { |
| 248 | return Some(text.trim_end_matches('!').to_string()); |
| 249 | } |
| 250 | } |
| 251 | if !cursor.goto_next_sibling() { |
| 252 | break; |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | None |
| 257 | } |
| 258 | |
| 259 | /// Returns the text of the rightmost identifier-like child of `node`. |
| 260 | fn rightmost_identifier(node: TsNode<'_>, source: &[u8]) -> String { |
no test coverage detected