Skip to content

Commit ee1702b

Browse files
author
kokobd
committed
add some doc comments
1 parent c45d471 commit ee1702b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lsp-types/src/Language/LSP/Types/Uri.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ platformAdjustToUriPath systemOS srcPath
164164
FPP.addTrailingPathSeparator (init drv)
165165
| otherwise = drv
166166

167-
-- | A file path that is already normalized. It is stored in a 'ShortByteString' with UTF-8 encoding.
167+
-- | A file path that is already normalized. It is stored as an UTF-8 encoded 'ShortByteString'
168168
--
169-
-- The NormalizedUri is cached to avoided
169+
-- The 'NormalizedUri' is cached to avoided
170170
-- repeated normalisation when we need to compute them (which is a lot).
171171
--
172172
-- This is one of the most performance critical parts of ghcide, do not
@@ -218,9 +218,8 @@ toNormalizedFilePath fp = NormalizedFilePath nuri . encodeFilePath $ nfp
218218
nfp = FP.normalise fp
219219
nuri = internalNormalizedFilePathToUri nfp
220220

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.
224223
fromNormalizedFilePath :: HasCallStack => NormalizedFilePath -> FilePath
225224
fromNormalizedFilePath (NormalizedFilePath _ fp) =
226225
case decodeFilePath fp of
@@ -239,6 +238,7 @@ emptyNormalizedUri =
239238
let s = "file://"
240239
in NormalizedUri (hash s) s
241240

241+
-- | 'NormalizedFilePath' that contains an empty file path
242242
emptyNormalizedFilePath :: NormalizedFilePath
243243
emptyNormalizedFilePath = NormalizedFilePath emptyNormalizedUri ""
244244

lsp-types/src/Language/LSP/Types/Uri/OsPath.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ module Language.LSP.Types.Uri.OsPath
1616
#ifdef OS_PATH
1717

1818
import Control.DeepSeq (NFData, force)
19+
import Control.Exception hiding (try)
1920
import Control.Monad.Catch
20-
import GHC.IO (evaluate)
2121
import Language.LSP.Types.Uri
2222
import System.IO.Unsafe (unsafePerformIO)
2323
import System.OsPath
2424

25+
{-|
26+
Constructs 'NormalizedFilePath' from 'OsPath'. Throws 'IOException' if the conversion fails.
27+
-}
2528
osPathToNormalizedFilePath :: MonadThrow m => OsPath -> m NormalizedFilePath
2629
osPathToNormalizedFilePath = fmap toNormalizedFilePath . unsafePerformIO' . decodeFS
2730

31+
{-|
32+
Extracts 'OsPath' from 'NormalizedFilePath'. Throws 'IOException' if the conversion fails.
33+
-}
2834
normalizedFilePathToOsPath :: MonadThrow m => NormalizedFilePath -> m OsPath
2935
normalizedFilePathToOsPath = unsafePerformIO' . encodeFS . fromNormalizedFilePath
3036

0 commit comments

Comments
 (0)