1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::ns;
use crate::Options;
use lib_ruby_parser_nodes::Message;

/// Returns name of the is-a-variant function for the given `message`
pub fn name(message: &Message) -> String {
    format!(
        "{ns}__is_{variant}",
        ns = ns(),
        variant = message.lower_name()
    )
}

/// Returns name of the is-a-variant function for the given `message`
pub fn sig(message: &Message, options: &Options) -> String {
    format!(
        "bool {fn_attributes} {variant_predicate_name}(const {diagnostic_message_blob} *self_blob)",
        fn_attributes = options.fn_attributes,
        variant_predicate_name = name(message),
        diagnostic_message_blob = options.diagnostic_message_blob_name
    )
}