on eddf78a help sign in
60 lines 2.2 kB history raw
1-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
4{-# LANGUAGE RankNTypes #-}
6-- | Options
7module Development.IDE.Types.Options
8 ( IdeOptions(..)
9 , IdePkgLocationOptions(..)
10 , defaultIdeOptions
11 ) where
13import Development.Shake
14import GHC hiding (parseModule, typecheckModule)
15import GhcPlugins as GHC hiding (fst3, (<>))
18data IdeOptions = IdeOptions
19 { optPreprocessor :: GHC.ParsedSource -> ([(GHC.SrcSpan, String)], GHC.ParsedSource)
20 , optGhcSession :: Action HscEnv
21 -- ^ Setup a GHC session using a given package state. If a `ParsedModule` is supplied,
22 -- the import path should be setup for that module.
23 , optPkgLocationOpts :: IdePkgLocationOptions
24 , optWriteIface :: Bool
25 , optExtensions :: [String]
27 , optThreads :: Int
28 , optShakeProfiling :: Maybe FilePath
29 , optLanguageSyntax :: String -- ^ the ```language to use
30 , optNewColonConvention :: Bool -- ^ whether to use new colon convention
31 }
33defaultIdeOptions :: Action HscEnv -> IdeOptions
34defaultIdeOptions session = IdeOptions
35 {optPreprocessor = (,) []
36 ,optWriteIface = False
37 ,optGhcSession = session
38 ,optExtensions = ["hs"]
39 ,optPkgLocationOpts = defaultIdePkgLocationOptions
40 ,optThreads = 0
41 ,optShakeProfiling = Nothing
42 ,optLanguageSyntax = "haskell"
43 ,optNewColonConvention = False
44 }
47-- | The set of options used to locate files belonging to external packages.
48data IdePkgLocationOptions = IdePkgLocationOptions
49 { optLocateHieFile :: PackageConfig -> Module -> IO (Maybe FilePath)
50 -- ^ Locate the HIE file for the given module. The PackageConfig can be
51 -- used to lookup settings like importDirs.
52 , optLocateSrcFile :: PackageConfig -> Module -> IO (Maybe FilePath)
53 -- ^ Locate the source file for the given module. The PackageConfig can be
54 -- used to lookup settings like importDirs. For DAML, we place them in the package DB.
55 -- For cabal this could point somewhere in ~/.cabal/packages.
56 }
58defaultIdePkgLocationOptions :: IdePkgLocationOptions
59defaultIdePkgLocationOptions = IdePkgLocationOptions f f
60 where f _ _ = return Nothing