packages feed

hls-cabal-fmt-plugin 2.1.0.0 → 2.2.0.0

raw patch · 3 files changed

+17/−16 lines, 3 filesdep +process-extrasdep −processdep ~ghcidedep ~hls-plugin-apidep ~hls-test-utilsPVP ok

version bump matches the API change (PVP)

Dependencies added: process-extras

Dependencies removed: process

Dependency ranges changed: ghcide, hls-plugin-api, hls-test-utils

API changes (from Hackage documentation)

- Ide.Plugin.CabalFmt: LogReadCreateProcessInfo :: String -> [String] -> Log
+ Ide.Plugin.CabalFmt: LogReadCreateProcessInfo :: Text -> [String] -> Log

Files

hls-cabal-fmt-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               hls-cabal-fmt-plugin-version:            2.1.0.0+version:            2.2.0.0 synopsis:           Integration with the cabal-fmt code formatter description:   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -33,12 +33,12 @@     , base            >=4.12 && <5     , directory     , filepath-    , ghcide          == 2.1.0.0-    , hls-plugin-api  == 2.1.0.0+    , ghcide          == 2.2.0.0+    , hls-plugin-api  == 2.2.0.0     , lens     , lsp-types     , mtl-    , process+    , process-extras     , text     , transformers @@ -56,7 +56,7 @@     , directory     , filepath     , hls-cabal-fmt-plugin-    , hls-test-utils        == 2.1.0.0+    , hls-test-utils        == 2.2.0.0    if flag(isolateTests)     build-tool-depends: cabal-fmt:cabal-fmt ^>=0.1.6
src/Ide/Plugin/CabalFmt.hs view
@@ -11,28 +11,29 @@ import           Ide.Plugin.Error            (PluginError (PluginInternalError, PluginInvalidParams)) import           Ide.PluginUtils import           Ide.Types-import           Language.LSP.Protocol.Lens  as L+import qualified Language.LSP.Protocol.Lens  as L import           Language.LSP.Protocol.Types import           Prelude                     hiding (log) import           System.Directory import           System.Exit import           System.FilePath-import           System.Process+import           System.Process.ListLike+import qualified System.Process.Text         as Process  data Log   = LogProcessInvocationFailure Int-  | LogReadCreateProcessInfo String [String]+  | LogReadCreateProcessInfo T.Text [String]   | LogInvalidInvocationInfo   | LogCabalFmtNotFound   deriving (Show)  instance Pretty Log where   pretty = \case-    LogProcessInvocationFailure code -> "Invocation of cabal-fmt failed with code" <+> pretty code+    LogProcessInvocationFailure exitCode -> "Invocation of cabal-fmt failed with code" <+> pretty exitCode     LogReadCreateProcessInfo stdErrorOut args ->       vcat $         ["Invocation of cabal-fmt with arguments" <+> pretty args]-          ++ ["failed with standard error:" <+> pretty stdErrorOut | not (null stdErrorOut)]+          ++ ["failed with standard error:" <+> pretty stdErrorOut | not (T.null stdErrorOut)]     LogInvalidInvocationInfo -> "Invocation of cabal-fmt with range was called but is not supported."     LogCabalFmtNotFound -> "Couldn't find executable 'cabal-fmt'" @@ -50,24 +51,24 @@   logWith recorder Info LogInvalidInvocationInfo   throwError $ PluginInvalidParams "You cannot format a text-range using cabal-fmt." provider recorder _ide FormatText contents nfp opts = do-  let cabalFmtArgs = [fp, "--indent", show tabularSize]+  let cabalFmtArgs = [ "--indent", show tabularSize]   x <- liftIO $ findExecutable "cabal-fmt"   case x of     Just _ -> do       (exitCode, out, err) <--        liftIO $ readCreateProcessWithExitCode+        liftIO $ Process.readCreateProcessWithExitCode           ( proc "cabal-fmt" cabalFmtArgs           )             { cwd = Just $ takeDirectory fp             }-          ""+          contents       log Debug $ LogReadCreateProcessInfo err cabalFmtArgs       case exitCode of         ExitFailure code -> do           log Error $ LogProcessInvocationFailure code           throwError (PluginInternalError "Failed to invoke cabal-fmt")         ExitSuccess -> do-          let fmtDiff = makeDiffTextEdit contents (T.pack out)+          let fmtDiff = makeDiffTextEdit contents out           pure $ InL fmtDiff     Nothing -> do       log Error LogCabalFmtNotFound
test/Main.hs view
@@ -39,7 +39,7 @@     cabalFmtGolden found "formats a simple document" "simple_testdata" "formatted_document" $ \doc -> do       formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) -  , knownBrokenOnWindows "expand:src comment bug in cabal-fmt on windows" $+  , expectFailBecause "cabal-fmt can't expand modules if .cabal file is read from stdin. Tracking issue: https://github.com/phadej/cabal-fmt/pull/82" $     cabalFmtGolden found "formats a document with expand:src comment" "commented_testdata" "formatted_document" $ \doc -> do       formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing) @@ -52,7 +52,7 @@   testCase title $     assertFailure $  "Couldn't find cabal-fmt on PATH or this is not an isolated run. "                   <> "Use cabal flag 'isolateTests' to make it isolated or install cabal-fmt locally."-cabalFmtGolden Found title path desc act = goldenWithCabalDocFormatter cabalFmtPlugin "cabal-fmt" conf title testDataDir path desc "cabal" act+cabalFmtGolden Found title path desc act = goldenWithCabalDocFormatter def cabalFmtPlugin "cabal-fmt" conf title testDataDir path desc "cabal" act   where     conf = def