kimun 0.32.0

Code metrics tool — health score, complexity, duplication, hotspots, ownership
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! What Phoenix relates by name alone, where no code says so.

use super::elixir::Reference;

/// The views Phoenix renders a controller with. It finds them by name, so
/// the controller never mentions them: `PageController` goes with
/// `PageHTML` and `PageJSON`, or `PageView`.
pub(super) fn views_of(defines: &[String]) -> impl Iterator<Item = Reference> + '_ {
    defines
        .iter()
        .filter_map(|module| module.strip_suffix("Controller"))
        .filter(|base| !base.is_empty() && !base.ends_with('.'))
        .flat_map(|base| ["HTML", "JSON", "View"].map(|view| format!("{base}{view}")))
        .map(|module| Reference {
            module,
            function: None,
        })
}