oak_javascript/language/
mod.rs1use oak_core::language::Language;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub struct JavaScriptLanguage {
6    pub jsx: bool,
8    pub typescript: bool,
10    pub experimental: bool,
12    pub strict_mode: bool,
14    pub ecma_version: EcmaVersion,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum EcmaVersion {
21    ES3,
22    ES5,
23    ES2015,
24    ES2016,
25    ES2017,
26    ES2018,
27    ES2019,
28    ES2020,
29    ES2021,
30    ES2022,
31    ES2023,
32    Latest,
33}
34
35impl JavaScriptLanguage {
36    pub fn standard() -> Self {
38        Self::default()
39    }
40
41    pub fn modern() -> Self {
43        Self { jsx: false, typescript: false, experimental: false, strict_mode: true, ecma_version: EcmaVersion::Latest }
44    }
45
46    pub fn jsx() -> Self {
48        Self { jsx: true, typescript: false, experimental: false, strict_mode: true, ecma_version: EcmaVersion::Latest }
49    }
50
51    pub fn typescript() -> Self {
53        Self { jsx: false, typescript: true, experimental: false, strict_mode: true, ecma_version: EcmaVersion::Latest }
54    }
55}
56
57impl Default for JavaScriptLanguage {
58    fn default() -> Self {
59        Self { jsx: false, typescript: false, experimental: false, strict_mode: false, ecma_version: EcmaVersion::ES2015 }
60    }
61}
62
63impl Language for JavaScriptLanguage {
64    type SyntaxKind = crate::kind::JavaScriptSyntaxKind;
65    type TypedRoot = ();
66}