82bb0090c0
This turned out to be quite involved but save for this huge commit it's actually quite awesome and squashes quite a few bugs and nasty problems (hopefully). Most importantly we now have native cabal component support without the user having to do anything to get it! To do this we traverse imports starting from each component's entrypoints (library modules or Main source file for executables) and use this information to find which component's options each module will build with. Under the assumption that these modules have to build with every component they're used in we can now just pick one. Quite a few internal assumptions have been invalidated by this change. Most importantly the runGhcModT* family of cuntions now change the current working directory to `cradleRootDir`.
26 lines
829 B
Haskell
26 lines
829 B
Haskell
module Language.Haskell.GhcMod.Doc where
|
|
|
|
import GHC
|
|
import Language.Haskell.GhcMod.Gap (withStyle, showDocWith)
|
|
import Outputable
|
|
import Pretty (Mode(..))
|
|
|
|
showPage :: DynFlags -> PprStyle -> SDoc -> String
|
|
showPage dflag style = showDocWith dflag PageMode . withStyle dflag style
|
|
|
|
showOneLine :: DynFlags -> PprStyle -> SDoc -> String
|
|
showOneLine dflag style = showDocWith dflag OneLineMode . withStyle dflag style
|
|
|
|
showForUser :: DynFlags -> PrintUnqualified -> SDoc -> String
|
|
showForUser dflags unqual sdoc =
|
|
showDocWith dflags PageMode $
|
|
runSDoc sdoc $ initSDocContext dflags $ mkUserStyle unqual AllTheWay
|
|
|
|
getStyle :: GhcMonad m => m PprStyle
|
|
getStyle = do
|
|
unqual <- getPrintUnqual
|
|
return $ mkUserStyle unqual AllTheWay
|
|
|
|
styleUnqualified :: PprStyle
|
|
styleUnqualified = mkUserStyle neverQualify AllTheWay
|