packages feed

hls-hlint-plugin 1.1.0.0 → 1.1.1.0

raw patch · 3 files changed

+40/−35 lines, 3 filesdep ~apply-refactdep ~ghcidedep ~hlint

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

Files

hls-hlint-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name:          hls-hlint-plugin-version:       1.1.0.0+version:       1.1.1.0 synopsis:      Hlint integration plugin with Haskell Language Server description:   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -20,16 +20,16 @@   test/testdata/**/*.hs   test/testdata/**/*.h +source-repository head+    type:     git+    location: https://github.com/haskell/haskell-language-server.git+ flag pedantic   description: Enable -Werror   default:     False   manual:      True  library-  if impl(ghc >= 9.3)-    buildable: False-  else-    buildable: True   exposed-modules:    Ide.Plugin.Hlint   hs-source-dirs:     src   build-depends:@@ -45,10 +45,10 @@     , extra     , filepath     , ghc-exactprint        >=0.6.3.4-    , ghcide                ^>=1.8+    , ghcide                ^>=1.9     , hashable-    , hlint                 < 3.5-    , hls-plugin-api        ^>=1.5+    , hlint                 < 3.6+    , hls-plugin-api        ^>=1.6     , hslogger     , lens     , lsp@@ -59,9 +59,12 @@     , text     , transformers     , unordered-containers-    , apply-refact          >=0.9.0.0     , ghc-lib-parser     , ghc-lib-parser-ex+  if impl(ghc >= 9.2)+    build-depends: apply-refact ^>= 0.11.0.0+  else+    build-depends: apply-refact ^>= 0.9.0.0    cpp-options:   -DHLINT_ON_GHC_LIB   ghc-options:@@ -77,10 +80,6 @@     TypeOperators  test-suite tests-  if impl(ghc >= 9.3)-    buildable: False-  else-    buildable: True   type:             exitcode-stdio-1.0   default-language: Haskell2010   hs-source-dirs:   test@@ -93,7 +92,7 @@     , filepath     , hls-hlint-plugin     , hls-plugin-api-    , hls-test-utils      ^>=1.4+    , hls-test-utils      ^>=1.5     , lens     , lsp-types     , text
src/Ide/Plugin/Hlint.hs view
@@ -43,7 +43,6 @@                                                                      ToJSON (..),                                                                      Value (..)) import qualified Data.ByteString                                    as BS-import           Data.Default import           Data.Hashable import qualified Data.HashMap.Strict                                as Map import           Data.Maybe@@ -51,10 +50,10 @@ import qualified Data.Text.Encoding                                 as T import           Data.Typeable import           Development.IDE                                    hiding-                                                                    (Error)+                                                                    (Error,+                                                                     getExtensions) import           Development.IDE.Core.Rules                         (defineNoFile,-                                                                     getParsedModuleWithComments,-                                                                     usePropertyAction)+                                                                     getParsedModuleWithComments) import           Development.IDE.Core.Shake                         (getDiagnostics) import qualified Refact.Apply                                       as Refact import qualified Refact.Types                                       as Refact@@ -68,6 +67,9 @@                                                                      wopt) import qualified Development.IDE.GHC.Compat.Util                    as EnumSet +#if MIN_GHC_API_VERSION(9,4,0)+import qualified "ghc-lib-parser" GHC.Data.Strict                   as Strict+#endif #if MIN_GHC_API_VERSION(9,0,0) import           "ghc-lib-parser" GHC.Types.SrcLoc                  hiding                                                                     (RealSrcSpan)@@ -109,7 +111,8 @@                                                                     (Config) import           Ide.Plugin.Properties import           Ide.PluginUtils-import           Ide.Types+import           Ide.Types                                          hiding+                                                                    (Config) import           Language.Haskell.HLint                             as Hlint hiding                                                                              (Error) import           Language.LSP.Server                                (ProgressCancellable (Cancellable),@@ -158,7 +161,9 @@ type BufSpan = () #endif pattern RealSrcSpan :: GHC.RealSrcSpan -> Maybe BufSpan -> GHC.SrcSpan-#if MIN_GHC_API_VERSION(9,0,0)+#if MIN_GHC_API_VERSION(9,4,0)+pattern RealSrcSpan x y <- GHC.RealSrcSpan x (fromStrictMaybe -> y)+#elif MIN_GHC_API_VERSION(9,0,0) pattern RealSrcSpan x y = GHC.RealSrcSpan x y #else pattern RealSrcSpan x y <- ((,Nothing) -> (GHC.RealSrcSpan x, y))@@ -166,6 +171,12 @@ {-# COMPLETE RealSrcSpan, UnhelpfulSpan #-} #endif +#if MIN_GHC_API_VERSION(9,4,0)+fromStrictMaybe :: Strict.Maybe a -> Maybe a+fromStrictMaybe (Strict.Just a ) = Just a+fromStrictMaybe  Strict.Nothing  = Nothing+#endif+ descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState descriptor recorder plId = (defaultPluginDescriptor plId)   { pluginRules = rules recorder plId@@ -199,8 +210,8 @@ rules :: Recorder (WithPriority Log) -> PluginId -> Rules () rules recorder plugin = do   define (cmapWithPrio LogShake recorder) $ \GetHlintDiagnostics file -> do-    config <- getClientConfigAction def-    let hlintOn = pluginEnabledConfig plcDiagnosticsOn plugin config+    config <- getPluginConfigAction plugin+    let hlintOn = pluginEnabledConfig plcDiagnosticsOn config     ideas <- if hlintOn then getIdeas recorder file else return (Right [])     return (diagnostics file ideas, Just ()) @@ -430,7 +441,7 @@      LSP.List diags = context ^. LSP.diagnostics --- | Convert a hlint diagonistic into an apply and an ignore code action+-- | Convert a hlint diagnostic into an apply and an ignore code action -- if applicable diagnosticToCodeActions :: DynFlags -> T.Text -> PluginId -> TextDocumentIdentifier -> LSP.Diagnostic -> [LSP.CodeAction] diagnosticToCodeActions dynFlags fileContents pluginId documentId diagnostic@@ -555,7 +566,7 @@     modsum <- liftIO $ runAction' $ use_ GetModSummary nfp     let dflags = ms_hspp_opts $ msrModSummary modsum     -- Setting a environment variable with the libdir used by ghc-exactprint.-    -- It is a workaround for an error caused by the use of a hadcoded at compile time libdir+    -- It is a workaround for an error caused by the use of a hardcoded at compile time libdir     -- in ghc-exactprint that makes dependent executables non portables.     -- See https://github.com/alanz/ghc-exactprint/issues/96.     -- WARNING: this code is not thread safe, so if you try to apply several async refactorings
test/Main.hs view
@@ -17,6 +17,7 @@ import           Ide.Plugin.Config       (Config (..), PluginConfig (..)) import qualified Ide.Plugin.Config       as Plugin import qualified Ide.Plugin.Hlint        as HLint+import           Ide.Types               (PluginId) import qualified Language.LSP.Types.Lens as L import           System.FilePath         ((</>)) import           Test.Hls@@ -24,8 +25,8 @@ main :: IO () main = defaultTestRunner tests -hlintPlugin :: PluginDescriptor IdeState-hlintPlugin = HLint.descriptor mempty "hlint"+hlintPlugin :: PluginTestDescriptor HLint.Log+hlintPlugin = mkPluginTestDescriptor HLint.descriptor "hlint"  tests :: TestTree tests = testGroup "hlint" [@@ -101,7 +102,7 @@         contents <- skipManyTill anyMessage $ getDocumentEdit doc         liftIO $ contents @?= "main = undefined\nfoo x = x\n" -    , testCase "falls back to pre 3.8 code actions" $ runSessionWithServer' [hlintPlugin] def def noLiteralCaps "test/testdata" $ do+    , testCase "falls back to pre 3.8 code actions" $ runSessionWithServerAndCaps hlintPlugin noLiteralCaps "test/testdata" $ do         doc <- openDoc "Base.hs" "haskell"          _ <- waitForDiagnosticsFromSource doc "hlint"@@ -181,11 +182,11 @@         doc <- openDoc "IgnoreAnnHlint.hs" "haskell"         expectNoMoreDiagnostics 3 doc "hlint" -    , knownBrokenForGhcVersions [GHC92] "apply-refact has different behavior on v0.10" $+    , knownBrokenForGhcVersions [GHC92, GHC94] "apply-refact has different behavior on v0.10" $       testCase "apply-refact preserve regular comments" $ runHlintSession "" $ do         testRefactor "Comments.hs" "Redundant bracket" expectedComments -    , onlyRunForGhcVersions [GHC92] "only run test for apply-refact-0.10" $+    , onlyRunForGhcVersions [GHC92, GHC94] "only run test for apply-refact-0.10" $       testCase "apply-refact preserve regular comments" $ runHlintSession "" $ do         testRefactor "Comments.hs" "Redundant bracket" expectedComments' @@ -340,12 +341,6 @@ testHlintDiagnostics doc = do     diags <- waitForDiagnosticsFromSource doc "hlint"     liftIO $ length diags > 0 @? "There are hlint diagnostics"--pluginGlobalOn :: Config -> T.Text -> Bool -> Config-pluginGlobalOn config pid state = config'-  where-      pluginConfig = def { plcGlobalOn = state }-      config' = def { plugins = Map.insert pid pluginConfig (plugins config) }  hlintConfigWithFlags :: [T.Text] -> Config hlintConfigWithFlags flags =