module Development.IDE.Spans.Type(
SpansInfo(..)
, SpanInfo(..)
, SpanSource(..)
, getNameM
) where
import GHC
import Control.DeepSeq
import OccName
import Development.IDE.GHC.Util
import Development.IDE.Spans.Common
data SpansInfo =
SpansInfo { spansExprs :: [SpanInfo]
, spansConstraints :: [SpanInfo] }
deriving Show
instance NFData SpansInfo where
rnf (SpansInfo e c) = liftRnf rnf e `seq` liftRnf rnf c
data SpanInfo =
SpanInfo {spaninfoStartLine :: {-# UNPACK #-} !Int
,spaninfoStartCol :: {-# UNPACK #-} !Int
,spaninfoEndLine :: {-# UNPACK #-} !Int
,spaninfoEndCol :: {-# UNPACK #-} !Int
,spaninfoType :: !(Maybe Type)
,spaninfoSource :: !SpanSource
,spaninfoDocs :: !SpanDoc
}
instance Show SpanInfo where
show (SpanInfo sl sc el ec t n docs) =
unwords ["(SpanInfo", show sl, show sc, show el, show ec
, show $ maybe "NoType" prettyPrint t, "(" <> show n <> "))"
, "docs(" <> show docs <> ")"]
instance NFData SpanInfo where
rnf = rwhnf
data SpanSource = Named Name
| SpanS SrcSpan
| Lit String
| NoSource
deriving (Eq)
instance Show SpanSource where
show = \case
Named n -> "Named " ++ occNameString (occName n)
SpanS sp -> "Span " ++ show sp
Lit lit -> "Lit " ++ lit
NoSource -> "NoSource"
getNameM :: SpanSource -> Maybe Name
getNameM = \case
Named name -> Just name
_ -> Nothing