@@ -4,26 +4,34 @@ import Language.LSP.Protocol.Internal.Types (WatchKind(..))
44import Language.LSP.Protocol.Types.LspEnum (toEnumBaseType , fromOpenEnumBaseType )
55import Data.Set (toList , Set )
66
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
711containsCreate :: WatchKind -> Bool
812containsCreate WatchKind_Create = True
913containsCreate (WatchKind_Custom 3 ) = True
1014containsCreate (WatchKind_Custom 5 ) = True
1115containsCreate (WatchKind_Custom 7 ) = True
1216containsCreate _ = False
1317
18+ -- | Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
1419containsChange :: WatchKind -> Bool
1520containsChange WatchKind_Change = True
1621containsChange (WatchKind_Custom 3 ) = True
1722containsChange (WatchKind_Custom 6 ) = True
1823containsChange (WatchKind_Custom 7 ) = True
1924containsChange _ = False
2025
26+ -- | Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
2127containsDelete :: WatchKind -> Bool
2228containsDelete WatchKind_Delete = True
2329containsDelete (WatchKind_Custom 5 ) = True
2430containsDelete (WatchKind_Custom 6 ) = True
2531containsDelete (WatchKind_Custom 7 ) = True
2632containsDelete _ = False
2733
34+ -- | Combine a set of WatchKind types into a new WatchKind type that accurately
35+ -- represents the set
2836combineWatchKinds :: Set WatchKind -> WatchKind
2937combineWatchKinds s = fromOpenEnumBaseType $ sum $ toEnumBaseType <$> toList s
0 commit comments