Skip to content

Commit 289b48b

Browse files
committed
Make compile ghc-8.10.1 code path
1 parent 37b00ed commit 289b48b

File tree

1 file changed

+19
-12
lines changed
  • plugins/hlint-hls-plugin/src/Ide/Plugin

1 file changed

+19
-12
lines changed

plugins/hlint-hls-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,27 @@ getIdeas :: NormalizedFilePath -> Action (Either ParseError [Idea])
172172
getIdeas nfp = do
173173
logm $ "getIdeas:file:" ++ show nfp
174174
(flags, classify, hint) <- useNoFile_ GetHlintSettings
175-
let applyHints' modEx = applyHints classify hint [modEx]
176-
fmap (fmap applyHints') (moduleEx flags)
177-
where moduleEx :: ParseFlags -> Action (Either ParseError ModuleEx)
178-
moduleEx flags = do
175+
176+
let applyHints' (Just (Right modEx)) = Right $ applyHints classify hint [modEx]
177+
applyHints' (Just (Left err)) = Left err
178+
applyHints' Nothing = Right []
179+
180+
fmap applyHints' (moduleEx flags)
181+
182+
where moduleEx :: ParseFlags -> Action (Maybe (Either ParseError ModuleEx))
179183
#ifndef GHC_LIB
180-
pm <- getParsedModule nfp
181-
let anns = pm_annotations pm
182-
let modu = pm_parsed_source pm
183-
return $ Right (createModuleEx anns modu)
184+
moduleEx _flags = do
185+
mbpm <- getParsedModule nfp
186+
case mbpm of
187+
Nothing -> return Nothing
188+
Just pm -> do
189+
let anns = pm_annotations pm
190+
let modu = pm_parsed_source pm
191+
return $ Just $ Right (createModuleEx anns modu)
184192
#else
193+
moduleEx flags = do
185194
flags' <- setExtensions flags
186-
liftIO $ parseModuleEx flags' (fromNormalizedFilePath nfp) Nothing
195+
Just <$> (liftIO $ parseModuleEx flags' (fromNormalizedFilePath nfp) Nothing)
187196

188197
setExtensions flags = do
189198
hsc <- hscEnv <$> use_ GhcSession nfp
@@ -233,9 +242,7 @@ codeActionProvider _ _ plId docId _ context = (Right . LSP.List . map CACodeActi
233242

234243
-- |Some hints do not have an associated refactoring
235244
validCommand (LSP.Diagnostic _ _ (Just (LSP.StringValue code)) (Just "hlint") _ _ _) =
236-
case code of
237-
"Eta reduce" -> False
238-
_ -> True
245+
code /= "Eta reduce"
239246
validCommand _ = False
240247

241248
LSP.List diags = context ^. LSP.diagnostics

0 commit comments

Comments
 (0)