git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Filter exported names in psci autocomplete method #238
commit973babe454f4412339ea1d6ec4bcccc6660a6f5f authorPhil Freeman <paf31@cantab.net> dateWed 5 Mar 2014, 22:53 (13 years ago) parentd21440c
3 files changed+13−6
docgen/Main.hs−1 examples/passing/ExportExplicit.purs+3 psci/Main.hs+10−5
docgen/Main.hs−1
@@ -58,7 +58,6 @@ renderModules ms = do
5858 headerLevel 1 "Module Documentation"
5959 mapM_ renderModule ms
6060
61−-- TODO: filter everything by exports
6261renderModule :: P.Module -> Docs
6362renderModule (P.Module moduleName ds exps) =
6463 let exported = filter (isExported exps) ds
examples/passing/ExportExplicit.purs+3
@@ -6,6 +6,9 @@ module M1 (X(X), Z(..), foo) where
66 foo :: Number
77 foo = 0
88
9+ bar :: Number
10+ bar = 1
11+
912module Main where
1013
1114 import M1
psci/Main.hs+10−5
@@ -172,13 +172,18 @@ completion = completeWord Nothing " \t\n\r" findCompletions
172172 files <- listFiles str
173173 let matches = filter (isPrefixOf str) (names ms)
174174 return $ sortBy sorter $ map simpleCompletion matches ++ files
175− getDeclName :: P.Declaration -> Maybe P.Ident
176− getDeclName (P.ValueDeclaration ident _ _ _) = Just ident
177− getDeclName _ = Nothing
175+ getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
176+ getDeclName Nothing (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
182+ getDeclName _ _ = Nothing
178183 names :: [P.Module] -> [String]
179184 names ms = nub [ show qual
180− | P.Module moduleName ds _ <- ms
181− , ident <- mapMaybe getDeclName ds
185+ | P.Module moduleName ds exts <- ms
186+ , ident <- mapMaybe (getDeclName exts) ds
182187 , qual <- [ P.Qualified Nothing ident
183188 , P.Qualified (Just moduleName) ident]
184189 ]