Skip to main content

literals_naming

Function literals_naming 

Source
pub fn literals_naming(text: &str, names: &[String]) -> Vec<String>
Expand description

String literals of a source naming any of names: "name" or 'name', exactly.

A name inside prose, a path or a longer literal is not a hit: only a literal that is the name and nothing else couples code to an advisor. Each name is reported once, in the order of names.

use majordomus_cli::reasoning::check::literals_naming;

let names = vec!["alpha".to_string(), "beta".to_string()];
let source = "let a = \"alpha\"; let b = 'alpha'; // the beta advisor\nimport('./beta.mjs')";
assert_eq!(literals_naming(source, &names), ["alpha"]);