refactor TopContext to use a ModContext for the current context

This commit is contained in:
2026-02-21 21:27:54 -08:00
parent 0a5ad3cc9b
commit 34744a8edc
11 changed files with 112 additions and 122 deletions

View File

@@ -1,7 +1,6 @@
module LSP
import Prelude
-- TODO pull this into its own file
import Lib.Common
import Lib.Eval
import Lib.Types
@@ -165,7 +164,7 @@ errorToDiag (Postpone fc qn msg) = errorToDiag $ E fc "Postpone \{show qn} \{msg
getInfos : M (List Json)
getInfos = do
top <- getTop
go Nil $ listValues $ top.metaCtx.metas
go Nil $ listValues $ top.currentMod.modMetaCtx.metas
where
go : List Json → List MetaEntry → M (List Json)
go acc Nil = pure acc
@@ -194,13 +193,12 @@ checkFile fn = unsafePerformIO $ do
then resetState base
else pure MkUnit
(Right (top, json)) <- (do
modifyTop [ errors := Nil ]
putStrLn "processModule"
_ <- switchModule lspFileSource modName
-- pull out errors and infos
top <- getTop
let errors = map (errorToDiag) top.errors
let errors = map (errorToDiag) top.currentMod.modErrors
infos <- getInfos
pure $ infos ++ errors
).runM st.topContext