HaRe-0.7.2.6: the Haskell Refactorer.

Safe HaskellNone

Language.Haskell.Refact.Utils.LocUtils

Synopsis

Documentation

isIgnored :: IsToken a => a -> Bool

isIn :: IsToken a => a -> Bool

endsWithNewLn :: PosToken -> BoolSource

Returns True if the token ends with '\n' ++AZ++: is this meaningful?

startsWithNewLn :: PosToken -> BoolSource

Returns True if the token starts with `\n`. ++AZ++: is this meaningful?

compressPreNewLns :: [PosToken] -> [PosToken]Source

Remove the extra preceding empty lines.

compressEndNewLns :: [PosToken] -> [PosToken]Source

Remove the following extra empty lines.

lengthOfLastLine :: [PosToken] -> IntSource

Given a token stream covering multi-lines, calculate the length of the last line AZ: should be the last token start col, plus length of token.

getToks :: (SimpPos, SimpPos) -> [PosToken] -> [PosToken]Source

get a token stream specified by the start and end position.

deleteToks :: [PosToken] -> SimpPos -> SimpPos -> [PosToken]Source

Delete a sequence of tokens specified by the start position and end position from the token stream, then adjust the remaining token stream to preserve layout

doRmWhites :: Int -> [PosToken] -> [PosToken]Source

remove at most n white space tokens from the beginning of ts

srcLocs :: Data t => t -> [SimpPos]Source

get all the source locations (use locations) in an AST phrase t according the the occurrence order of identifiers.

getSrcSpan :: Data t => t -> Maybe SrcSpanSource

Get the first SrcSpan found, in top down traversal

getAllSrcLocs :: Data t => t -> [(SimpPos, SimpPos)]Source

Get all the source locations in a given syntax fragment

extendForwards :: [PosToken] -> (SimpPos, SimpPos) -> (PosToken -> Bool) -> (SimpPos, SimpPos)Source

Extend the given position forwards to the end of the file while the supplied condition holds

extendBackwards :: [PosToken] -> (SimpPos, SimpPos) -> (PosToken -> Bool) -> (SimpPos, SimpPos)Source

Extend the given position backwards to the front of the file while the supplied condition holds

startEndLocIncFowComment :: Data t => [PosToken] -> t -> (SimpPos, SimpPos)Source

Get the start&end location of syntax phrase t, then extend the end location to cover the comment/white spaces or new line which starts in the same line as the end location TODO: deprecate this in favour of startEndLocIncComments

startEndLocIncComments :: Data t => [PosToken] -> t -> (SimpPos, SimpPos)Source

Get the start&end location of t in the token stream, then extend the start and end location to cover the preceding and following comments.

In this routine, 'then','else','do' and 'in' are treated as comments.

startEndLocIncComments' :: IsToken a => [a] -> (SimpPos, SimpPos) -> (SimpPos, SimpPos)

Get the start&end location of t in the token stream, then extend the start and end location to cover the preceding and following comments.

groupTokensByLine :: IsToken a => [a] -> [[a]]

getLineOffset :: [PosToken] -> SimpPos -> IntSource

Get the start of the line before the pos,

increaseSrcSpan :: IsToken a => SimpPos -> a -> a

Shift the whole token by the given offset

getGhcLoc :: SrcSpan -> (Int, Int)Source

gets the (row,col) of the start of the GHC.SrcSpan, or (-1,-1) if there is an GHC.UnhelpfulSpan

getGhcLocEnd :: SrcSpan -> (Int, Int)Source

gets the (row,col) of the end of the GHC.SrcSpan, or (-1,-1) if there is an GHC.UnhelpfulSpan

splitToks :: IsToken a => (SimpPos, SimpPos) -> [a] -> ([a], [a], [a])

Split the token stream into three parts: the tokens before the startPos, the tokens between startPos and endPos, and the tokens after endPos. Note: The startPos and endPos refer to the startPos of a token only. So a single token will have the same startPos and endPos NO^^^^

emptyList :: [t] -> BoolSource

Get around lack of instance Eq when simply testing for empty list TODO: get rid of this in favour of null built in fn

isEmpty :: IsToken a => a -> Bool

Zero-length tokens, as appear in GHC as markers

isWhere :: IsToken a => a -> Bool

isLet :: IsToken a => a -> Bool

isElse :: IsToken a => a -> Bool

isThen :: IsToken a => a -> Bool

isOf :: IsToken a => a -> Bool

isDo :: IsToken a => a -> Bool

getIndentOffset :: IsToken a => [a] -> SimpPos -> Int

Get the indent of the line before, taking into account in-line 'where', 'let', 'in' and 'do' tokens

splitOnNewLn :: IsToken a => [a] -> ([a], [a])

tokenLen :: IsToken a => a -> Int

tokenLen returns the length of the string representation of the token, not just the difference in the location, as the string may have changed without the position being updated, e.g. in a renaming

newLnToken :: IsToken a => a -> a

reSequenceToks :: [PosToken] -> [PosToken]Source

Adjust token stream to cater for changes in token length due to token renaming

mkToken :: Token -> SimpPos -> String -> GhcPosToken

Compose a new token using the given arguments.

markToken :: IsToken a => a -> a

Mark a token so that it can be use to trigger layout checking later when the toks are retrieved

isMarked :: IsToken a => a -> Bool