From 65fc5bec75594167230a70d96e5f2cd1e4b71a4d Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 3 Jul 2020 20:35:58 +0400 Subject: [PATCH] Separate env-tree construction and usage --- tools/lsp/squirrel/src/AST/Scope.hs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/lsp/squirrel/src/AST/Scope.hs b/tools/lsp/squirrel/src/AST/Scope.hs index 8e3e2eb2e..0ce1c7767 100644 --- a/tools/lsp/squirrel/src/AST/Scope.hs +++ b/tools/lsp/squirrel/src/AST/Scope.hs @@ -5,12 +5,12 @@ -} module AST.Scope - ( HasLocalScope (..) - , addLocalScopes - , lookupEnv - , Kind (..) - , ScopedDecl (..) - ) + -- ( HasLocalScope (..) + -- , addLocalScopes + -- , lookupEnv + -- , Kind (..) + -- , ScopedDecl (..) + -- ) where import Control.Arrow (second) @@ -59,11 +59,15 @@ addLocalScopes -> Pascal (Product ([ScopedDecl] : xs)) addLocalScopes tree = fmap (\xs -> Cons (envAt envWithREfs $ getRange xs) xs) tree + where + envWithREfs = getEnvTree tree + +getEnvTree tree = envWithREfs where envWithREfs = flip execState env do flip traverseOnly tree \r (Name t) -> do - modify $ addRef (getRange r) t - return (Name t) + modify $ getRange r `addRef` t + return $ Name t env = execCollectM