Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pluginId from getNormalizedFilePath error message #3118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Plugin/HLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ extensiblePlugins recorder xs = mempty { P.pluginHandlers = handlers }
case nonEmpty fs of
Nothing -> logAndReturnError recorder InvalidRequest (pluginNotEnabled m fs')
Just fs -> do
let msg e pid = "Exception in plugin " <> T.pack (show pid) <> "while processing " <> T.pack (show m) <> ": " <> T.pack (show e)
let msg e pid = "Exception in plugin " <> T.pack (show pid) <> " while processing " <> T.pack (show m) <> ": " <> T.pack (show e)
handlers = fmap (\(plid,_,handler) -> (plid,handler)) fs
es <- runConcurrently msg (show m) handlers ide params
let (errs,succs) = partitionEithers $ toList es
Expand Down
6 changes: 3 additions & 3 deletions hls-plugin-api/src/Ide/PluginUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ allLspCmdIds pid commands = concatMap go commands

-- ---------------------------------------------------------------------

getNormalizedFilePath :: Monad m => PluginId -> Uri -> ExceptT String m NormalizedFilePath
getNormalizedFilePath (PluginId plId) uri = handleMaybe errMsg
getNormalizedFilePath :: Monad m => Uri -> ExceptT String m NormalizedFilePath
getNormalizedFilePath uri = handleMaybe errMsg
$ uriToNormalizedFilePath
$ toNormalizedUri uri
where
errMsg = T.unpack $ "Error(" <> plId <> "): converting " <> getUri uri <> " to NormalizedFilePath"
errMsg = T.unpack $ "Failed converting " <> getUri uri <> " to NormalizedFilePath"

-- ---------------------------------------------------------------------
throwPluginError :: Monad m => String -> ExceptT String m b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,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 plId (CodeActionParams _ _ docId currRange _) = pluginResponse $ do
nfp <- getNormalizedFilePath plId (docId ^. L.uri)
codeActionHandler state _ (CodeActionParams _ _ docId currRange _) = pluginResponse $ do
nfp <- getNormalizedFilePath (docId ^. L.uri)
CLR{..} <- requestLiterals state nfp
pragma <- getFirstPragma state nfp
-- remove any invalid literals (see validTarget comment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ callHierarchyId = PluginId "callHierarchy"

-- | Render prepare call hierarchy request.
prepareCallHierarchy :: PluginMethodHandler IdeState TextDocumentPrepareCallHierarchy
prepareCallHierarchy state pluginId param = pluginResponse $ do
nfp <- getNormalizedFilePath pluginId (param ^. L.textDocument ^. L.uri)
prepareCallHierarchy state _ param = pluginResponse $ do
nfp <- getNormalizedFilePath (param ^. L.textDocument ^. L.uri)
items <- liftIO (runAction "CallHierarchy.prepareHierarchy" state (prepareCallHierarchyItem nfp (param ^. L.position)))
pure (List <$> items)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ descriptor :: PluginDescriptor IdeState
descriptor = (defaultPluginDescriptor changeTypeSignatureId) { pluginHandlers = mkPluginHandler STextDocumentCodeAction codeActionHandler }

codeActionHandler :: PluginMethodHandler IdeState 'TextDocumentCodeAction
codeActionHandler ideState plId CodeActionParams {_textDocument = TextDocumentIdentifier uri, _context = CodeActionContext (List diags) _} = pluginResponse $ do
nfp <- getNormalizedFilePath plId uri
codeActionHandler ideState _ CodeActionParams {_textDocument = TextDocumentIdentifier uri, _context = CodeActionContext (List diags) _} = pluginResponse $ do
nfp <- getNormalizedFilePath uri
decls <- getDecls ideState nfp
let actions = mapMaybe (generateAction uri decls) diags
pure $ List actions
Expand Down
6 changes: 3 additions & 3 deletions plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import Language.LSP.Types
import qualified Language.LSP.Types.Lens as J

addMethodPlaceholders :: PluginId -> CommandFunction IdeState AddMinimalMethodsParams
addMethodPlaceholders plId state param@AddMinimalMethodsParams{..} = do
addMethodPlaceholders _ state param@AddMinimalMethodsParams{..} = do
caps <- getClientCapabilities
pluginResponse $ do
nfp <- getNormalizedFilePath plId uri
nfp <- getNormalizedFilePath uri
pm <- handleMaybeM "Unable to GetParsedModule"
$ liftIO
$ runAction "classplugin.addMethodPlaceholders.GetParsedModule" state
Expand Down Expand Up @@ -81,7 +81,7 @@ addMethodPlaceholders plId state param@AddMinimalMethodsParams{..} = do
-- sensitive to the format of diagnostic messages from GHC.
codeAction :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState TextDocumentCodeAction
codeAction recorder state plId (CodeActionParams _ _ docId _ context) = pluginResponse $ do
nfp <- getNormalizedFilePath plId uri
nfp <- getNormalizedFilePath uri
actions <- join <$> mapM (mkActions nfp) methodDiags
pure $ List actions
where
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified Language.LSP.Types.Lens as J

codeLens :: PluginMethodHandler IdeState TextDocumentCodeLens
codeLens state plId CodeLensParams{..} = pluginResponse $ do
nfp <- getNormalizedFilePath plId uri
nfp <- getNormalizedFilePath uri
tmr <- handleMaybeM "Unable to typecheck"
$ liftIO
$ runAction "classplugin.TypeCheck" state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ descriptor recorder = (defaultPluginDescriptor pluginId)
}

hover :: PluginMethodHandler IdeState TextDocumentHover
hover state plId (HoverParams (TextDocumentIdentifier uri) pos _) = pluginResponse $ do
nfp <- getNormalizedFilePath plId uri
hover state _ (HoverParams (TextDocumentIdentifier uri) pos _) = pluginResponse $ do
nfp <- getNormalizedFilePath uri
fixityTrees <- handleMaybeM "ExplicitFixity: Unable to get fixity"
$ liftIO
$ runAction "ExplicitFixity.GetFixity" state
Expand Down
6 changes: 3 additions & 3 deletions plugins/hls-gadt-plugin/src/Ide/Plugin/GADT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ toGADTSyntaxCommandId = "GADT.toGADT"

-- | A command replaces H98 data decl with GADT decl in place
toGADTCommand :: PluginId -> CommandFunction IdeState ToGADTParams
toGADTCommand plId state ToGADTParams{..} = pluginResponse $ do
nfp <- getNormalizedFilePath plId uri
toGADTCommand _ state ToGADTParams{..} = pluginResponse $ do
nfp <- getNormalizedFilePath uri
(decls, exts) <- getInRangeH98DeclsAndExts state range nfp
(L ann decl) <- case decls of
[d] -> pure d
Expand Down Expand Up @@ -83,7 +83,7 @@ toGADTCommand plId state ToGADTParams{..} = pluginResponse $ do

codeActionHandler :: PluginMethodHandler IdeState TextDocumentCodeAction
codeActionHandler state plId (CodeActionParams _ _ doc range _) = pluginResponse $ do
nfp <- getNormalizedFilePath plId (doc ^. L.uri)
nfp <- getNormalizedFilePath (doc ^. L.uri)
(inRangeH98Decls, _) <- getInRangeH98DeclsAndExts state range nfp
let actions = map (mkAction . printOutputable . tcdLName . unLoc) inRangeH98Decls
pure $ List actions
Expand Down