git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Filter exported names in psci autocomplete method #238
973babePhil Freeman
docgen/Main.hs−1
@@ -58,7 +58,6 @@ renderModules ms = do
58 headerLevel 1 "Module Documentation"
58 headerLevel 1 "Module Documentation"
59 mapM_ renderModule ms
59 mapM_ renderModule ms
60
60
61−-- TODO: filter everything by exports
62renderModule :: P.Module -> Docs
61renderModule :: P.Module -> Docs
63renderModule (P.Module moduleName ds exps) =
62renderModule (P.Module moduleName ds exps) =
64 let exported = filter (isExported exps) ds
63 let exported = filter (isExported exps) ds
examples/passing/ExportExplicit.purs+3
@@ -6,6 +6,9 @@ module M1 (X(X), Z(..), foo) where
6 foo :: Number
6 foo :: Number
7 foo = 0
7 foo = 0
8
8
9+ bar :: Number
10+ bar = 1
11+
9module Main where
12module Main where
10
13
11 import M1
14 import M1
psci/Main.hs+10−5
@@ -172,13 +172,18 @@ completion = completeWord Nothing " \t\n\r" findCompletions
172 files <- listFiles str
172 files <- listFiles str
173 let matches = filter (isPrefixOf str) (names ms)
173 let matches = filter (isPrefixOf str) (names ms)
174 return $ sortBy sorter $ map simpleCompletion matches ++ files
174 return $ sortBy sorter $ map simpleCompletion matches ++ files
175− getDeclName :: P.Declaration -> Maybe P.Ident
175+ getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
176+ getDeclName Nothing (P.ValueDeclaration ident _ _ _) = Just ident
176− getDeclName (P.ValueDeclaration ident _ _ _) = Just ident
177+ getDeclName (Just exts) (P.ValueDeclaration ident _ _ _) | isExported = Just ident
178+ where
179+ isExported = flip any exts $ \e -> case e of
180+ P.ValueRef ident' -> ident == ident'
181+ _ -> False
177− getDeclName _ = Nothing
182+ getDeclName _ _ = Nothing
178 names :: [P.Module] -> [String]
183 names :: [P.Module] -> [String]
179 names ms = nub [ show qual
184 names ms = nub [ show qual
180− | P.Module moduleName ds _ <- ms
185+ | P.Module moduleName ds exts <- ms
181− , ident <- mapMaybe getDeclName ds
186+ , ident <- mapMaybe (getDeclName exts) ds
182 , qual <- [ P.Qualified Nothing ident
187 , qual <- [ P.Qualified Nothing ident
183 , P.Qualified (Just moduleName) ident]
188 , P.Qualified (Just moduleName) ident]
184 ]
189 ]