Skip to content

Commit 0d5c227

Browse files
author
Jan Vogt
committed
Add missing utility for NormalizedPath
1 parent b61ba36 commit 0d5c227

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ghcide/src/Development/IDE/Core/PluginUtils.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Development.IDE.Core.PluginUtils
1515
, useWithStaleFastE
1616
, useWithStaleFastMT
1717
, uriToFilePathE
18+
, uriToNormalizedFilePathE
1819
-- * Wrapped PositionMapping functions
1920
, toCurrentPositionE
2021
, toCurrentPositionMT
@@ -136,6 +137,11 @@ useWithStaleFastMT k = MaybeT . Shake.useWithStaleFast k
136137
uriToFilePathE :: Monad m => LSP.Uri -> ExceptT PluginError m FilePath
137138
uriToFilePathE uri = maybeToExceptT (PluginInvalidParams (T.pack $ "uriToFilePath' failed. Uri:" <> show uri)) $ uriToFilePathMT uri
138139

140+
-- |ExceptT version of `toNormalizedFilePath . uriToFilePath` that throws a PluginInvalidParams upon
141+
-- failure
142+
uriToNormalizedFilePathE :: Monad m => LSP.Uri -> ExceptT PluginError m NormalizedFilePath
143+
uriToNormalizedFilePathE uri = LSP.toNormalizedFilePath <$> uriToFilePathE uri
144+
139145
-- |MaybeT version of `uriToFilePath`
140146
uriToFilePathMT :: Monad m => LSP.Uri -> MaybeT m FilePath
141147
uriToFilePathMT = MaybeT . pure . Location.uriToFilePath'

0 commit comments

Comments
 (0)