Skip to main content

just_lsp/
attribute_target.rs

1use super::*;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum AttributeTarget {
5  Alias,
6  Assignment,
7  Module,
8  Recipe,
9}
10
11impl Display for AttributeTarget {
12  fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
13    write!(
14      f,
15      "{}",
16      match self {
17        AttributeTarget::Alias => "alias",
18        AttributeTarget::Assignment => "assignment",
19        AttributeTarget::Module => "module",
20        AttributeTarget::Recipe => "recipe",
21      }
22    )
23  }
24}
25
26impl AttributeTarget {
27  #[must_use]
28  pub fn try_from_kind(kind: &str) -> Option<Self> {
29    match kind {
30      "alias" => Some(Self::Alias),
31      "assignment" | "export" => Some(Self::Assignment),
32      "module" => Some(Self::Module),
33      "recipe" => Some(Self::Recipe),
34      _ => None,
35    }
36  }
37}