diff --git a/hls-plugin-api/src/Ide/PluginUtils.hs b/hls-plugin-api/src/Ide/PluginUtils.hs index 8dc33fbdbe..345d5e15f9 100644 --- a/hls-plugin-api/src/Ide/PluginUtils.hs +++ b/hls-plugin-api/src/Ide/PluginUtils.hs @@ -246,13 +246,12 @@ allLspCmdIds pid commands = concatMap go commands -- --------------------------------------------------------------------- -getNormalizedFilePath :: Monad m => PluginId -> TextDocumentIdentifier -> ExceptT String m NormalizedFilePath -getNormalizedFilePath (PluginId plId) docId = handleMaybe errMsg +getNormalizedFilePath :: Monad m => PluginId -> Uri -> ExceptT String m NormalizedFilePath +getNormalizedFilePath (PluginId plId) uri = handleMaybe errMsg $ uriToNormalizedFilePath - $ toNormalizedUri uri' + $ toNormalizedUri uri where - errMsg = T.unpack $ "Error(" <> plId <> "): converting " <> getUri uri' <> " to NormalizedFilePath" - uri' = docId ^. uri + errMsg = T.unpack $ "Error(" <> plId <> "): converting " <> getUri uri <> " to NormalizedFilePath" -- --------------------------------------------------------------------- handleMaybe :: Monad m => e -> Maybe b -> ExceptT e m b diff --git a/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal b/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal index c045e625e4..372fd8c3d2 100644 --- a/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal +++ b/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal @@ -29,7 +29,7 @@ library , ghcide ^>=1.6 || ^>=1.7 , ghc-boot-th , hls-graph - , hls-plugin-api ^>=1.3 || ^>=1.4 + , hls-plugin-api ^>=1.4 , hie-compat , lens , lsp diff --git a/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/AlternateNumberFormat.hs b/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/AlternateNumberFormat.hs index 4491f96fb9..dcf8b3dd8a 100644 --- a/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/AlternateNumberFormat.hs +++ b/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/AlternateNumberFormat.hs @@ -14,9 +14,8 @@ import Development.IDE (GetParsedModule (GetParsedModu GhcSession (GhcSession), IdeState, RuleResult, Rules, define, getFileContents, - hscEnv, ideLogger, - realSrcSpanToRange, runAction, - use, useWithStale) + hscEnv, realSrcSpanToRange, + runAction, use, useWithStale) import qualified Development.IDE.Core.Shake as Shake import Development.IDE.GHC.Compat hiding (getSrcSpan) import Development.IDE.GHC.Compat.Util (toList) @@ -31,8 +30,8 @@ import Ide.Plugin.Conversion (AlternateFormat, ExtensionNeeded (NeedsExtension, NoExtension), alternateFormat) import Ide.Plugin.Literals -import Ide.PluginUtils (handleMaybe, handleMaybeM, - response) +import Ide.PluginUtils (getNormalizedFilePath, + handleMaybeM, response) import Ide.Types import Language.LSP.Types import Language.LSP.Types.Lens (uri) @@ -84,8 +83,8 @@ collectLiteralsRule recorder = define (cmapWithPrio LogShake recorder) $ \Collec getExtensions = map GhcExtension . toList . extensionFlags . ms_hspp_opts . pm_mod_summary codeActionHandler :: PluginMethodHandler IdeState 'TextDocumentCodeAction -codeActionHandler state _ (CodeActionParams _ _ docId currRange _) = response $ do - nfp <- getNormalizedFilePath docId +codeActionHandler state plId (CodeActionParams _ _ docId currRange _) = response $ do + nfp <- getNormalizedFilePath plId (docId ^. uri) CLR{..} <- requestLiterals state nfp pragma <- getFirstPragma state nfp -- remove any invalid literals (see validTarget comment) @@ -151,12 +150,6 @@ getFirstPragma state nfp = handleMaybeM "Error: Could not get NextPragmaInfo" $ Just (hscEnv -> hsc_dflags -> sessionDynFlags, _) -> pure $ Just $ getNextPragmaInfo sessionDynFlags fileContents Nothing -> pure Nothing - -getNormalizedFilePath :: Monad m => TextDocumentIdentifier -> ExceptT String m NormalizedFilePath -getNormalizedFilePath docId = handleMaybe "Error: converting to NormalizedFilePath" - $ uriToNormalizedFilePath - $ toNormalizedUri (docId ^. uri) - requestLiterals :: MonadIO m => IdeState -> NormalizedFilePath -> ExceptT String m CollectLiteralsResult requestLiterals state = handleMaybeM "Error: Could not Collect Literals" . liftIO diff --git a/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal b/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal index ccd8c6238c..5f9812c30e 100644 --- a/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal +++ b/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal @@ -24,7 +24,7 @@ library build-depends: , base >=4.12 && < 5 , ghcide ^>=1.7 - , hls-plugin-api ^>=1.3 || ^>=1.4 + , hls-plugin-api ^>=1.4 , lsp-types , regex-tdfa , syb diff --git a/plugins/hls-change-type-signature-plugin/src/Ide/Plugin/ChangeTypeSignature.hs b/plugins/hls-change-type-signature-plugin/src/Ide/Plugin/ChangeTypeSignature.hs index 3d833a9cd5..b0163bef59 100644 --- a/plugins/hls-change-type-signature-plugin/src/Ide/Plugin/ChangeTypeSignature.hs +++ b/plugins/hls-change-type-signature-plugin/src/Ide/Plugin/ChangeTypeSignature.hs @@ -35,7 +35,7 @@ descriptor plId = (defaultPluginDescriptor plId) { pluginHandlers = mkPluginHand codeActionHandler :: PluginMethodHandler IdeState 'TextDocumentCodeAction codeActionHandler ideState plId CodeActionParams {_textDocument = TextDocumentIdentifier uri, _context = CodeActionContext (List diags) _} = response $ do - nfp <- getNormalizedFilePath plId (TextDocumentIdentifier uri) + nfp <- getNormalizedFilePath plId uri decls <- getDecls ideState nfp let actions = mapMaybe (generateAction uri decls) diags pure $ List actions