@@ -20,7 +20,6 @@ module Ide.Plugin.Hlint
20
20
import Refact.Apply
21
21
import Control.Arrow ((&&&) )
22
22
import Control.DeepSeq
23
- import Control.Exception
24
23
import Control.Lens ((^.) )
25
24
import Control.Monad
26
25
import Control.Monad.IO.Class
@@ -38,16 +37,19 @@ import Development.IDE.Core.Rules (defineNoFile)
38
37
import Development.IDE.Core.Shake (getDiagnostics )
39
38
40
39
#ifdef HLINT_ON_GHC_LIB
40
+ import Control.Exception
41
41
import Data.List (nub )
42
- import "ghc-lib" GHC hiding (DynFlags (.. ))
42
+ import "ghc-lib" GHC hiding (DynFlags (.. ), ms_hspp_opts )
43
43
import "ghc-lib-parser" GHC.LanguageExtensions (Extension )
44
44
import "ghc" GHC as RealGHC (DynFlags (.. ))
45
- import "ghc" HscTypes as RealGHC.HscTypes (hsc_dflags )
45
+ import "ghc" HscTypes as RealGHC.HscTypes (hsc_dflags , ms_hspp_opts )
46
46
import qualified "ghc" EnumSet as EnumSet
47
47
import Language.Haskell.GhclibParserEx.GHC.Driver.Session as GhclibParserEx (readExtension )
48
+ import System.FilePath (takeFileName )
49
+ import System.IO (hPutStr , noNewlineTranslation , hSetNewlineMode , utf8 , hSetEncoding , IOMode (WriteMode ), withFile , hClose )
50
+ import System.IO.Temp
48
51
#else
49
52
import Development.IDE.GHC.Compat hiding (DynFlags (.. ))
50
- import HscTypes (hsc_dflags )
51
53
import Language.Haskell.GHC.ExactPrint.Parsers (postParseTransform )
52
54
import Language.Haskell.GHC.ExactPrint.Delta (normalLayout )
53
55
#endif
@@ -58,12 +60,12 @@ import Ide.Plugin.Config
58
60
import Ide.PluginUtils
59
61
import Language.Haskell.HLint as Hlint
60
62
import Language.Haskell.LSP.Core
63
+ ( LspFuncs (withIndefiniteProgress ),
64
+ ProgressCancellable (Cancellable ) )
61
65
import Language.Haskell.LSP.Types
62
66
import qualified Language.Haskell.LSP.Types as LSP
63
67
import qualified Language.Haskell.LSP.Types.Lens as LSP
64
- import System.FilePath (takeFileName )
65
- import System.IO (hPutStr , noNewlineTranslation , hSetNewlineMode , utf8 , hSetEncoding , IOMode (WriteMode ), withFile , hClose )
66
- import System.IO.Temp
68
+
67
69
import Text.Regex.TDFA.Text ()
68
70
import GHC.Generics (Generic )
69
71
@@ -208,12 +210,15 @@ getIdeas nfp = do
208
210
209
211
getExtensions :: ParseFlags -> NormalizedFilePath -> Action [Extension ]
210
212
getExtensions pflags nfp = do
211
- hsc <- hscEnv <$> use_ GhcSession nfp
212
- let dflags = hsc_dflags hsc
213
+ dflags <- getFlags
213
214
let hscExts = EnumSet. toList (extensionFlags dflags)
214
215
let hscExts' = mapMaybe (GhclibParserEx. readExtension . show ) hscExts
215
216
let hlintExts = nub $ enabledExtensions pflags ++ hscExts'
216
217
return hlintExts
218
+ where getFlags :: Action DynFlags
219
+ getFlags = do
220
+ (modsum, _) <- use_ GetModSummary nfp
221
+ return $ ms_hspp_opts modsum
217
222
#endif
218
223
219
224
-- ---------------------------------------------------------------------
@@ -395,8 +400,8 @@ applyHint ide nfp mhint =
395
400
Just pm -> do
396
401
let anns = pm_annotations pm
397
402
let modu = pm_parsed_source pm
398
- hsc <- liftIO $ runAction' $ hscEnv <$> use_ GhcSession nfp
399
- let dflags = hsc_dflags hsc
403
+ (modsum, _) <- liftIO $ runAction' $ use_ GetModSummary nfp
404
+ let dflags = ms_hspp_opts modsum
400
405
(anns', modu') <-
401
406
ExceptT $ return $ postParseTransform (Right (anns, [] , dflags, modu)) normalLayout
402
407
liftIO (Right <$> applyRefactorings' Nothing commands anns' modu')
0 commit comments