oak_fsharp/language/
mod.rs1use oak_core::{Language, LanguageCategory};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub struct FSharpLanguage {
7 pub fsharp_4_0: bool,
9 pub fsharp_4_1: bool,
11 pub fsharp_4_5: bool,
13 pub fsharp_5_0: bool,
15 pub fsharp_6_0: bool,
17 pub fsharp_7_0: bool,
19 pub computation_expressions: bool,
21 pub type_providers: bool,
23 pub async_workflows: bool,
25 pub query_expressions: bool,
27}
28
29impl Default for FSharpLanguage {
30 fn default() -> Self {
31 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 }
32 }
33}
34
35impl FSharpLanguage {
36 pub fn new() -> Self {
38 Self::default()
39 }
40
41 pub fn with_all_features(mut self) -> Self {
43 self.fsharp_4_0 = true;
44 self.fsharp_4_1 = true;
45 self.fsharp_4_5 = true;
46 self.fsharp_5_0 = true;
47 self.fsharp_6_0 = true;
48 self.fsharp_7_0 = true;
49 self.computation_expressions = true;
50 self.type_providers = true;
51 self.async_workflows = true;
52 self.query_expressions = true;
53 self
54 }
55
56 pub fn with_version(mut self, major: u8, minor: u8) -> Self {
58 match (major, minor) {
59 (4, 0) => {
60 self.fsharp_4_0 = true;
61 }
62 (4, 1) => {
63 self.fsharp_4_0 = true;
64 self.fsharp_4_1 = true;
65 }
66 (4, 5) => {
67 self.fsharp_4_0 = true;
68 self.fsharp_4_1 = true;
69 self.fsharp_4_5 = true;
70 }
71 (5, 0) => {
72 self.fsharp_4_0 = true;
73 self.fsharp_4_1 = true;
74 self.fsharp_4_5 = true;
75 self.fsharp_5_0 = true;
76 }
77 (6, 0) => {
78 self.fsharp_4_0 = true;
79 self.fsharp_4_1 = true;
80 self.fsharp_4_5 = true;
81 self.fsharp_5_0 = true;
82 self.fsharp_6_0 = true;
83 }
84 (7, 0) => {
85 self.fsharp_4_0 = true;
86 self.fsharp_4_1 = true;
87 self.fsharp_4_5 = true;
88 self.fsharp_5_0 = true;
89 self.fsharp_6_0 = true;
90 self.fsharp_7_0 = true;
91 }
92 _ => {}
93 }
94 self
95 }
96
97 pub fn with_computation_expressions(mut self, enabled: bool) -> Self {
99 self.computation_expressions = enabled;
100 self
101 }
102
103 pub fn with_type_providers(mut self, enabled: bool) -> Self {
105 self.type_providers = enabled;
106 self
107 }
108
109 pub fn with_async_workflows(mut self, enabled: bool) -> Self {
111 self.async_workflows = enabled;
112 self
113 }
114
115 pub fn with_query_expressions(mut self, enabled: bool) -> Self {
117 self.query_expressions = enabled;
118 self
119 }
120}
121
122pub struct FSharpRoot;
123
124impl Language for FSharpLanguage {
125 const NAME: &'static str = "fsharp";
126 const CATEGORY: LanguageCategory = LanguageCategory::Programming;
127
128 type TokenType = crate::kind::FSharpSyntaxKind;
129 type ElementType = crate::kind::FSharpSyntaxKind;
130 type TypedRoot = FSharpRoot;
131}