on 2a7aaa9 help sign in
64 lines 2.4 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 , InterfaceDirectory(..)
11 , defaultIdeOptions
12 ) where
14import Development.Shake
15import GHC hiding (parseModule, typecheckModule)
16import GhcPlugins as GHC hiding (fst3, (<>))
19-- | If `Nothing` we do not write .hi files.
20newtype InterfaceDirectory = InterfaceDirectory (Maybe FilePath)
22data IdeOptions = IdeOptions
23 { optPreprocessor :: GHC.ParsedSource -> ([(GHC.SrcSpan, String)], GHC.ParsedSource)
24 , optGhcSession :: Action HscEnv
25 -- ^ Setup a GHC session using a given package state. If a `ParsedModule` is supplied,
26 -- the import path should be setup for that module.
27 , optPkgLocationOpts :: IdePkgLocationOptions
28 , optIfaceDir :: InterfaceDirectory
29 , optExtensions :: [String]
31 , optThreads :: Int
32 , optShakeProfiling :: Maybe FilePath
33 , optLanguageSyntax :: String -- ^ the ```language to use
34 , optNewColonConvention :: Bool -- ^ whether to use new colon convention
35 }
37defaultIdeOptions :: Action HscEnv -> IdeOptions
38defaultIdeOptions session = IdeOptions
39 {optPreprocessor = (,) []
40 ,optIfaceDir = InterfaceDirectory Nothing
41 ,optGhcSession = session
42 ,optExtensions = ["hs"]
43 ,optPkgLocationOpts = defaultIdePkgLocationOptions
44 ,optThreads = 0
45 ,optShakeProfiling = Nothing
46 ,optLanguageSyntax = "haskell"
47 ,optNewColonConvention = False
48 }
51-- | The set of options used to locate files belonging to external packages.
52data IdePkgLocationOptions = IdePkgLocationOptions
53 { optLocateHieFile :: PackageConfig -> Module -> IO (Maybe FilePath)
54 -- ^ Locate the HIE file for the given module. The PackageConfig can be
55 -- used to lookup settings like importDirs.
56 , optLocateSrcFile :: PackageConfig -> Module -> IO (Maybe FilePath)
57 -- ^ Locate the source file for the given module. The PackageConfig can be
58 -- used to lookup settings like importDirs. For DAML, we place them in the package DB.
59 -- For cabal this could point somewhere in ~/.cabal/packages.
60 }
62defaultIdePkgLocationOptions :: IdePkgLocationOptions
63defaultIdePkgLocationOptions = IdePkgLocationOptions f f
64 where f _ _ = return Nothing