Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Language/PureScript/Ide.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import Language.PureScript.Ide.Util (discardAnn, identifierFromIdeDeclaration, n
import Language.PureScript.Ide.Usage (findUsages)
import System.Directory (getCurrentDirectory, getDirectoryContents, doesDirectoryExist, doesFileExist)
import System.FilePath ((</>), normalise)
import Control.Concurrent.Async.Lifted (mapConcurrently, mapConcurrently_)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: insert into the imports in alphabetical order, please.


-- | Accepts a Command and runs it against psc-ide's State. This is the main
-- entry point for the server.
Expand Down Expand Up @@ -219,16 +220,16 @@ loadModules moduleNames = do
oDir <- outputDirectory
let efPaths =
map (\mn -> oDir </> toS (P.runModuleName mn) </> P.externsFileName) moduleNames
efiles <- traverse readExternFile efPaths
traverse_ insertExterns efiles
efiles <- mapConcurrently readExternFile efPaths
mapConcurrently_ insertExterns efiles

-- We parse all source files, log eventual parse failures and insert the
-- successful parses into the state.
(failures, allModules) <-
partitionEithers <$> (parseModulesFromFiles =<< findAllSourceFiles)
unless (null failures) $
logWarnN ("Failed to parse: " <> show failures)
traverse_ insertModule allModules
mapConcurrently_ insertModule allModules

pure (TextResult ("Loaded " <> show (length efiles) <> " modules and "
<> show (length allModules) <> " source files."))
6 changes: 4 additions & 2 deletions src/Language/PureScript/Ide/SourceFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import Language.PureScript.CST qualified as CST
import Language.PureScript.Ide.Error (IdeError)
import Language.PureScript.Ide.Types (DefinitionSites, IdeNamespace(..), IdeNamespaced(..), TypeAnnotations)
import Language.PureScript.Ide.Util (ideReadFile)
import Control.Concurrent.Async.Lifted (mapConcurrently)
import Control.Monad.Trans.Control (MonadBaseControl)
Comment on lines +32 to +33
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same nit.


parseModule :: FilePath -> Text -> Either FilePath (FilePath, P.Module)
parseModule path file =
Expand All @@ -37,11 +39,11 @@ parseModule path file =
Right m -> Right (path, m)

parseModulesFromFiles
:: (MonadIO m, MonadError IdeError m)
:: (MonadIO m, MonadBaseControl IO m, MonadError IdeError m)
=> [FilePath]
-> m [Either FilePath (FilePath, P.Module)]
parseModulesFromFiles paths = do
files <- traverse ideReadFile paths
files <- mapConcurrently ideReadFile paths
pure (inParallel (map (uncurry parseModule) files))
where
inParallel :: [Either e (k, a)] -> [Either e (k, a)]
Expand Down
3 changes: 2 additions & 1 deletion src/Language/PureScript/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Data.Map.Lazy qualified as M
import Language.PureScript qualified as P
import Language.PureScript.Errors.JSON qualified as P
import Language.PureScript.Ide.Filter.Declaration (DeclarationType(..))
import Control.Monad.Trans.Control (MonadBaseControl)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same nit.


type ModuleIdent = Text
type ModuleMap a = Map P.ModuleName a
Expand Down Expand Up @@ -173,7 +174,7 @@ data IdeEnvironment =
, ideCacheDbTimestamp :: IORef (Maybe UTCTime)
}

type Ide m = (MonadIO m, MonadReader IdeEnvironment m)
type Ide m = (MonadIO m, MonadBaseControl IO m, MonadReader IdeEnvironment m)

data IdeState = IdeState
{ ideFileState :: IdeFileState
Expand Down