on master help sign in
Clean up the logging in hie-core (#1839)

* Move prettyPosition over to a more sensible place * Avoid some pretty printing * Remove duplicate methods and switch to having a function to get the logger handle * Remove unncessary bits of the logger * Remove reportSeriousErrorDie - was unused * Rename the Logger methods to Logger rather than Handle * Delete the unique supply * Decrease the use of getServiceEnv * Move getIdeOptions inside Service * Add getFilesOfInterest rule * Hide the existence of Env * Inline some redundant forwarding methods * Add a FIXME for a dodgy function * Delete some redundant imports * Rename Map to HMap, since I need to use Data.Map too * Make the Shake-specific Diagnostics functions into that module * Delete errorDiag which was unused * Inline the diagnostic function, since it had one user * Add ofInterest rule as a separate module * Sort the exposed modules * Fix up the demo * Make sure you add the OfInterestVar global * HLint * Get rid of some of interest stuff in other places * Remove the OfInterest stuff from Service

commitf746db9dc492381990f03b7567e4df652118fc60 authorNeil Mitchell <35463327+neil-da@users.noreply.github.com> dateMon 24 Jun 2019, 12:46 (7 years ago) parentbf2cbd2
15 files changed+247−272
hie-core.cabal+17−16 src/Development/IDE/Core/OfInterest.hs+81 src/Development/IDE/Core/RuleTypes.hs−10 src/Development/IDE/Core/Rules.hs+6−20 src/Development/IDE/Core/Service.hs+14−55 src/Development/IDE/Core/Shake.hs+74−42 src/Development/IDE/LSP/Definition.hs+5−7 src/Development/IDE/LSP/Hover.hs+4−6 src/Development/IDE/LSP/LanguageServer.hs+19−19 src/Development/IDE/LSP/Protocol.hs+1−5 src/Development/IDE/LSP/Server.hs+3−3 src/Development/IDE/Types/Diagnostics.hs+8−76 src/Development/IDE/Types/Location.hs+5−2 src/Development/IDE/Types/Logger.hs+8−8 test/Demo.hs+2−3
hie-core.cabal+17−16
@@ -76,33 +76,34 @@ library
7676 hs-source-dirs:
7777 src
7878 exposed-modules:
79− Development.IDE.Types.Logger
80− Development.IDE.GHC.Util
81− Development.IDE.Spans.AtPoint
8279 Development.IDE.Core.Compile
80+ Development.IDE.Core.FileStore
81+ Development.IDE.Core.OfInterest
82+ Development.IDE.Core.Rules
83+ Development.IDE.Core.RuleTypes
84+ Development.IDE.Core.Service
85+ Development.IDE.Core.Shake
86+ Development.IDE.GHC.Compat
8387 Development.IDE.GHC.CPP
88+ Development.IDE.GHC.Error
8489 Development.IDE.GHC.Orphans
90+ Development.IDE.GHC.Util
91+ Development.IDE.GHC.Warnings
8592 Development.IDE.Import.DependencyInformation
86− Development.IDE.Spans.Documentation
8793 Development.IDE.Import.FindImports
88− Development.IDE.GHC.Error
89− Development.IDE.Spans.Calculate
90− Development.IDE.GHC.Warnings
91− Development.IDE.Core.FileStore
92− Development.IDE.Core.Rules
93− Development.IDE.GHC.Compat
94− Development.IDE.LSP.LanguageServer
9594 Development.IDE.LSP.Definition
9695 Development.IDE.LSP.Hover
96+ Development.IDE.LSP.LanguageServer
9797 Development.IDE.LSP.Protocol
9898 Development.IDE.LSP.Server
99− Development.IDE.Types.Options
100− Development.IDE.Core.RuleTypes
101− Development.IDE.Core.Service
102− Development.IDE.Core.Shake
99+ Development.IDE.Spans.AtPoint
100+ Development.IDE.Spans.Calculate
101+ Development.IDE.Spans.Documentation
102+ Development.IDE.Spans.Type
103103 Development.IDE.Types.Diagnostics
104104 Development.IDE.Types.Location
105− Development.IDE.Spans.Type
105+ Development.IDE.Types.Logger
106+ Development.IDE.Types.Options
106107
107108executable hie-core
108109 default-language: Haskell2010
src/Development/IDE/Core/OfInterest.hsnew file+81
@@ -0,0 +1,81 @@
1+-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+-- SPDX-License-Identifier: Apache-2.0
3+
4+
5+{-# LANGUAGE TypeFamilies #-}
6+{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE FlexibleInstances #-}
8+
9+-- | A Shake implementation of the compiler service, built
10+-- using the "Shaker" abstraction layer for in-memory use.
11+--
12+module Development.IDE.Core.OfInterest(
13+ ofInterestRules,
14+ getFilesOfInterest, setFilesOfInterest, modifyFilesOfInterest,
15+ ) where
16+
17+import Control.Concurrent.Extra
18+import Control.Monad.Except
19+import Data.Hashable
20+import Control.DeepSeq
21+import GHC.Generics
22+import Data.Typeable
23+import qualified Data.ByteString.UTF8 as BS
24+import Control.Exception
25+import Development.IDE.Types.Location
26+import Development.IDE.Types.Logger
27+import Data.Set (Set)
28+import qualified Data.Set as Set
29+import qualified Data.Text as T
30+import Data.Tuple.Extra
31+import Development.Shake hiding (Diagnostic, Env, newCache)
32+
33+import Development.IDE.Core.Shake
34+
35+
36+
37+newtype OfInterestVar = OfInterestVar (Var (Set NormalizedFilePath))
38+instance IsIdeGlobal OfInterestVar
39+
40+
41+type instance RuleResult GetFilesOfInterest = Set NormalizedFilePath
42+
43+
44+data GetFilesOfInterest = GetFilesOfInterest
45+ deriving (Eq, Show, Typeable, Generic)
46+instance Hashable GetFilesOfInterest
47+instance NFData GetFilesOfInterest
48+
49+
50+ofInterestRules :: Rules ()
51+ofInterestRules = do
52+ addIdeGlobal . OfInterestVar =<< liftIO (newVar Set.empty)
53+ defineEarlyCutoff $ \GetFilesOfInterest _file -> assert (null $ fromNormalizedFilePath _file) $ do
54+ alwaysRerun
55+ filesOfInterest <- getFilesOfInterestUntracked
56+ pure (Just $ BS.fromString $ show filesOfInterest, ([], Just filesOfInterest))
57+
58+
59+getFilesOfInterest :: Action (Set NormalizedFilePath)
60+getFilesOfInterest = use_ GetFilesOfInterest ""
61+
62+
63+
64+------------------------------------------------------------
65+-- Exposed API
66+
67+-- | Set the files-of-interest which will be built and kept-up-to-date.
68+setFilesOfInterest :: IdeState -> Set NormalizedFilePath -> IO ()
69+setFilesOfInterest state files = modifyFilesOfInterest state (const files)
70+
71+getFilesOfInterestUntracked :: Action (Set NormalizedFilePath)
72+getFilesOfInterestUntracked = do
73+ OfInterestVar var <- getIdeGlobalAction
74+ liftIO $ readVar var
75+
76+modifyFilesOfInterest :: IdeState -> (Set NormalizedFilePath -> Set NormalizedFilePath) -> IO ()
77+modifyFilesOfInterest state f = do
78+ OfInterestVar var <- getIdeGlobalState state
79+ files <- modifyVar var $ pure . dupe . f
80+ logDebug (ideLogger state) $ "Set files of interest to: " <> T.pack (show $ Set.toList files)
81+ void $ shakeRun state [] (const $ pure ())
src/Development/IDE/Core/RuleTypes.hs−10
@@ -17,8 +17,6 @@ import Development.IDE.Import.FindImports (Import(..))
1717import Development.IDE.Import.DependencyInformation
1818import Data.Hashable
1919import Data.Typeable
20−import Development.IDE.Types.Location
21−import Data.Set(Set)
2220import Development.Shake hiding (Env, newCache)
2321import GHC.Generics (Generic)
2422
@@ -69,14 +67,6 @@ type instance RuleResult ReportImportCycles = ()
6967type instance RuleResult GetHieFile = HieFile
7068
7169
72−type instance RuleResult GetFilesOfInterest = Set NormalizedFilePath
73−
74−
75−data GetFilesOfInterest = GetFilesOfInterest
76− deriving (Eq, Show, Typeable, Generic)
77−instance Hashable GetFilesOfInterest
78−instance NFData GetFilesOfInterest
79−
8070data GetParsedModule = GetParsedModule
8171 deriving (Eq, Show, Typeable, Generic)
8272instance Hashable GetParsedModule
src/Development/IDE/Core/Rules.hs+6−20
@@ -32,9 +32,6 @@ import Development.IDE.Import.FindImports
3232import Development.IDE.Core.FileStore
3333import Development.IDE.Types.Diagnostics as Base
3434import Development.IDE.Types.Location
35−import qualified Data.ByteString.UTF8 as BS
36−import Control.Exception
37−import Control.Concurrent.Extra
3835import Data.Bifunctor
3936import Data.Either.Extra
4037import Data.Maybe
@@ -78,14 +75,6 @@ defineNoFile f = define $ \k file -> do
7875------------------------------------------------------------
7976-- Exposed API
8077
81−getFilesOfInterestRule :: Rules ()
82−getFilesOfInterestRule = do
83− defineEarlyCutoff $ \GetFilesOfInterest _file -> assert (null $ fromNormalizedFilePath _file) $ do
84− alwaysRerun
85− Env{..} <- getServiceEnv
86− filesOfInterest <- liftIO $ readVar envOfInterestVar
87− pure (Just $ BS.fromString $ show filesOfInterest, ([], Just filesOfInterest))
88−
8978
9079-- | Generate the GHC Core for the supplied file and its dependencies.
9180getGhcCore :: NormalizedFilePath -> Action (Maybe [CoreModule])
@@ -104,7 +93,7 @@ getDependencies file = fmap transitiveModuleDeps <$> use GetDependencies file
10493-- | Try to get hover text for the name under point.
10594getAtPoint :: NormalizedFilePath -> Position -> Action (Maybe (Maybe Range, [T.Text]))
10695getAtPoint file pos = fmap join $ runMaybeT $ do
107− opts <- lift getOpts
96+ opts <- lift getIdeOptions
10897 files <- transitiveModuleDeps <$> useE GetDependencies file
10998 tms <- usesE TypeCheck (file : files)
11099 spans <- useE GetSpanInfo file
@@ -115,7 +104,7 @@ getDefinition :: NormalizedFilePath -> Position -> Action (Maybe Location)
115104getDefinition file pos = fmap join $ runMaybeT $ do
116105 spans <- useE GetSpanInfo file
117106 pkgState <- useE GhcSession ""
118− opts <- lift getOpts
107+ opts <- lift getIdeOptions
119108 let getHieFile x = use (GetHieFile x) ""
120109 lift $ AtPoint.gotoDefinition getHieFile opts pkgState spans pos
121110
@@ -123,8 +112,6 @@ getDefinition file pos = fmap join $ runMaybeT $ do
123112getParsedModule :: NormalizedFilePath -> Action (Maybe ParsedModule)
124113getParsedModule file = use GetParsedModule file
125114
126−getOpts :: Action Compile.IdeOptions
127−getOpts = envOptions <$> getServiceEnv
128115
129116------------------------------------------------------------
130117-- Rules
@@ -144,7 +131,7 @@ getParsedModuleRule =
144131 define $ \GetParsedModule file -> do
145132 (_, contents) <- getFileContents file
146133 packageState <- use_ GhcSession ""
147− opt <- getOpts
134+ opt <- getIdeOptions
148135 liftIO $ Compile.parseModule opt packageState (fromNormalizedFilePath file) contents
149136
150137getLocatedImportsRule :: Rules ()
@@ -155,7 +142,7 @@ getLocatedImportsRule =
155142 let imports = ms_textual_imps ms
156143 packageState <- use_ GhcSession ""
157144 dflags <- liftIO $ Compile.getGhcDynFlags pm packageState
158− opt <- getOpts
145+ opt <- getIdeOptions
159146 xs <- forM imports $ \(mbPkgName, modName) ->
160147 (modName, ) <$> locateModule dflags (Compile.optExtensions opt) getFileExists modName mbPkgName
161148 return (concat $ lefts $ map snd xs, Just $ map (second eitherToMaybe) xs)
@@ -255,7 +242,7 @@ typeCheckRule =
255242 tms <- uses_ TypeCheck (transitiveModuleDeps deps)
256243 setPriority PriorityTypeCheck
257244 packageState <- use_ GhcSession ""
258− opt <- getOpts
245+ opt <- getIdeOptions
259246 liftIO $ Compile.typecheckModule opt packageState tms pm
260247
261248
@@ -272,7 +259,7 @@ generateCoreRule =
272259loadGhcSession :: Rules ()
273260loadGhcSession =
274261 defineNoFile $ \GhcSession -> do
275− opts <- envOptions <$> getServiceEnv
262+ opts <- getIdeOptions
276263 Compile.optGhcSession opts
277264
278265
@@ -296,7 +283,6 @@ mainRule = do
296283 generateCoreRule
297284 loadGhcSession
298285 getHieFileRule
299− getFilesOfInterestRule
300286
301287------------------------------------------------------------
302288
src/Development/IDE/Core/Service.hs+14−55
@@ -9,64 +9,31 @@
99-- using the "Shaker" abstraction layer for in-memory use.
1010--
1111module Development.IDE.Core.Service(
12− Env(..),
13− getServiceEnv,
12+ getIdeOptions,
1413 IdeState, initialise, shutdown,
1514 runAction, runActions,
1615 runActionSync, runActionsSync,
17− setFilesOfInterest, modifyFilesOfInterest,
16+ getFilesOfInterest, setFilesOfInterest, modifyFilesOfInterest,
1817 writeProfile,
1918 getDiagnostics, unsafeClearDiagnostics,
20− logDebug, logSeriousError
19+ ideLogger
2120 ) where
2221
2322import Control.Concurrent.Extra
2423import Control.Monad.Except
2524import Development.IDE.Types.Options (IdeOptions(..))
2625import Development.IDE.Core.FileStore
27−import qualified Development.IDE.Types.Logger as Logger
28−import Data.Set (Set)
29−import qualified Data.Set as Set
30−import qualified Data.Text as T
31−import Data.Tuple.Extra
32−import Development.IDE.Types.Diagnostics(FileDiagnostic)
33−import Development.IDE.Types.Location (NormalizedFilePath)
26+import Development.IDE.Core.OfInterest
27+import Development.IDE.Types.Logger
3428import Development.Shake hiding (Diagnostic, Env, newCache)
3529import qualified Language.Haskell.LSP.Messages as LSP
3630
37−import UniqSupply
38−
3931import Development.IDE.Core.Shake
4032
4133
42−-- | Environment threaded through the Shake actions.
43−data Env = Env
44− { envOptions :: IdeOptions
45− -- ^ Compiler options.
46− , envOfInterestVar :: Var (Set NormalizedFilePath)
47− -- ^ The files of interest.
48− , envUniqSupplyVar :: Var UniqSupply
49− -- ^ The unique supply of names used by the compiler.
50− }
51−instance IsIdeGlobal Env
52−
53−
54−mkEnv :: IdeOptions -> IO Env
55−mkEnv options = do
56− ofInterestVar <- newVar Set.empty
57− uniqSupplyVar <- mkSplitUniqSupply 'a' >>= newVar
58− return Env
59− { envOptions = options
60− , envOfInterestVar = ofInterestVar
61− , envUniqSupplyVar = uniqSupplyVar
62− }
63−
64−getDiagnostics :: IdeState -> IO [FileDiagnostic]
65−getDiagnostics = getAllDiagnostics
66−
67−unsafeClearDiagnostics :: IdeState -> IO ()
68−unsafeClearDiagnostics = unsafeClearAllDiagnostics
6934
35+newtype GlobalIdeOptions = GlobalIdeOptions IdeOptions
36+instance IsIdeGlobal GlobalIdeOptions
7037
7138------------------------------------------------------------
7239-- Exposed API
@@ -74,7 +41,7 @@ unsafeClearDiagnostics = unsafeClearAllDiagnostics
7441-- | Initialise the Compiler Service.
7542initialise :: Rules ()
7643 -> (LSP.FromServerMessage -> IO ())
77− -> Logger.Handle
44+ -> Logger
7845 -> IdeOptions
7946 -> VFSHandle
8047 -> IO IdeState
@@ -86,8 +53,9 @@ initialise mainRule toDiags logger options vfs =
8653 shakeOptions { shakeThreads = optThreads options
8754 , shakeFiles = "/dev/null"
8855 }) $ do
89− addIdeGlobal =<< liftIO (mkEnv options)
56+ addIdeGlobal $ GlobalIdeOptions options
9057 fileStoreRules vfs
58+ ofInterestRules
9159 mainRule
9260
9361writeProfile :: IdeState -> FilePath -> IO ()
@@ -128,16 +96,7 @@ runActionSync s a = head <$> runActionsSync s [a]
12896runActionsSync :: IdeState -> [Action a] -> IO [a]
12997runActionsSync s acts = join $ shakeRun s acts (const $ pure ())
13098
131−-- | Set the files-of-interest which will be built and kept-up-to-date.
132−setFilesOfInterest :: IdeState -> Set NormalizedFilePath -> IO ()
133−setFilesOfInterest state files = modifyFilesOfInterest state (const files)
134−
135−modifyFilesOfInterest :: IdeState -> (Set NormalizedFilePath -> Set NormalizedFilePath) -> IO ()
136−modifyFilesOfInterest state f = do
137− Env{..} <- getIdeGlobalState state
138− files <- modifyVar envOfInterestVar $ pure . dupe . f
139− logDebug state $ "Set files of interest to: " <> T.pack (show $ Set.toList files)
140− void $ shakeRun state [] (const $ pure ())
141−
142−getServiceEnv :: Action Env
143−getServiceEnv = getIdeGlobalAction
99+getIdeOptions :: Action IdeOptions
100+getIdeOptions = do
101+ GlobalIdeOptions x <- getIdeGlobalAction
102+ return x
src/Development/IDE/Core/Shake.hs+74−42
@@ -31,14 +31,13 @@ module Development.IDE.Core.Shake(
3131 use, uses,
3232 use_, uses_,
3333 define, defineEarlyCutoff,
34− getAllDiagnostics, unsafeClearAllDiagnostics,
35− reportSeriousError, reportSeriousErrorDie,
34+ getDiagnostics, unsafeClearDiagnostics,
35+ reportSeriousError,
3636 IsIdeGlobal, addIdeGlobal, getIdeGlobalState, getIdeGlobalAction,
3737 garbageCollect,
3838 setPriority,
3939 sendEvent,
40− Development.IDE.Core.Shake.logDebug,
41− Development.IDE.Core.Shake.logSeriousError,
40+ ideLogger,
4241 FileVersion(..),
4342 vfsVersion
4443 ) where
@@ -47,16 +46,18 @@ import Development.Shake
4746import Development.Shake.Database
4847import Development.Shake.Classes
4948import Development.Shake.Rule
50−import qualified Data.HashMap.Strict as Map
49+import qualified Data.HashMap.Strict as HMap
50+import qualified Data.Map as Map
5151import qualified Data.ByteString.Char8 as BS
5252import Data.Dynamic
5353import Data.Maybe
5454import Data.Either.Extra
5555import Data.List.Extra
5656import qualified Data.Text as T
57−import Development.IDE.Types.Logger as Logger
58−import Development.IDE.Types.Diagnostics hiding (getAllDiagnostics)
59−import qualified Development.IDE.Types.Diagnostics as D
57+import Development.IDE.Types.Logger
58+import Language.Haskell.LSP.Diagnostics
59+import qualified Data.SortedList as SL
60+import Development.IDE.Types.Diagnostics
6061import Development.IDE.Types.Location
6162import Control.Concurrent.Extra
6263import Control.Exception
@@ -78,8 +79,8 @@ import Numeric.Extra
7879-- information we stash inside the shakeExtra field
7980data ShakeExtras = ShakeExtras
8081 {eventer :: LSP.FromServerMessage -> IO ()
81− ,logger :: Logger.Handle
82− ,globals :: Var (Map.HashMap TypeRep Dynamic)
82+ ,logger :: Logger
83+ ,globals :: Var (HMap.HashMap TypeRep Dynamic)
8384 ,state :: Var Values
8485 ,diagnostics :: Var DiagnosticStore
8586 }
@@ -101,14 +102,14 @@ class Typeable a => IsIdeGlobal a where
101102addIdeGlobal :: IsIdeGlobal a => a -> Rules ()
102103addIdeGlobal x@(typeOf -> ty) = do
103104 ShakeExtras{globals} <- getShakeExtrasRules
104− liftIO $ modifyVar_ globals $ \mp -> case Map.lookup ty mp of
105+ liftIO $ modifyVar_ globals $ \mp -> case HMap.lookup ty mp of
105106 Just _ -> error $ "Can't addIdeGlobal twice on the same type, got " ++ show ty
106− Nothing -> return $! Map.insert ty (toDyn x) mp
107+ Nothing -> return $! HMap.insert ty (toDyn x) mp
107108
108109
109110getIdeGlobalExtras :: forall a . IsIdeGlobal a => ShakeExtras -> IO a
110111getIdeGlobalExtras ShakeExtras{globals} = do
111− Just x <- Map.lookup (typeRep (Proxy :: Proxy a)) <$> readVar globals
112+ Just x <- HMap.lookup (typeRep (Proxy :: Proxy a)) <$> readVar globals
112113 return $ fromDyn x $ error "Serious error, corrupt globals"
113114
114115getIdeGlobalAction :: forall a . IsIdeGlobal a => Action a
@@ -119,7 +120,7 @@ getIdeGlobalState = getIdeGlobalExtras . shakeExtras
119120
120121
121122-- | The state of the all values - nested so you can easily find all errors at a given file.
122−type Values = Map.HashMap (NormalizedFilePath, Key) (Maybe Dynamic)
123+type Values = HMap.HashMap (NormalizedFilePath, Key) (Maybe Dynamic)
123124
124125-- | Key type
125126data Key = forall k . (Typeable k, Hashable k, Eq k, Show k) => Key k
@@ -168,7 +169,6 @@ data IdeState = IdeState
168169 ,shakeExtras :: ShakeExtras
169170 }
170171
171−
172172profileDir :: Maybe FilePath
173173profileDir = Nothing -- set to Just the directory you want profile reports to appear in
174174
@@ -199,7 +199,7 @@ setValues :: IdeRule k v
199199 -> Maybe v
200200 -> IO ()
201201setValues state key file val = modifyVar_ state $
202− pure . Map.insert (file, Key key) (fmap toDyn val)
202+ pure . HMap.insert (file, Key key) (fmap toDyn val)
203203
204204-- | The outer Maybe is Nothing if this function hasn't been computed before
205205-- the inner Maybe is Nothing if the result of the previous computation failed to produce
@@ -208,19 +208,19 @@ getValues :: forall k v. IdeRule k v => Var Values -> k -> NormalizedFilePath ->
208208getValues state key file = do
209209 vs <- readVar state
210210 return $ do
211− v <- Map.lookup (file, Key key) vs
211+ v <- HMap.lookup (file, Key key) vs
212212 pure $ fmap (fromJust . fromDynamic @v) v
213213
214214-- | Open a 'IdeState', should be shut using 'shakeShut'.
215215shakeOpen :: (LSP.FromServerMessage -> IO ()) -- ^ diagnostic handler
216− -> Logger.Handle
216+ -> Logger
217217 -> ShakeOptions
218218 -> Rules ()
219219 -> IO IdeState
220220shakeOpen eventer logger opts rules = do
221221 shakeExtras <- do
222− globals <- newVar Map.empty
223− state <- newVar Map.empty
222+ globals <- newVar HMap.empty
223+ state <- newVar HMap.empty
224224 diagnostics <- newVar mempty
225225 pure ShakeExtras{..}
226226 (shakeDb, shakeClose) <- shakeOpenDatabase opts{shakeExtra = addShakeExtra shakeExtras $ shakeExtra opts} rules
@@ -248,7 +248,7 @@ shakeRun :: IdeState -> [Action a] -> ([a] -> IO ()) -> IO (IO [a])
248248-- not even start, which would make issues with async exceptions less problematic.
249249shakeRun IdeState{shakeExtras=ShakeExtras{..}, ..} acts callback = modifyVar shakeAbort $ \stop -> do
250250 (stopTime,_) <- duration stop
251− Logger.logDebug logger $ T.pack $ "Starting shakeRun (aborting the previous one took " ++ showDuration stopTime ++ ")"
251+ logDebug logger $ T.pack $ "Starting shakeRun (aborting the previous one took " ++ showDuration stopTime ++ ")"
252252 bar <- newBarrier
253253 start <- offsetTime
254254 let act = do
@@ -258,7 +258,7 @@ shakeRun IdeState{shakeExtras=ShakeExtras{..}, ..} acts callback = modifyVar sha
258258 thread <- forkFinally (shakeRunDatabaseProfile shakeDb [act]) $ \res -> do
259259 signalBarrier bar (mapRight head res)
260260 runTime <- start
261− Logger.logDebug logger $ T.pack $
261+ logDebug logger $ T.pack $
262262 "Finishing shakeRun (took " ++ showDuration runTime ++ ", " ++ (if isLeft res then "exception" else "completed") ++ ")"
263263 -- important: we send an async exception to the thread, then wait for it to die, before continuing
264264 return (do killThread thread; void $ waitBarrier bar, either throwIO return =<< waitBarrier bar)
@@ -271,14 +271,14 @@ useStale IdeState{shakeExtras=ShakeExtras{state}} k fp =
271271 join <$> getValues state k fp
272272
273273
274−getAllDiagnostics :: IdeState -> IO [FileDiagnostic]
275−getAllDiagnostics IdeState{shakeExtras = ShakeExtras{diagnostics}} = do
274+getDiagnostics :: IdeState -> IO [FileDiagnostic]
275+getDiagnostics IdeState{shakeExtras = ShakeExtras{diagnostics}} = do
276276 val <- readVar diagnostics
277− return $ D.getAllDiagnostics val
277+ return $ getAllDiagnostics val
278278
279279-- | FIXME: This function is temporary! Only required because the files of interest doesn't work
280−unsafeClearAllDiagnostics :: IdeState -> IO ()
281−unsafeClearAllDiagnostics IdeState{shakeExtras = ShakeExtras{diagnostics}} =
280+unsafeClearDiagnostics :: IdeState -> IO ()
281+unsafeClearDiagnostics IdeState{shakeExtras = ShakeExtras{diagnostics}} =
282282 writeVar diagnostics mempty
283283
284284-- | Clear the results for all files that do not match the given predicate.
@@ -286,7 +286,7 @@ garbageCollect :: (NormalizedFilePath -> Bool) -> Action ()
286286garbageCollect keep = do
287287 ShakeExtras{state, diagnostics} <- getShakeExtras
288288 liftIO $
289− do modifyVar_ state $ return . Map.filterWithKey (\(file, _) _ -> keep file)
289+ do modifyVar_ state $ return . HMap.filterWithKey (\(file, _) _ -> keep file)
290290 modifyVar_ diagnostics $ return . filterDiagnostics keep
291291
292292define
@@ -311,13 +311,7 @@ uses_ key files = do
311311reportSeriousError :: String -> Action ()
312312reportSeriousError t = do
313313 ShakeExtras{logger} <- getShakeExtras
314− liftIO $ Logger.logSeriousError logger $ T.pack t
315−
316−reportSeriousErrorDie :: String -> Action a
317−reportSeriousErrorDie t = do
318− ShakeExtras{logger} <- getShakeExtras
319− liftIO $ Logger.logSeriousError logger $ T.pack t
320− fail t
314+ liftIO $ logSeriousError logger $ T.pack t
321315
322316
323317-- | When we depend on something that reported an error, and we fail as a direct result, throw BadDependency
@@ -424,14 +418,9 @@ sendEvent e = do
424418 ShakeExtras{eventer} <- getShakeExtras
425419 liftIO $ eventer e
426420
427−-- | bit of an odd signature because we're trying to remove priority
428−sl :: (Handle -> T.Text -> IO ()) -> IdeState -> T.Text -> IO ()
429−sl f IdeState{shakeExtras=ShakeExtras{logger}} p = f logger p
421+ideLogger :: IdeState -> Logger
422+ideLogger IdeState{shakeExtras=ShakeExtras{logger}} = logger
430423
431−logDebug, logSeriousError
432− :: IdeState -> T.Text -> IO ()
433−logDebug = sl Logger.logDebug
434−logSeriousError = sl Logger.logSeriousError
435424
436425data GetModificationTime = GetModificationTime
437426 deriving (Eq, Show, Generic)
@@ -449,3 +438,46 @@ instance NFData FileVersion
449438vfsVersion :: FileVersion -> Maybe Int
450439vfsVersion (VFSVersion i) = Just i
451440vfsVersion (ModificationTime _) = Nothing
441+
442+
443+
444+getDiagnosticsFromStore :: StoreItem -> [Diagnostic]
445+getDiagnosticsFromStore (StoreItem _ diags) = concatMap SL.fromSortedList $ Map.elems diags
446+
447+
448+-- | Sets the diagnostics for a file and compilation step
449+-- if you want to clear the diagnostics call this with an empty list
450+setStageDiagnostics ::
451+ NormalizedFilePath ->
452+ Maybe Int ->
453+ -- ^ the time that the file these diagnostics originate from was last edited
454+ T.Text ->
455+ [LSP.Diagnostic] ->
456+ DiagnosticStore ->
457+ DiagnosticStore
458+setStageDiagnostics fp timeM stage diags ds =
459+ updateDiagnostics ds uri timeM diagsBySource
460+ where
461+ diagsBySource = Map.singleton (Just stage) (SL.toSortedList diags)
462+ uri = filePathToUri' fp
463+
464+getAllDiagnostics ::
465+ DiagnosticStore ->
466+ [FileDiagnostic]
467+getAllDiagnostics =
468+ concatMap (\(k,v) -> map (fromUri k,) $ getDiagnosticsFromStore v) . Map.toList
469+
470+getFileDiagnostics ::
471+ NormalizedFilePath ->
472+ DiagnosticStore ->
473+ [LSP.Diagnostic]
474+getFileDiagnostics fp ds =
475+ maybe [] getDiagnosticsFromStore $
476+ Map.lookup (filePathToUri' fp) ds
477+
478+filterDiagnostics ::
479+ (NormalizedFilePath -> Bool) ->
480+ DiagnosticStore ->
481+ DiagnosticStore
482+filterDiagnostics keep =
483+ Map.filterWithKey (\uri _ -> maybe True (keep . toNormalizedFilePath) $ uriToFilePath' $ fromNormalizedUri uri)
src/Development/IDE/LSP/Definition.hs+5−7
@@ -11,27 +11,25 @@ module Development.IDE.LSP.Definition
1111import Development.IDE.LSP.Protocol
1212import Development.IDE.Types.Location
1313
14−import qualified Development.IDE.Types.Logger as Logger
14+import Development.IDE.Types.Logger
1515import Development.IDE.Core.Rules
1616
1717import qualified Data.Text as T
18−import Data.Text.Prettyprint.Doc
19−import Data.Text.Prettyprint.Doc.Render.Text
2018
2119-- | Go to the definition of a variable.
2220handle
23− :: Logger.Handle
21+ :: Logger
2422 -> IdeState
2523 -> TextDocumentPositionParams
2624 -> IO LocationResponseParams
27−handle loggerH compilerH (TextDocumentPositionParams (TextDocumentIdentifier uri) pos) = do
25+handle logger compilerH (TextDocumentPositionParams (TextDocumentIdentifier uri) pos) = do
2826
2927
3028 mbResult <- case uriToFilePath' uri of
3129 Just (toNormalizedFilePath -> filePath) -> do
32− Logger.logInfo loggerH $
30+ logInfo logger $
3331 "Definition request at position " <>
34− renderStrict (layoutPretty defaultLayoutOptions $ prettyPosition pos) <>
32+ T.pack (showPosition pos) <>
3533 " in file: " <> T.pack (fromNormalizedFilePath filePath)
3634 runAction compilerH (getDefinition filePath pos)
3735 Nothing -> pure Nothing
src/Development/IDE/LSP/Hover.hs+4−6
@@ -12,26 +12,24 @@ import Development.IDE.LSP.Protocol hiding (Hover)
1212import Language.Haskell.LSP.Types (Hover(..))
1313import Development.IDE.Types.Location
1414
15−import qualified Development.IDE.Types.Logger as Logger
15+import Development.IDE.Types.Logger
1616
1717import qualified Data.Text as T
18−import Data.Text.Prettyprint.Doc
19−import Data.Text.Prettyprint.Doc.Render.Text
2018
2119import Development.IDE.Core.Rules
2220
2321-- | Display information on hover.
2422handle
25− :: Logger.Handle
23+ :: Logger
2624 -> IdeState
2725 -> TextDocumentPositionParams
2826 -> IO (Maybe Hover)
2927handle loggerH compilerH (TextDocumentPositionParams (TextDocumentIdentifier uri) pos) = do
3028 mbResult <- case uriToFilePath' uri of
3129 Just (toNormalizedFilePath -> filePath) -> do
32− Logger.logInfo loggerH $
30+ logInfo loggerH $
3331 "Hover request at position " <>
34− renderStrict (layoutPretty defaultLayoutOptions $ prettyPosition pos) <>
32+ T.pack (showPosition pos) <>
3533 " in file: " <> T.pack (fromNormalizedFilePath filePath)
3634 runAction compilerH $ getAtPoint filePath pos
3735 Nothing -> pure Nothing
src/Development/IDE/LSP/LanguageServer.hs+19−19
@@ -17,7 +17,7 @@ import Development.IDE.LSP.Server
1717import Control.Monad.IO.Class
1818import qualified Development.IDE.LSP.Definition as LS.Definition
1919import qualified Development.IDE.LSP.Hover as LS.Hover
20−import qualified Development.IDE.Types.Logger as Logger
20+import Development.IDE.Types.Logger
2121import Development.IDE.Core.Service
2222import Development.IDE.Types.Location
2323
@@ -44,30 +44,30 @@ textShow = T.pack . show
4444------------------------------------------------------------------------
4545
4646handleRequest
47− :: Logger.Handle
47+ :: Logger
4848 -> IdeState
4949 -> (forall resp. resp -> ResponseMessage resp)
5050 -> (ErrorCode -> ResponseMessage ())
5151 -> ServerRequest
5252 -> IO FromServerMessage
53−handleRequest loggerH compilerH makeResponse makeErrorResponse = \case
53+handleRequest logger compilerH makeResponse makeErrorResponse = \case
5454 Shutdown -> do
55− Logger.logInfo loggerH "Shutdown request received, terminating."
55+ logInfo logger "Shutdown request received, terminating."
5656 System.Exit.exitSuccess
5757
5858 KeepAlive -> pure $ RspCustomServer $ makeResponse Aeson.Null
5959
60− Definition params -> RspDefinition . makeResponse <$> LS.Definition.handle loggerH compilerH params
61− Hover params -> RspHover . makeResponse <$> LS.Hover.handle loggerH compilerH params
60+ Definition params -> RspDefinition . makeResponse <$> LS.Definition.handle logger compilerH params
61+ Hover params -> RspHover . makeResponse <$> LS.Hover.handle logger compilerH params
6262 CodeLens _params -> pure $ RspCodeLens $ makeResponse mempty
6363
6464 req -> do
65− Logger.logWarning loggerH ("Method not found" <> T.pack (show req))
65+ logWarning logger ("Method not found" <> T.pack (show req))
6666 pure $ RspError $ makeErrorResponse MethodNotFound
6767
6868
69−handleNotification :: LspFuncs () -> Logger.Handle -> IdeState -> ServerNotification -> IO ()
70−handleNotification lspFuncs loggerH compilerH = \case
69+handleNotification :: LspFuncs () -> Logger -> IdeState -> ServerNotification -> IO ()
70+handleNotification lspFuncs logger compilerH = \case
7171
7272 DidOpenTextDocument (DidOpenTextDocumentParams item) -> do
7373 case URI.parseURI $ T.unpack $ getUri $ _uri (item :: TextDocumentItem) of
@@ -76,10 +76,10 @@ handleNotification lspFuncs loggerH compilerH = \case
7676 -> handleDidOpenFile item
7777
7878 | otherwise
79− -> Logger.logWarning loggerH $ "Unknown scheme in URI: "
79+ -> logWarning logger $ "Unknown scheme in URI: "
8080 <> textShow uri
8181
82− _ -> Logger.logSeriousError loggerH $ "Invalid URI in DidOpenTextDocument: "
82+ _ -> logSeriousError logger $ "Invalid URI in DidOpenTextDocument: "
8383 <> textShow (_uri (item :: TextDocumentItem))
8484
8585 DidChangeTextDocument (DidChangeTextDocumentParams docId _) -> do
@@ -90,11 +90,11 @@ handleNotification lspFuncs loggerH compilerH = \case
9090 mbVirtual <- getVirtualFileFunc lspFuncs $ toNormalizedUri uri
9191 let contents = maybe "" (Rope.toText . (_text :: VirtualFile -> Rope.Rope)) mbVirtual
9292 onFileModified compilerH filePath (Just contents)
93− Logger.logInfo loggerH
93+ logInfo logger
9494 $ "Updated text document: " <> textShow (fromNormalizedFilePath filePath)
9595
9696 Nothing ->
97− Logger.logSeriousError loggerH
97+ logSeriousError logger
9898 $ "Invalid file path: " <> textShow (_uri (docId :: VersionedTextDocumentIdentifier))
9999
100100 DidCloseTextDocument (DidCloseTextDocumentParams (TextDocumentIdentifier uri)) ->
@@ -103,9 +103,9 @@ handleNotification lspFuncs loggerH compilerH = \case
103103 | URI.uriScheme uri' == "file:" -> do
104104 Just fp <- pure $ toNormalizedFilePath <$> uriToFilePath' uri
105105 handleDidCloseFile fp
106− | otherwise -> Logger.logWarning loggerH $ "Unknown scheme in URI: " <> textShow uri
106+ | otherwise -> logWarning logger $ "Unknown scheme in URI: " <> textShow uri
107107
108− _ -> Logger.logSeriousError loggerH
108+ _ -> logSeriousError logger
109109 $ "Invalid URI in DidCloseTextDocument: "
110110 <> textShow uri
111111
@@ -122,10 +122,10 @@ handleNotification lspFuncs loggerH compilerH = \case
122122 Just filePath <- pure $ toNormalizedFilePath <$> uriToFilePath' uri
123123 onFileModified compilerH filePath (Just contents)
124124 modifyFilesOfInterest compilerH (S.insert filePath)
125− Logger.logInfo loggerH $ "Opened text document: " <> textShow filePath
125+ logInfo logger $ "Opened text document: " <> textShow filePath
126126
127127 handleDidCloseFile filePath = do
128− Logger.logInfo loggerH $ "Closed text document: " <> textShow (fromNormalizedFilePath filePath)
128+ logInfo logger $ "Closed text document: " <> textShow (fromNormalizedFilePath filePath)
129129 onFileModified compilerH filePath Nothing
130130 modifyFilesOfInterest compilerH (S.delete filePath)
131131
@@ -136,7 +136,7 @@ onFileModified
136136 -> Maybe T.Text
137137 -> IO ()
138138onFileModified service fp mbContents = do
139− logDebug service $ "File modified " <> T.pack (show fp)
139+ logDebug (ideLogger service) $ "File modified " <> T.pack (show fp)
140140 setBufferModified service fp mbContents
141141
142142------------------------------------------------------------------------
@@ -144,7 +144,7 @@ onFileModified service fp mbContents = do
144144------------------------------------------------------------------------
145145
146146runLanguageServer
147− :: Logger.Handle
147+ :: Logger
148148 -> ((FromServerMessage -> IO ()) -> VFSHandle -> IO IdeState)
149149 -> IO ()
150150runLanguageServer loggerH getIdeState = do
src/Development/IDE/LSP/Protocol.hs+1−5
@@ -6,7 +6,6 @@ module Development.IDE.LSP.Protocol
66 ( module Language.Haskell.LSP.Types
77 , ServerRequest(..)
88 , ServerNotification(..)
9− , prettyPosition
109 , pattern EventFileDiagnostics
1110 ) where
1211
@@ -15,7 +14,7 @@ import qualified Data.Text as T
1514import Development.IDE.Types.Diagnostics
1615import Development.IDE.Types.Location
1716import Language.Haskell.LSP.Messages
18−import Data.Text.Prettyprint.Doc
17+
1918
2019import Language.Haskell.LSP.Types hiding
2120 ( CodeLens
@@ -54,9 +53,6 @@ data ServerNotification
5453-- Pretty printing
5554----------------------------------------------------------------------------------------------------
5655
57−prettyPosition :: Position -> Doc a
58−prettyPosition Position{..} = pretty (_line + 1) <> colon <> pretty (_character + 1)
59−
6056-- | Pattern synonym to make it a bit more convenient to match on diagnostics
6157-- in things like damlc test.
6258pattern EventFileDiagnostics :: FilePath -> [Diagnostic] -> FromServerMessage
src/Development/IDE/LSP/Server.hs+3−3
@@ -19,7 +19,7 @@ import Control.Concurrent.STM
1919import Data.Default
2020
2121import Development.IDE.LSP.Protocol
22−import qualified Development.IDE.Types.Logger as Logger
22+import Development.IDE.Types.Logger
2323
2424import qualified Data.Aeson as Aeson
2525import qualified Data.Aeson.Text as Aeson
@@ -49,7 +49,7 @@ data Handlers = Handlers
4949 }
5050
5151runServer
52− :: Logger.Handle
52+ :: Logger
5353 -> (LSP.LspFuncs () -> IO Handlers)
5454 -- ^ Notification handler for language server notifications
5555 -> IO ()
@@ -93,7 +93,7 @@ runServer loggerH getHandlers = do
9393 _ <- flip forkFinally (const exitClientMsg) $ forever $ do
9494 msg <- atomically $ readTChan clientMsgChan
9595 case convClientMsg msg of
96− Nothing -> Logger.logSeriousError loggerH $ "Unknown client msg: " <> T.pack (show msg)
96+ Nothing -> logSeriousError loggerH $ "Unknown client msg: " <> T.pack (show msg)
9797 Just (Left notif) -> notificationHandler notif
9898 Just (Right req) -> sendFunc =<< requestHandler' req
9999 pure Nothing
src/Development/IDE/Types/Diagnostics.hs+8−76
@@ -8,34 +8,22 @@ module Development.IDE.Types.Diagnostics (
88 FileDiagnostic,
99 LSP.DiagnosticSeverity(..),
1010 DiagnosticStore,
11− DiagnosticRelatedInformation(..),
1211 List(..),
13− StoreItem(..),
1412 ideErrorText,
1513 ideErrorPretty,
16− errorDiag,
1714 showDiagnostics,
1815 showDiagnosticsColored,
19− setStageDiagnostics,
20− getAllDiagnostics,
21− filterDiagnostics,
22− getFileDiagnostics,
23− prettyDiagnostics
2416 ) where
2517
2618import Data.Maybe as Maybe
27−import Data.Foldable
28−import qualified Data.Map as Map
2919import qualified Data.Text as T
3020import Data.Text.Prettyprint.Doc
31−import qualified Data.SortedList as SL
3221import qualified Text.PrettyPrint.Annotated.HughesPJClass as Pretty
3322import qualified Language.Haskell.LSP.Types as LSP
3423import Language.Haskell.LSP.Types as LSP (
3524 DiagnosticSeverity(..)
3625 , Diagnostic(..)
3726 , List(..)
38− , DiagnosticRelatedInformation(..)
3927 )
4028import Language.Haskell.LSP.Diagnostics
4129import Data.Text.Prettyprint.Doc.Render.Text
@@ -46,31 +34,18 @@ import Development.IDE.Types.Location
4634
4735
4836ideErrorText :: NormalizedFilePath -> T.Text -> FileDiagnostic
49−ideErrorText fp = errorDiag fp "Ide Error"
37+ideErrorText fp msg = (fp, LSP.Diagnostic {
38+ _range = noRange,
39+ _severity = Just LSP.DsError,
40+ _code = Nothing,
41+ _source = Just "compiler",
42+ _message = msg,
43+ _relatedInformation = Nothing
44+ })
5045
5146ideErrorPretty :: Pretty.Pretty e => NormalizedFilePath -> e -> FileDiagnostic
5247ideErrorPretty fp = ideErrorText fp . T.pack . Pretty.prettyShow
5348
54−errorDiag :: NormalizedFilePath -> T.Text -> T.Text -> FileDiagnostic
55−errorDiag fp src msg =
56− (fp, diagnostic noRange LSP.DsError src msg)
57−
58−-- | This is for compatibility with our old diagnostic type
59−diagnostic :: Range
60− -> LSP.DiagnosticSeverity
61− -> T.Text -- ^ source
62− -> T.Text -- ^ message
63− -> LSP.Diagnostic
64−diagnostic rng sev src msg
65− = LSP.Diagnostic {
66− _range = rng,
67− _severity = Just sev,
68− _code = Nothing,
69− _source = Just src,
70− _message = msg,
71− _relatedInformation = Nothing
72− }
73−
7449
7550-- | Human readable diagnostics for a specific file.
7651--
@@ -116,49 +91,6 @@ prettyDiagnostic (fp, LSP.Diagnostic{..}) =
11691 where
11792 sev = fromMaybe LSP.DsError _severity
11893
119−getDiagnosticsFromStore :: StoreItem -> [Diagnostic]
120−getDiagnosticsFromStore (StoreItem _ diags) =
121− toList =<< Map.elems diags
122−
123−
124−-- | Sets the diagnostics for a file and compilation step
125−-- if you want to clear the diagnostics call this with an empty list
126−setStageDiagnostics ::
127− NormalizedFilePath ->
128− Maybe Int ->
129− -- ^ the time that the file these diagnostics originate from was last edited
130− T.Text ->
131− [LSP.Diagnostic] ->
132− DiagnosticStore ->
133− DiagnosticStore
134−setStageDiagnostics fp timeM stage diags ds =
135− updateDiagnostics ds uri timeM diagsBySource
136− where
137− diagsBySource = Map.singleton (Just stage) (SL.toSortedList diags)
138− uri = filePathToUri' fp
139−
140−getAllDiagnostics ::
141− DiagnosticStore ->
142− [FileDiagnostic]
143−getAllDiagnostics =
144− concatMap (\(k,v) -> map (fromUri k,) $ getDiagnosticsFromStore v) . Map.toList
145−
146−getFileDiagnostics ::
147− NormalizedFilePath ->
148− DiagnosticStore ->
149− [LSP.Diagnostic]
150−getFileDiagnostics fp ds =
151− maybe [] getDiagnosticsFromStore $
152− Map.lookup (filePathToUri' fp) ds
153−
154−filterDiagnostics ::
155− (NormalizedFilePath -> Bool) ->
156− DiagnosticStore ->
157− DiagnosticStore
158−filterDiagnostics keep =
159− Map.filterWithKey (\uri _ -> maybe True (keep . toNormalizedFilePath) $ uriToFilePath' $ fromNormalizedUri uri)
160−
161−
16294
16395-- | Label a document.
16496slabel_ :: String -> Doc a -> Doc a
src/Development/IDE/Types/Location.hs+5−2
@@ -9,6 +9,7 @@ module Development.IDE.Types.Location
99 , noFilePath
1010 , noRange
1111 , Position(..)
12+ , showPosition
1213 , Range(..)
1314 , Uri(..)
1415 , NormalizedUri
@@ -24,8 +25,6 @@ module Development.IDE.Types.Location
2425 ) where
2526
2627import Language.Haskell.LSP.Types (Location(..), Range(..), Position(..))
27−
28−
2928import Control.DeepSeq
3029import Data.Maybe as Maybe
3130import Data.Hashable
@@ -84,3 +83,7 @@ noFilePath = "<unknown>"
8483-- A dummy range to use when range is unknown
8584noRange :: Range
8685noRange = Range (Position 0 0) (Position 100000 0)
86+
87+
88+showPosition :: Position -> String
89+showPosition Position{..} = show (_line + 1) ++ ":" ++ show (_character + 1)
src/Development/IDE/Types/Logger.hs+8−8
@@ -6,23 +6,23 @@
66-- concrete choice of logging framework so users can plug in whatever
77-- framework they want to.
88module Development.IDE.Types.Logger
9− ( Handle(..)
10− , makeOneHandle
11− , makeNopHandle
9+ ( Logger(..)
10+ , makeOneLogger
11+ , makeNopLogger
1212 ) where
1313
1414import qualified Data.Text as T
1515import GHC.Stack
1616
17−data Handle = Handle {
17+data Logger = Logger {
1818 logSeriousError :: HasCallStack => T.Text -> IO ()
1919 , logInfo :: HasCallStack => T.Text -> IO ()
2020 , logDebug :: HasCallStack => T.Text -> IO ()
2121 , logWarning :: HasCallStack => T.Text -> IO ()
2222 }
2323
24−makeNopHandle :: Handle
25−makeNopHandle = makeOneHandle $ const $ pure ()
24+makeNopLogger :: Logger
25+makeNopLogger = makeOneLogger $ const $ pure ()
2626
27−makeOneHandle :: (HasCallStack => T.Text -> IO ()) -> Handle
28−makeOneHandle x = Handle x x x x
27+makeOneLogger :: (HasCallStack => T.Text -> IO ()) -> Logger
28+makeOneLogger x = Logger x x x x
test/Demo.hs+2−3
@@ -14,7 +14,6 @@ import Development.IDE.Core.Shake
1414import Development.IDE.Core.RuleTypes
1515import Development.IDE.LSP.Protocol
1616import Development.IDE.Types.Location
17−import Data.String
1817import Development.IDE.Types.Diagnostics
1918import Development.IDE.Types.Options
2019import Development.IDE.Types.Logger
@@ -47,7 +46,7 @@ main = do
4746 args <- getArgs
4847 -- lock to avoid overlapping output on stdout
4948 lock <- newLock
50− let logger = makeOneHandle $ withLock lock . T.putStrLn
49+ let logger = makeOneLogger $ withLock lock . T.putStrLn
5150
5251 dir <- getCurrentDirectory
5352 hPutStrLn stderr dir
@@ -75,7 +74,7 @@ main = do
7574
7675kick :: Action ()
7776kick = do
78− files <- use_ GetFilesOfInterest $ fromString ""
77+ files <- getFilesOfInterest
7978 void $ uses TypeCheck $ Set.toList files
8079
8180-- | Print an LSP event.