Show user info messages in LSP, invalidate modules transitively on change

This commit is contained in:
2026-02-16 09:22:49 -08:00
parent adff28ea0f
commit d86c257426
2 changed files with 50 additions and 3 deletions

View File

@@ -138,6 +138,26 @@ processModule importFC repo stk modns = do
(Left err) <- tryError $ processDecl ns decl | _ => pure MkUnit
addError err
-- NOW TODO clear dependents too.
-- invalidate Module and anyone who depends on it
invalidateModule : String -> M Unit
invalidateModule modname = modifyTop [modules $= deleteMap modname]
invalidateModule modname = do
top <- getTop
let modules = join $ map getDeps $ toList top.modules
let revMap = map swap modules
let deps = foldl accumulate emptyMap revMap
go deps $ modname :: Nil
where
accumulate : SortedMap String (List String) String × String SortedMap String (List String)
accumulate deps (k,v) = let prev = fromMaybe Nil $ lookupMap' k deps
in updateMap k (v :: prev) deps
getDeps : String × ModContext List (String × String)
getDeps (nm, mod) = map (nm , ) mod.modDeps
go : SortedMap String (List String) List String M Unit
go deps Nil = pure MkUnit
go deps (name :: names) = do
modifyTop [modules $= deleteMap name]
let ds = fromMaybe Nil $ lookupMap' name deps
putStrLn "Chase \{name} → \{show ds}"
go deps $ ds ++ names