1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Produce a list of named children of a node.

This commit is contained in:
Rob Rix 2015-11-25 12:05:25 -05:00
parent e87459d608
commit b39bc3e33e

View File

@ -94,6 +94,14 @@ withNode writer = do
node <- (mallocForeignPtr :: IO (ForeignPtr TSNode))
withForeignPtr node writer
namedChildren :: Ptr TSNode -> IO [Ptr TSNode]
namedChildren node = do
count <- ts_node_p_named_child_count node
mapM (withNode . getChild) [0..count] where
getChild n out = do
ts_node_p_named_child node n out
return out
parseModuleFile :: FilePath -> IO (ParseResult HsModule)
parseModuleFile file = do
contents <- readFile file