@@ -172,18 +172,27 @@ getIdeas :: NormalizedFilePath -> Action (Either ParseError [Idea])
172
172
getIdeas nfp = do
173
173
logm $ " getIdeas:file:" ++ show nfp
174
174
(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 ))
179
183
#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)
184
192
#else
193
+ moduleEx flags = do
185
194
flags' <- setExtensions flags
186
- liftIO $ parseModuleEx flags' (fromNormalizedFilePath nfp) Nothing
195
+ Just <$> ( liftIO $ parseModuleEx flags' (fromNormalizedFilePath nfp) Nothing )
187
196
188
197
setExtensions flags = do
189
198
hsc <- hscEnv <$> use_ GhcSession nfp
@@ -233,9 +242,7 @@ codeActionProvider _ _ plId docId _ context = (Right . LSP.List . map CACodeActi
233
242
234
243
-- | Some hints do not have an associated refactoring
235
244
validCommand (LSP. Diagnostic _ _ (Just (LSP. StringValue code)) (Just " hlint" ) _ _ _) =
236
- case code of
237
- " Eta reduce" -> False
238
- _ -> True
245
+ code /= " Eta reduce"
239
246
validCommand _ = False
240
247
241
248
LSP. List diags = context ^. LSP. diagnostics
0 commit comments