mirror of
https://github.com/github/semantic.git
synced 2024-12-01 00:33:59 +03:00
Generalize advanceState over the syntax functor.
This commit is contained in:
parent
f7c1992db1
commit
9d4fb0920b
@ -235,7 +235,7 @@ dropAnonymous :: Symbol grammar => (forall x. CofreeF f a x -> Maybe grammar) ->
|
||||
dropAnonymous toSymbol state = state { stateNodes = dropWhile ((`notElem` [Just Regular, Nothing]) . fmap symbolType . toSymbol . runCofree) (stateNodes state) }
|
||||
|
||||
-- | Advances the state past the current (head) node (if any), dropping it off stateNodes & its corresponding bytes off of stateSource, and updating stateOffset & statePos to its end. Exhausted 'AssignmentState's (those without any remaining nodes) are returned unchanged.
|
||||
advanceState :: AssignmentState (Cofree [] (Record (node ': Location))) -> AssignmentState (Cofree [] (Record (node ': Location)))
|
||||
advanceState :: AssignmentState (Cofree f (Record (node ': Location))) -> AssignmentState (Cofree f (Record (node ': Location)))
|
||||
advanceState state@AssignmentState{..}
|
||||
| node : rest <- stateNodes, (_ :. range :. span :. _) :< _ <- runCofree node = AssignmentState (Info.end range) (Info.spanEnd span) (Source.drop (Info.end range - stateOffset) stateSource) rest
|
||||
| otherwise = state
|
||||
|
Loading…
Reference in New Issue
Block a user