hls-refactor-plugin 2.5.0.0 → 2.6.0.0
raw patch · 4 files changed
+34/−15 lines, 4 filesdep ~ghcidedep ~hls-plugin-apidep ~hls-test-utilsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghcide, hls-plugin-api, hls-test-utils
API changes (from Hackage documentation)
- Development.IDE.GHC.ExactPrint: instance (p GHC.Types.~ GHC.Hs.Extension.GhcPs) => Development.IDE.GHC.ExactPrint.ASTElement GHC.Parser.Annotation.AnnListItem (GHC.Hs.ImpExp.ImportDecl p)
+ Development.IDE.GHC.ExactPrint: instance (p GHC.Types.~ GHC.Hs.Extension.GhcPs) => Development.IDE.GHC.ExactPrint.ASTElement GHC.Parser.Annotation.AnnListItem (Language.Haskell.Syntax.ImpExp.ImportDecl p)
- Development.IDE.GHC.Compat.ExactPrint: data Annotated ast
+ Development.IDE.GHC.Compat.ExactPrint: data () => Annotated ast
- Development.IDE.GHC.ExactPrint: data TransformT (m :: Type -> Type) a
+ Development.IDE.GHC.ExactPrint: data () => TransformT (m :: Type -> Type) a
Files
- hls-refactor-plugin.cabal +4/−4
- src/Development/IDE/Plugin/CodeAction.hs +5/−2
- src/Development/IDE/Plugin/CodeAction/Args.hs +4/−4
- test/Main.hs +21/−5
hls-refactor-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: hls-refactor-plugin-version: 2.5.0.0+version: 2.6.0.0 synopsis: Exactprint refactorings for Haskell Language Server description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -73,8 +73,8 @@ , ghc-boot , regex-tdfa , text-rope- , ghcide == 2.5.0.0- , hls-plugin-api == 2.5.0.0+ , ghcide == 2.6.0.0+ , hls-plugin-api == 2.6.0.0 , lsp , text , transformers@@ -112,7 +112,7 @@ , base , filepath , hls-refactor-plugin- , hls-test-utils == 2.5.0.0+ , hls-test-utils == 2.6.0.0 , lens , lsp-types , text
src/Development/IDE/Plugin/CodeAction.hs view
@@ -145,6 +145,7 @@ , wrap suggestAddRecordFieldImport ] plId+ "Provides various quick fixes" in mkExactprintPluginDescriptor recorder $ old {pluginHandlers = pluginHandlers old <> mkPluginHandler SMethod_TextDocumentCodeAction codeAction } typeSigsPluginDescriptor :: Recorder (WithPriority E.Log) -> PluginId -> PluginDescriptor IdeState@@ -157,6 +158,7 @@ , wrap suggestConstraint ] plId+ "Provides various quick fixes for type signatures" bindingsPluginDescriptor :: Recorder (WithPriority E.Log) -> PluginId -> PluginDescriptor IdeState bindingsPluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder $@@ -168,12 +170,13 @@ , wrap suggestDeleteUnusedBinding ] plId+ "Provides various quick fixes for bindings" fillHolePluginDescriptor :: Recorder (WithPriority E.Log) -> PluginId -> PluginDescriptor IdeState-fillHolePluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder (mkGhcideCAPlugin (wrap suggestFillHole) plId)+fillHolePluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder (mkGhcideCAPlugin (wrap suggestFillHole) plId "Provides a code action to fill a hole") extendImportPluginDescriptor :: Recorder (WithPriority E.Log) -> PluginId -> PluginDescriptor IdeState-extendImportPluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder $ (defaultPluginDescriptor plId)+extendImportPluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder $ (defaultPluginDescriptor plId "Provides a command to extend the import list") { pluginCommands = [extendImportCommand] }
src/Development/IDE/Plugin/CodeAction/Args.hs view
@@ -93,9 +93,9 @@ mkCA title kind isPreferred diags edit = InR $ CodeAction title kind (Just $ diags) isPreferred Nothing (Just edit) Nothing Nothing -mkGhcideCAPlugin :: GhcideCodeAction -> PluginId -> PluginDescriptor IdeState-mkGhcideCAPlugin codeAction plId =- (defaultPluginDescriptor plId)+mkGhcideCAPlugin :: GhcideCodeAction -> PluginId -> T.Text -> PluginDescriptor IdeState+mkGhcideCAPlugin codeAction plId desc =+ (defaultPluginDescriptor plId desc) { pluginHandlers = mkPluginHandler SMethod_TextDocumentCodeAction $ \state _ params@(CodeActionParams _ _ (TextDocumentIdentifier uri) _ CodeActionContext {_diagnostics = diags}) -> do results <- lift $ runGhcideCodeAction state params codeAction@@ -107,7 +107,7 @@ ] } -mkGhcideCAsPlugin :: [GhcideCodeAction] -> PluginId -> PluginDescriptor IdeState+mkGhcideCAsPlugin :: [GhcideCodeAction] -> PluginId -> T.Text -> PluginDescriptor IdeState mkGhcideCAsPlugin codeActions = mkGhcideCAPlugin $ mconcat codeActions -------------------------------------------------------------------------------------------------
test/Main.hs view
@@ -176,6 +176,25 @@ "join" ["{-# LANGUAGE NoImplicitPrelude #-}", "module A where", "import Control.Monad as M ()", "import Control.Monad as N (join)", "f = N.joi"]+ -- Regression test for https://github.com/haskell/haskell-language-server/issues/2824+ , completionNoCommandTest+ "explicit qualified"+ ["{-# LANGUAGE NoImplicitPrelude #-}",+ "module A where", "import qualified Control.Monad as M (j)"]+ (Position 2 38)+ "join"+ , completionNoCommandTest+ "explicit qualified post"+ ["{-# LANGUAGE NoImplicitPrelude, ImportQualifiedPost #-}",+ "module A where", "import Control.Monad qualified as M (j)"]+ (Position 2 38)+ "join"+ , completionNoCommandTest+ "multiline import"+ [ "{-# LANGUAGE NoImplicitPrelude #-}"+ , "module A where", "import Control.Monad", " (fore)"]+ (Position 3 9)+ "forever" ] , testGroup "Data constructor" [ completionCommandTest@@ -288,11 +307,8 @@ docId <- createDoc "A.hs" "haskell" (T.unlines src) _ <- waitForDiagnostics compls <- getCompletions docId pos- let wantedC = find ( \case- CompletionItem {_insertText = Just x} -> wanted `T.isPrefixOf` x- _ -> False- ) compls- case wantedC of+ let isPrefixOfInsertOrLabel ci = any (wanted `T.isPrefixOf`) [fromMaybe "" (ci ^. L.insertText), ci ^. L.label]+ case find isPrefixOfInsertOrLabel compls of Nothing -> liftIO $ assertFailure $ "Cannot find expected completion in: " <> show [_label | CompletionItem {_label} <- compls] Just CompletionItem{..} -> liftIO . assertBool ("Expected no command but got: " <> show _command) $ null _command