git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
PSCI: unwrap data binding groups during completion
commitea9bad069800847be9efec844ae45219374e88b2 authorVladimir Korablin <vkorablin@gmail.com> dateThu 8 Jan 2015, 21:39 (12 years ago) parentc542b4f
2 files changed+11−3
psci/Main.hs+1−1 src/Language/PureScript/AST/Declarations.hs+10−2
psci/Main.hs+1−1
@@ -274,7 +274,7 @@ completion = completeWordWithPrev Nothing " \t\n\r" findCompletions
274274 getTypeName _ = Nothing
275275
276276 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) ]
278278 where getDeclName :: Maybe [P.DeclarationRef] -> P.Declaration -> Maybe P.Ident
279279 getDeclName exts decl@(P.ValueDeclaration ident _ _ _) | P.isExported exts decl = Just ident
280280 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
5959 matches _ _ = False
6060
6161exportedDeclarations :: Module -> [Declaration]
62−exportedDeclarations (Module _ decls exps) = filter (isExported exps) decls
62+exportedDeclarations (Module _ decls exps) = filter (isExported exps) (flattenDecls decls)
6363
6464-- |
6565-- 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]
8080exportedDctors (Module _ decls exps) ident =
8181 filter (isDctorExported ident exps) dctors
8282 where
83− dctors = concatMap getDctors decls
83+ dctors = concatMap getDctors (flattenDecls decls)
8484 getDctors (DataDeclaration _ _ _ ctors) = map fst ctors
8585 getDctors (PositionedDeclaration _ d) = getDctors d
8686 getDctors _ = []
@@ -267,6 +267,14 @@ isTypeClassDeclaration TypeInstanceDeclaration{} = True
267267isTypeClassDeclaration (PositionedDeclaration _ d) = isTypeClassDeclaration d
268268isTypeClassDeclaration _ = False
269269
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+
270278-- |
271279-- A guard is just a boolean-valued expression that appears alongside a set of binders
272280--