Skip to content

Commit a07a714

Browse files
committed
[psc-ide] Multi phase load
1 parent 3629bd6 commit a07a714

30 files changed

+521
-529
lines changed

psc-ide-server/Main.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ main = do
8181
Options dir outputPath port noWatch debug <- execParser opts
8282
maybe (pure ()) setCurrentDirectory dir
8383
serverState <- newTVarIO emptyPscIdeState
84+
ideState <- newTVarIO emptyIdeState
8485
cwd <- getCurrentDirectory
8586
let fullOutputPath = cwd </> outputPath
8687

87-
doesDirectoryExist fullOutputPath
88-
>>= flip unless
89-
(do putStrLn ("Your output directory didn't exist. I'll create it at: " <> fullOutputPath)
90-
createDirectory fullOutputPath
91-
putStrLn "This usually means you didn't compile your project yet."
92-
putStrLn "psc-ide needs you to compile your project (for example by running pulp build)")
88+
unlessM (doesDirectoryExist fullOutputPath) $ do
89+
putStrLn ("Your output directory didn't exist. I'll create it at: " <> fullOutputPath)
90+
createDirectory fullOutputPath
91+
putStrLn "This usually means you didn't compile your project yet."
92+
putStrLn "psc-ide needs you to compile your project (for example by running pulp build)"
9393

9494
unless noWatch $
95-
void (forkFinally (watcher serverState fullOutputPath) print)
95+
void (forkFinally (watcher ideState fullOutputPath) print)
9696

9797
let conf = Configuration {confDebug = debug, confOutputPath = outputPath}
98-
env = PscIdeEnvironment {envStateVar = serverState, envConfiguration = conf}
98+
env = IdeEnvironment {envStateVar = serverState, ideStateVar = ideState, ideConfiguration = conf}
9999
startServer port env
100100
where
101101
parser =
@@ -111,14 +111,14 @@ main = do
111111
(InfoMsg (showVersion Paths.version))
112112
(long "version" <> help "Show the version number")
113113

114-
startServer :: PortID -> PscIdeEnvironment -> IO ()
114+
startServer :: PortID -> IdeEnvironment -> IO ()
115115
startServer port env = withSocketsDo $ do
116116
sock <- listenOnLocalhost port
117117
runLogger (runReaderT (forever (loop sock)) env)
118118
where
119-
runLogger = runStdoutLoggingT . filterLogger (\_ _ -> confDebug (envConfiguration env))
119+
runLogger = runStdoutLoggingT . filterLogger (\_ _ -> confDebug (ideConfiguration env))
120120

121-
loop :: (PscIde m, MonadLogger m) => Socket -> m ()
121+
loop :: (Ide m, MonadLogger m) => Socket -> m ()
122122
loop sock = do
123123
accepted <- runExceptT $ acceptCommand sock
124124
case accepted of

psc-ide-server/PROTOCOL.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,20 @@ to detect all the compiled modules in your project and load them.
1414

1515
**Params:**
1616
- `modules :: (optional) [ModuleName]`: A list of modules to load.
17-
psc-ide-server will try to parse all the declarations in these modules
18-
- `dependencies :: (optional) [ModuleName]`: A list of modules to load
19-
including their dependencies. In contrast to the `module` field, all the
20-
imports in these Modules will also be loaded.
17+
psc-ide-server will try to parse all the declarations in these modules
2118

2219
```json
2320
{
2421
"command": "load",
2522
"params": (optional) {
26-
"modules": (optional)["Module.Name1", "Module.Name2"],
27-
"dependencies": (optional)["Module.Name3"]
23+
"modules": (optional)["Module.Name1", "Module.Name2"]
2824
}
2925
}
3026
```
3127

3228
**Result:**
3329

34-
The Load Command returns a string.
30+
The Load Command returns a string with a summary about the loading process.
3531

3632
### Type
3733
The `type` command looks up the type for a given identifier.

purescript.cabal

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ library
101101
aeson >= 0.8 && < 0.12,
102102
aeson-better-errors >= 0.8,
103103
ansi-terminal >= 0.6.2 && < 0.7,
104+
async,
104105
base-compat >=0.6.0,
105106
bower-json >= 0.8,
106107
boxes >= 0.1.4 && < 0.2.0,
@@ -251,22 +252,23 @@ library
251252
Language.PureScript.Publish.BoxesHelpers
252253

253254
Language.PureScript.Ide
255+
Language.PureScript.Ide.CaseSplit
254256
Language.PureScript.Ide.Command
257+
Language.PureScript.Ide.Completion
258+
Language.PureScript.Ide.Conversions
255259
Language.PureScript.Ide.Externs
256260
Language.PureScript.Ide.Error
257-
Language.PureScript.Ide.Pursuit
258-
Language.PureScript.Ide.Completion
259-
Language.PureScript.Ide.Matcher
261+
Language.PureScript.Ide.Imports
260262
Language.PureScript.Ide.Filter
261-
Language.PureScript.Ide.Types
262-
Language.PureScript.Ide.State
263-
Language.PureScript.Ide.CaseSplit
264-
Language.PureScript.Ide.SourceFile
265-
Language.PureScript.Ide.Watcher
263+
Language.PureScript.Ide.Matcher
264+
Language.PureScript.Ide.Pursuit
265+
Language.PureScript.Ide.Rebuild
266266
Language.PureScript.Ide.Reexports
267-
Language.PureScript.Ide.Imports
267+
Language.PureScript.Ide.SourceFile
268+
Language.PureScript.Ide.State
269+
Language.PureScript.Ide.Types
268270
Language.PureScript.Ide.Util
269-
Language.PureScript.Ide.Rebuild
271+
Language.PureScript.Ide.Watcher
270272

271273
Language.PureScript.Interactive
272274
Language.PureScript.Interactive.Types
@@ -498,6 +500,5 @@ test-suite tests
498500
Language.PureScript.Ide.MatcherSpec
499501
Language.PureScript.Ide.RebuildSpec
500502
Language.PureScript.Ide.ReexportsSpec
501-
Language.PureScript.IdeSpec
502503
buildable: True
503504
hs-source-dirs: tests

0 commit comments

Comments
 (0)