oak_dockerfile/kind/
mod.rs1pub type DockerfileToken = Token<DockerfileSyntaxKind>;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize)]
5pub enum DockerfileSyntaxKind {
6 Identifier,
8 String,
9 Number,
10 Whitespace,
11 Newline,
12
13 From,
15 Run,
16 Cmd,
17 Label,
18 Maintainer,
19 Expose,
20 Env,
21 Add,
22 Copy,
23 Entrypoint,
24 Volume,
25 User,
26 Workdir,
27 Arg,
28 Onbuild,
29 Stopsignal,
30 Healthcheck,
31 Shell,
32
33 As,
35 None,
36 Interval,
37 Timeout,
38 StartPeriod,
39 Retries,
40
41 Equal, Equals, Colon, Comma, Semicolon, Dollar, LeftBracket, RightBracket, LeftBrace, RightBrace, LeftParen, RightParen, Comment,
57
58 Path,
60
61 Error,
63 Eof,
64}
65
66impl DockerfileSyntaxKind {
67 pub fn is_instruction(&self) -> bool {
68 matches!(
69 self,
70 Self::From
71 | Self::Run
72 | Self::Cmd
73 | Self::Label
74 | Self::Maintainer
75 | Self::Expose
76 | Self::Env
77 | Self::Add
78 | Self::Copy
79 | Self::Entrypoint
80 | Self::Volume
81 | Self::User
82 | Self::Workdir
83 | Self::Arg
84 | Self::Onbuild
85 | Self::Stopsignal
86 | Self::Healthcheck
87 | Self::Shell
88 )
89 }
90
91 pub fn is_trivia(&self) -> bool {
92 matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
93 }
94}
95
96use oak_core::{SyntaxKind, Token};
97
98impl SyntaxKind for DockerfileSyntaxKind {
99 fn is_trivia(&self) -> bool {
100 matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
101 }
102
103 fn is_comment(&self) -> bool {
104 matches!(self, Self::Comment)
105 }
106
107 fn is_whitespace(&self) -> bool {
108 matches!(self, Self::Whitespace | Self::Newline)
109 }
110
111 fn is_token_type(&self) -> bool {
112 !matches!(self, Self::Error | Self::Eof)
113 }
114
115 fn is_element_type(&self) -> bool {
116 matches!(self, Self::Error | Self::Eof)
117 }
118}