oak_fsharp/language/
mod.rs1use oak_core::{Language, LanguageCategory};
2
3#[derive(Debug, Clone)]
5pub struct FSharpLanguage {
6 pub fsharp_4_0: bool,
8 pub fsharp_4_1: bool,
10 pub fsharp_4_5: bool,
12 pub fsharp_5_0: bool,
14 pub fsharp_6_0: bool,
16 pub fsharp_7_0: bool,
18 pub computation_expressions: bool,
20 pub type_providers: bool,
22 pub async_workflows: bool,
24 pub query_expressions: bool,
26}
27
28impl Default for FSharpLanguage {
29 fn default() -> Self {
30 Self { fsharp_4_0: true, fsharp_4_1: true, fsharp_4_5: true, fsharp_5_0: true, fsharp_6_0: true, fsharp_7_0: true, computation_expressions: true, type_providers: true, async_workflows: true, query_expressions: true }
31 }
32}
33
34impl FSharpLanguage {
35 pub fn new() -> Self {
37 Self::default()
38 }
39
40 pub fn with_all_features(mut self) -> Self {
42 self.fsharp_4_0 = true;
43 self.fsharp_4_1 = true;
44 self.fsharp_4_5 = true;
45 self.fsharp_5_0 = true;
46 self.fsharp_6_0 = true;
47 self.fsharp_7_0 = true;
48 self.computation_expressions = true;
49 self.type_providers = true;
50 self.async_workflows = true;
51 self.query_expressions = true;
52 self
53 }
54
55 pub fn with_version(mut self, major: u8, minor: u8) -> Self {
57 match (major, minor) {
58 (4, 0) => {
59 self.fsharp_4_0 = true;
60 }
61 (4, 1) => {
62 self.fsharp_4_0 = true;
63 self.fsharp_4_1 = true;
64 }
65 (4, 5) => {
66 self.fsharp_4_0 = true;
67 self.fsharp_4_1 = true;
68 self.fsharp_4_5 = true;
69 }
70 (5, 0) => {
71 self.fsharp_4_0 = true;
72 self.fsharp_4_1 = true;
73 self.fsharp_4_5 = true;
74 self.fsharp_5_0 = true;
75 }
76 (6, 0) => {
77 self.fsharp_4_0 = true;
78 self.fsharp_4_1 = true;
79 self.fsharp_4_5 = true;
80 self.fsharp_5_0 = true;
81 self.fsharp_6_0 = true;
82 }
83 (7, 0) => {
84 self.fsharp_4_0 = true;
85 self.fsharp_4_1 = true;
86 self.fsharp_4_5 = true;
87 self.fsharp_5_0 = true;
88 self.fsharp_6_0 = true;
89 self.fsharp_7_0 = true;
90 }
91 _ => {}
92 }
93 self
94 }
95
96 pub fn with_computation_expressions(mut self, enabled: bool) -> Self {
98 self.computation_expressions = enabled;
99 self
100 }
101
102 pub fn with_type_providers(mut self, enabled: bool) -> Self {
104 self.type_providers = enabled;
105 self
106 }
107
108 pub fn with_async_workflows(mut self, enabled: bool) -> Self {
110 self.async_workflows = enabled;
111 self
112 }
113
114 pub fn with_query_expressions(mut self, enabled: bool) -> Self {
116 self.query_expressions = enabled;
117 self
118 }
119}
120
121pub struct FSharpRoot;
122
123impl Language for FSharpLanguage {
124 const NAME: &'static str = "fsharp";
125 const CATEGORY: LanguageCategory = LanguageCategory::Programming;
126
127 type TokenType = crate::kind::FSharpSyntaxKind;
128 type ElementType = crate::kind::FSharpSyntaxKind;
129 type TypedRoot = FSharpRoot;
130}