Skip to content

Commit f2f1697

Browse files
VenInffendor
andauthored
Apply suggestions from code review
small review changes Co-authored-by: fendor <[email protected]>
1 parent 2209853 commit f2f1697

File tree

1 file changed

+5
-5
lines changed
  • plugins/hls-cabal-plugin/src/Ide/Plugin

1 file changed

+5
-5
lines changed

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ instance Pretty Log where
8989
LogCabalAdd logs -> pretty logs
9090

9191
-- | Some actions with cabal files originate from haskell files.
92-
-- This descriptor is needed to handle these cases.
92+
-- This descriptor allows to hook into the diagnostics of haskell source files, and
93+
-- allows us to provide code actions and commands that interact with `.cabal` files.
9394
haskellInteractionDescriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
9495
haskellInteractionDescriptor recorder plId =
9596
(defaultPluginDescriptor plId "Provides the cabal-add code action in haskell files")
@@ -98,7 +99,7 @@ haskellInteractionDescriptor recorder plId =
9899
[ mkPluginHandler LSP.SMethod_TextDocumentCodeAction $ cabalAddCodeAction recorder
99100
]
100101
, pluginCommands = [PluginCommand CabalAdd.cabalAddCommand "add a dependency to a cabal file" (CabalAdd.command cabalAddRecorder)]
101-
, pluginRules = pure () -- TODO: change to haskell files only (?)
102+
, pluginRules = pure ()
102103
, pluginNotificationHandlers = mempty
103104
}
104105
where
@@ -302,13 +303,12 @@ fieldSuggestCodeAction recorder ide _ (CodeActionParams _ _ (TextDocumentIdentif
302303
cabalAddCodeAction :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'LSP.Method_TextDocumentCodeAction
303304
cabalAddCodeAction recorder state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) _ CodeActionContext{_diagnostics=diags}) = do
304305
maxCompls <- fmap maxCompletions . liftIO $ runAction "cabal.cabal-add" state getClientConfigAction
305-
let mbHaskellFilePath = uriToFilePath uri
306-
case mbHaskellFilePath of
306+
case uriToFilePath uri of
307307
Nothing -> pure $ InL []
308308
Just haskellFilePath -> do
309309
mbCabalFile <- liftIO $ CabalAdd.findResponsibleCabalFile haskellFilePath
310310
case mbCabalFile of
311-
Nothing -> pure $ InL $ fmap InR [noCabalFileAction]
311+
Nothing -> pure $ InL [InR noCabalFileAction]
312312
Just cabalFilePath -> do
313313
verTxtDocId <- lift $ pluginGetVersionedTextDoc $ TextDocumentIdentifier (filePathToUri cabalFilePath)
314314
mbGPD <- liftIO $ runAction "cabal.cabal-add" state $ useWithStale ParseCabalFile $ toNormalizedFilePath cabalFilePath

0 commit comments

Comments
 (0)