Skip to main content

luaur_analysis/functions/
has_native_comment_directive.rs

1use luaur_ast::records::hot_comment::HotComment;
2
3pub fn has_native_comment_directive(hotcomments: &[HotComment]) -> bool {
4    for hc in hotcomments {
5        if hc.content.is_empty()
6            || hc.content.as_bytes().first() == Some(&b' ')
7            || hc.content.as_bytes().first() == Some(&b'\t')
8        {
9            continue;
10        }
11
12        if hc.header {
13            let bytes = hc.content.as_bytes();
14            let space_pos = bytes.iter().position(|&b| b == b' ' || b == b'\t');
15
16            let first = if let Some(pos) = space_pos {
17                &hc.content[..pos]
18            } else {
19                &hc.content[..]
20            };
21
22            if first == "native" {
23                return true;
24            }
25        }
26    }
27
28    false
29}