File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
lsp-types/src/Language/LSP/Types Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -218,9 +218,8 @@ toNormalizedFilePath fp = NormalizedFilePath nuri . encodeFilePath $ nfp
218
218
nfp = FP. normalise fp
219
219
nuri = internalNormalizedFilePathToUri nfp
220
220
221
- -- | Extract 'FilePath' from 'NormalizedFilePath'.
222
- -- The function is total if 'NormalizedFilePath' is valid. The 'HasCallStack' constraint is added
223
- -- for debugging purpose, in case an invalid
221
+ -- | Extracts 'FilePath' from 'NormalizedFilePath'.
222
+ -- The function is total. The 'HasCallStack' constraint is added for debugging purpose only.
224
223
fromNormalizedFilePath :: HasCallStack => NormalizedFilePath -> FilePath
225
224
fromNormalizedFilePath (NormalizedFilePath _ fp) =
226
225
case decodeFilePath fp of
@@ -239,6 +238,7 @@ emptyNormalizedUri =
239
238
let s = " file://"
240
239
in NormalizedUri (hash s) s
241
240
241
+ -- | 'NormalizedFilePath' that contains an empty file path
242
242
emptyNormalizedFilePath :: NormalizedFilePath
243
243
emptyNormalizedFilePath = NormalizedFilePath emptyNormalizedUri " "
244
244
Original file line number Diff line number Diff line change @@ -16,15 +16,21 @@ module Language.LSP.Types.Uri.OsPath
16
16
#ifdef OS_PATH
17
17
18
18
import Control.DeepSeq (NFData , force )
19
+ import Control.Exception hiding (try )
19
20
import Control.Monad.Catch
20
- import GHC.IO (evaluate )
21
21
import Language.LSP.Types.Uri
22
22
import System.IO.Unsafe (unsafePerformIO )
23
23
import System.OsPath
24
24
25
+ {-|
26
+ Constructs 'NormalizedFilePath' from 'OsPath'. Throws 'IOException' if the conversion fails.
27
+ -}
25
28
osPathToNormalizedFilePath :: MonadThrow m => OsPath -> m NormalizedFilePath
26
29
osPathToNormalizedFilePath = fmap toNormalizedFilePath . unsafePerformIO' . decodeFS
27
30
31
+ {-|
32
+ Extracts 'OsPath' from 'NormalizedFilePath'. Throws 'IOException' if the conversion fails.
33
+ -}
28
34
normalizedFilePathToOsPath :: MonadThrow m => NormalizedFilePath -> m OsPath
29
35
normalizedFilePathToOsPath = unsafePerformIO' . encodeFS . fromNormalizedFilePath
30
36
You can’t perform that action at this time.
0 commit comments