Add api to begin and end a span of source code
This commit is contained in:
parent
8ff35fb4af
commit
1699c9e9ba
|
@ -188,6 +188,27 @@ getNextId = do
|
||||||
pos <- getPosition
|
pos <- getPosition
|
||||||
getNextIdAt pos
|
getNextIdAt pos
|
||||||
|
|
||||||
|
data IncompleteInterval = IncompleteInterval SourcePos
|
||||||
|
|
||||||
|
startSpan = IncompleteInterval <$> getPosition
|
||||||
|
|
||||||
|
endSpan (IncompleteInterval start) = do
|
||||||
|
id <- getNextIdAt start
|
||||||
|
endPos <- getPosition
|
||||||
|
state <- getState
|
||||||
|
let setEndPos (start, _) = Just (start, Just endPos)
|
||||||
|
let newMap = Map.update setEndPos id (positionMap state)
|
||||||
|
putState $ state {
|
||||||
|
lastId = id,
|
||||||
|
positionMap = newMap
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
|
||||||
|
zeroWidthSpan = do
|
||||||
|
start <- startSpan
|
||||||
|
id <- endSpan start
|
||||||
|
return id
|
||||||
|
|
||||||
endPosOfStartId s = do
|
endPosOfStartId s = do
|
||||||
endPos <- getPosition
|
endPos <- getPosition
|
||||||
state <- getState
|
state <- getState
|
||||||
|
|
Loading…
Reference in New Issue