Skip to main content

elixir_call_keyword

Function elixir_call_keyword 

Source
pub fn elixir_call_keyword<'a>(
    node: &'a Node<'a>,
    code: &'a [u8],
) -> Option<&'a str>
Expand description

Reads the text of the target field of an Elixir Call node.

Most of Elixir’s control-flow constructs (if, unless, for, while, case, cond, with, try) and method-defining macros (def, defp, defmacro, …) parse as Call nodes whose target is an Identifier whose source text spells the keyword. The Cyclomatic and Exit impls already follow this pattern; this helper centralises the byte-text lookup so Cognitive and Abc can share it.

Returns None for Calls whose target is not a simple identifier (e.g. Module.func(…) parses as RemoteCallWithParentheses with the dotted name as target) or when the bytes are not valid UTF-8.