git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #801 from vkorablin/completion
37205c8Phil Freeman
psci/Main.hs+1−1
@@ -274,7 +274,7 @@ completion = completeWordWithPrev Nothing " \t\n\r" findCompletions
274 getTypeName _ = Nothing
274 getTypeName _ = Nothing
275
275
276 identNames :: P.Module -> [N.Ident]
276 identNames :: P.Module -> [N.Ident]
277− identNames (P.Module _ ds exports) = nub [ ident | ident <- mapMaybe (getDeclName exports) ds ]
277+ identNames (P.Module _ ds exports) = nub [ ident | ident <- mapMaybe (getDeclName exports) (D.flattenDecls ds) ]
278 where getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
278 where getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
279 getDeclName exts decl@(P.ValueDeclaration ident _ _ _) | P.isExported exts decl = Just ident
279 getDeclName exts decl@(P.ValueDeclaration ident _ _ _) | P.isExported exts decl = Just ident
280 getDeclName exts decl@(P.ExternDeclaration _ ident _ _) | P.isExported exts decl = Just ident
280 getDeclName exts decl@(P.ExternDeclaration _ ident _ _) | P.isExported exts decl = Just ident
src/Language/PureScript/AST/Declarations.hs+10−2
@@ -59,7 +59,7 @@ isExported (Just exps) decl = any (matches decl) exps
59 matches _ _ = False
59 matches _ _ = False
60
60
61exportedDeclarations :: Module -> [Declaration]
61exportedDeclarations :: Module -> [Declaration]
62−exportedDeclarations (Module _ decls exps) = filter (isExported exps) decls
62+exportedDeclarations (Module _ decls exps) = filter (isExported exps) (flattenDecls decls)
63
63
64-- |
64-- |
65-- Test if a data constructor for a given type is exported, given a module's export list.
65-- Test if a data constructor for a given type is exported, given a module's export list.
@@ -80,7 +80,7 @@ exportedDctors :: Module -> ProperName -> [ProperName]
80exportedDctors (Module _ decls exps) ident =
80exportedDctors (Module _ decls exps) ident =
81 filter (isDctorExported ident exps) dctors
81 filter (isDctorExported ident exps) dctors
82 where
82 where
83− dctors = concatMap getDctors decls
83+ dctors = concatMap getDctors (flattenDecls decls)
84 getDctors (DataDeclaration _ _ _ ctors) = map fst ctors
84 getDctors (DataDeclaration _ _ _ ctors) = map fst ctors
85 getDctors (PositionedDeclaration _ d) = getDctors d
85 getDctors (PositionedDeclaration _ d) = getDctors d
86 getDctors _ = []
86 getDctors _ = []
@@ -267,6 +267,14 @@ isTypeClassDeclaration TypeInstanceDeclaration{} = True
267isTypeClassDeclaration (PositionedDeclaration _ d) = isTypeClassDeclaration d
267isTypeClassDeclaration (PositionedDeclaration _ d) = isTypeClassDeclaration d
268isTypeClassDeclaration _ = False
268isTypeClassDeclaration _ = False
269
269
270+-- |
271+-- Recursively flatten data binding groups in the list of declarations
272+flattenDecls :: [Declaration] -> [Declaration]
273+flattenDecls = concatMap flattenOne
274+ where flattenOne :: Declaration -> [Declaration]
275+ flattenOne (DataBindingGroupDeclaration decls) = concatMap flattenOne decls
276+ flattenOne d = [d]
277+
270-- |
278-- |
271-- A guard is just a boolean-valued expression that appears alongside a set of binders
279-- A guard is just a boolean-valued expression that appears alongside a set of binders
272--
280--