mirror of
https://github.com/github/semantic.git
synced 2024-12-15 01:51:39 +03:00
Use insertScope here too.
This commit is contained in:
parent
b47e28f278
commit
b3ef26f301
@ -126,7 +126,7 @@ lookupScope scope = Map.lookup scope . unScopeGraph
|
|||||||
-- Declare a declaration with a span and an associated scope in the scope graph.
|
-- Declare a declaration with a span and an associated scope in the scope graph.
|
||||||
-- TODO: Return the whole value in Maybe or Either.
|
-- TODO: Return the whole value in Maybe or Either.
|
||||||
declare :: Ord scope => Declaration -> Span -> Maybe scope -> scope -> ScopeGraph scope -> (ScopeGraph scope, Maybe Position)
|
declare :: Ord scope => Declaration -> Span -> Maybe scope -> scope -> ScopeGraph scope -> (ScopeGraph scope, Maybe Position)
|
||||||
declare declaration ddata assocScope currentScope g@(ScopeGraph graph) = fromMaybe (g, Nothing) $ do
|
declare declaration ddata assocScope currentScope g = fromMaybe (g, Nothing) $ do
|
||||||
scope <- lookupScope currentScope g
|
scope <- lookupScope currentScope g
|
||||||
|
|
||||||
dataSeq <- ddataOfScope currentScope g
|
dataSeq <- ddataOfScope currentScope g
|
||||||
@ -134,7 +134,7 @@ declare declaration ddata assocScope currentScope g@(ScopeGraph graph) = fromMay
|
|||||||
Just index -> pure (g, Just (Position index))
|
Just index -> pure (g, Just (Position index))
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
let newScope = scope { declarations = declarations scope Seq.|> (declaration, (ddata, assocScope)) }
|
let newScope = scope { declarations = declarations scope Seq.|> (declaration, (ddata, assocScope)) }
|
||||||
pure (ScopeGraph (Map.insert currentScope newScope graph), Just (Position (length (declarations newScope))))
|
pure (insertScope currentScope newScope g, Just (Position (length (declarations newScope))))
|
||||||
|
|
||||||
-- | Add a reference to a declaration in the scope graph.
|
-- | Add a reference to a declaration in the scope graph.
|
||||||
-- Returns the original scope graph if the declaration could not be found.
|
-- Returns the original scope graph if the declaration could not be found.
|
||||||
|
Loading…
Reference in New Issue
Block a user