@@ -4,26 +4,34 @@ import Language.LSP.Protocol.Internal.Types (WatchKind(..))
4
4
import Language.LSP.Protocol.Types.LspEnum (toEnumBaseType , fromOpenEnumBaseType )
5
5
import Data.Set (toList , Set )
6
6
7
+ -- WatchKind is better represented as a Set than as enum. As the lsp spec
8
+ -- defines them as an enum, these helper functions help bridge the difference.
9
+
10
+ -- | Tests whether `WatchKind_Create` is contained in the provided WatchKind enum
7
11
containsCreate :: WatchKind -> Bool
8
12
containsCreate WatchKind_Create = True
9
13
containsCreate (WatchKind_Custom 3 ) = True
10
14
containsCreate (WatchKind_Custom 5 ) = True
11
15
containsCreate (WatchKind_Custom 7 ) = True
12
16
containsCreate _ = False
13
17
18
+ -- | Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
14
19
containsChange :: WatchKind -> Bool
15
20
containsChange WatchKind_Change = True
16
21
containsChange (WatchKind_Custom 3 ) = True
17
22
containsChange (WatchKind_Custom 6 ) = True
18
23
containsChange (WatchKind_Custom 7 ) = True
19
24
containsChange _ = False
20
25
26
+ -- | Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
21
27
containsDelete :: WatchKind -> Bool
22
28
containsDelete WatchKind_Delete = True
23
29
containsDelete (WatchKind_Custom 5 ) = True
24
30
containsDelete (WatchKind_Custom 6 ) = True
25
31
containsDelete (WatchKind_Custom 7 ) = True
26
32
containsDelete _ = False
27
33
34
+ -- | Combine a set of WatchKind types into a new WatchKind type that accurately
35
+ -- represents the set
28
36
combineWatchKinds :: Set WatchKind -> WatchKind
29
37
combineWatchKinds s = fromOpenEnumBaseType $ sum $ toEnumBaseType <$> toList s
0 commit comments