git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #790 from purescript/completion

Auto complete names of foreign imports

commit2881a5be8aacb6096663a7673fc2d40afc18e1c3 authorPhil Freeman <paf31@cantab.net> dateSun 28 Dec 2014, 18:13 (12 years ago) parentc7209c8f253eb2
1 file changed+11−6
psci/Main.hs+11−6
psci/Main.hs+11−6
@@ -234,22 +234,27 @@ completion = completeWordWithPrev Nothing " \t\n\r" findCompletions
234234
235235 getLoadedModules :: StateT PSCiState IO [P.Module]
236236 getLoadedModules = map snd . psciLoadedModules <$> get
237+
237238 getModuleNames :: StateT PSCiState IO [String]
238239 getModuleNames = moduleNames <$> getLoadedModules
240+
239241 getIdentNames :: StateT PSCiState IO [String]
240242 getIdentNames = identNames <$> getLoadedModules
241243
242244 getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
243− getDeclName Nothing (P.ValueDeclaration ident _ _ _) = Just ident
244− getDeclName (Just exts) (P.ValueDeclaration ident _ _ _) | isExported = Just ident
245+ getDeclName exts (P.ValueDeclaration ident _ _ _) | isExported ident exts = Just ident
246+ getDeclName exts (P.ExternDeclaration _ ident _ _) | isExported ident exts = Just ident
247+ getDeclName exts (P.PositionedDeclaration _ d) = getDeclName exts d
248+ getDeclName _ _ = Nothing
249+
250+ isExported :: N.Ident -> Maybe [P.DeclarationRef] -> Bool
251+ isExported ident = maybe True (any exports)
245252 where
246− isExported = any exports exts
253+ exports :: P.DeclarationRef -> Bool
247254 exports (P.ValueRef ident') = ident == ident'
248255 exports (P.PositionedDeclarationRef _ r) = exports r
249256 exports _ = False
250− getDeclName exts (P.PositionedDeclaration _ d) = getDeclName exts d
251− getDeclName _ _ = Nothing
252−
257+
253258 identNames :: [P.Module] -> [String]
254259 identNames ms = nub [ show qual
255260 | P.Module moduleName ds exts <- ms