Skip to content

Commit 663659c

Browse files
committed
start removal of state
1 parent 7da06be commit 663659c

File tree

6 files changed

+165
-170
lines changed

6 files changed

+165
-170
lines changed

purescript.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ library
306306
Language.PureScript.Hierarchy
307307
Language.PureScript.Ide
308308
Language.PureScript.Ide.CaseSplit
309+
Language.PureScript.Ide.Cache
309310
Language.PureScript.Ide.Command
310311
Language.PureScript.Ide.Completion
311312
Language.PureScript.Ide.Error

src/Language/PureScript/AST/Declarations.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ data UnknownsHint
120120
-- explicitly exported. If the export list is Nothing, everything is exported.
121121
--
122122
data Module = Module SourceSpan [Comment] ModuleName [Declaration] (Maybe [DeclarationRef])
123-
deriving (Show)
123+
deriving (Show, Serialise, Generic)
124124

125125
-- | Return a module's name.
126126
getModuleName :: Module -> ModuleName
@@ -445,7 +445,7 @@ data Declaration
445445
-- declaration, while the second @SourceAnn@ serves as the
446446
-- annotation for the type class and its arguments.
447447
| TypeInstanceDeclaration SourceAnn SourceAnn ChainId Integer (Either Text Ident) [SourceConstraint] (Qualified (ProperName 'ClassName)) [SourceType] TypeInstanceBody
448-
deriving (Show, Generic, NFData)
448+
deriving (Show, Generic, Serialise, NFData)
449449

450450
data ValueFixity = ValueFixity Fixity (Qualified (Either Ident (ProperName 'ConstructorName))) (OpName 'ValueOpName)
451451
deriving (Eq, Ord, Show, Generic, NFData)

src/Language/PureScript/Ide/State.hs

+6-12
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,7 @@ insertModule module' = do
117117
liftIO . atomically $ insertModuleSTM stateVar module'
118118

119119
-- | STM version of insertModule
120-
insertModuleSTM :: TVar IdeState -> (FilePath, P.Module) -> STM ()
121-
insertModuleSTM ref (fp, module') =
122-
modifyTVar ref $ \x ->
123-
x { ideFileState = (ideFileState x) {
124-
fsModules = Map.insert
125-
(P.getModuleName module')
126-
(module', fp)
127-
(fsModules (ideFileState x))}}
120+
128121

129122
-- | Retrieves the FileState from the State. This includes loaded Externfiles
130123
-- and parsed Modules
@@ -231,13 +224,14 @@ populateVolatileState = do
231224

232225
-- | STM version of populateVolatileState
233226
populateVolatileStateSTM
234-
:: TVar IdeState
227+
:: FilePath
235228
-> STM (ModuleMap (ReexportResult [IdeDeclarationAnn]))
236-
populateVolatileStateSTM ref = do
237-
IdeFileState{fsExterns = externs, fsModules = modules} <- getFileStateSTM ref
229+
populateVolatileStateSTM outputPath = do
230+
-- IdeFileState{fsExterns = externs, fsModules = modules} <- getFileStateSTM outputPath
238231
-- We're not using the cached rebuild for anything other than preserving it
239232
-- through the repopulation
240-
rebuildCache <- vsCachedRebuild <$> getVolatileStateSTM ref
233+
rebuildCache <- vsCachedRebuild <$> getVolatileStateSTM outputPath
234+
241235
let asts = map (extractAstInformation . fst) modules
242236
let (moduleDeclarations, reexportRefs) = unzip (Map.map convertExterns externs)
243237
results =

0 commit comments

Comments
 (0)