@@ -39,7 +39,7 @@ import Language.PureScript.Ide.Filter
39import Language.PureScript.Ide.State
39import Language.PureScript.Ide.State
40import Language.PureScript.Ide.Types
40import Language.PureScript.Ide.Types
41import Language.PureScript.Ide.Util
41import Language.PureScript.Ide.Util
42−import System.IO.UTF8 (readUTF8FileT, writeUTF8FileT)
42+import System.IO.UTF8 (writeUTF8FileT)
44data Import = Import P.ModuleName P.ImportDeclarationType (Maybe P.ModuleName)
44data Import = Import P.ModuleName P.ImportDeclarationType (Maybe P.ModuleName)
45 deriving (Eq, Show)
45 deriving (Eq, Show)
@@ -67,10 +67,10 @@ compImport (Import n i q) (Import n' i' q')
68-- | Reads a file and returns the (lines before the imports, the imports, the
68-- | Reads a file and returns the (lines before the imports, the imports, the
69-- lines after the imports)
69-- lines after the imports)
70−parseImportsFromFile :: (MonadIO m, MonadError PscIdeError m) =>
70+parseImportsFromFile :: (MonadIO m, MonadError IdeError m) =>
71 FilePath -> m (P.ModuleName, [Text], [Import], [Text])
71 FilePath -> m (P.ModuleName, [Text], [Import], [Text])
72parseImportsFromFile fp = do
72parseImportsFromFile fp = do
73− file <- liftIO (readUTF8FileT fp)
73+ file <- ideReadFile fp
74 case sliceImportSection (T.lines file) of
74 case sliceImportSection (T.lines file) of
75 Right res -> pure res
75 Right res -> pure res
76 Left err -> throwError (GeneralError err)
76 Left err -> throwError (GeneralError err)
@@ -147,7 +147,7 @@ moduleParse t = first show $ do
147 P.runTokenParser "<psc-ide>" P.parseModule tokens
147 P.runTokenParser "<psc-ide>" P.parseModule tokens
149-- | Adds an implicit import like @import Prelude@ to a Sourcefile.
149-- | Adds an implicit import like @import Prelude@ to a Sourcefile.
150−addImplicitImport :: (MonadIO m, MonadError PscIdeError m)
150+addImplicitImport :: (MonadIO m, MonadError IdeError m)
151 => FilePath -- ^ The Sourcefile read from
151 => FilePath -- ^ The Sourcefile read from
152 -> P.ModuleName -- ^ The module to import
152 -> P.ModuleName -- ^ The module to import
153 -> m [Text]
153 -> m [Text]
@@ -170,7 +170,7 @@ addImplicitImport' imports mn =
170-- So @addExplicitImport "/File.purs" "bind" "Prelude"@ with an already existing
170-- So @addExplicitImport "/File.purs" "bind" "Prelude"@ with an already existing
171-- @import Prelude (bind)@ in the file File.purs returns @["import Prelude
171-- @import Prelude (bind)@ in the file File.purs returns @["import Prelude
172-- (bind, unit)"]@
172-- (bind, unit)"]@
173−addExplicitImport :: (MonadIO m, MonadError PscIdeError m) =>
173+addExplicitImport :: (MonadIO m, MonadError IdeError m) =>
174 FilePath -> IdeDeclaration -> P.ModuleName -> m [Text]
174 FilePath -> IdeDeclaration -> P.ModuleName -> m [Text]
175addExplicitImport fp decl moduleName = do
175addExplicitImport fp decl moduleName = do
176 (mn, pre, imports, post) <- parseImportsFromFile fp
176 (mn, pre, imports, post) <- parseImportsFromFile fp
@@ -249,7 +249,7 @@ updateAtFirstOrPrepend p t d l =
250-- * If more than one possible imports are found, reports the possibilities as a
250-- * If more than one possible imports are found, reports the possibilities as a
251-- list of completions.
251-- list of completions.
252−addImportForIdentifier :: (Ide m, MonadError PscIdeError m)
252+addImportForIdentifier :: (Ide m, MonadError IdeError m)
253 => FilePath -- ^ The Sourcefile to read from
253 => FilePath -- ^ The Sourcefile to read from
254 -> Text -- ^ The identifier to import
254 -> Text -- ^ The identifier to import
255 -> [Filter] -- ^ Filters to apply before searching for
255 -> [Filter] -- ^ Filters to apply before searching for