From f636f1a79b4d185d199bb6f9bc2259d535f2851c Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 20 Jan 2022 16:26:11 +0000 Subject: [PATCH] Use helpers from lsp to do code action prefixing Nicer version as promised in https://github.com/haskell/haskell-language-server/pull/2146. --- hls-plugin-api/src/Ide/Types.hs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hls-plugin-api/src/Ide/Types.hs b/hls-plugin-api/src/Ide/Types.hs index b20eb890d6..c15d2ce08d 100644 --- a/hls-plugin-api/src/Ide/Types.hs +++ b/hls-plugin-api/src/Ide/Types.hs @@ -202,11 +202,7 @@ instance PluginMethod TextDocumentCodeAction where -- should check whether the requested kind is a *prefix* of the action kind. -- That means, for example, we will return actions with kinds `quickfix.import` and -- `quickfix.somethingElse` if the requested kind is `quickfix`. - -- TODO: add helpers in `lsp` for handling code action hierarchies - -- For now we abuse the fact that the JSON representation gives us the hierarchical string. - , Just caKind <- ca ^. kind - , String caKindStr <- toJSON caKind = - any (\k -> k `T.isPrefixOf` caKindStr) [kstr | k <- allowed, let String kstr = toJSON k ] + , Just caKind <- ca ^. kind = any (\k -> k `codeActionKindSubsumes` caKind) allowed | otherwise = False instance PluginMethod TextDocumentCodeLens where