packages feed

hls-cabal-plugin 2.5.0.0 → 2.6.0.0

raw patch · 3 files changed

+38/−34 lines, 3 filesdep ~ghcidedep ~hls-graphdep ~hls-plugin-apiPVP ok

version bump matches the API change (PVP)

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

API changes (from Hackage documentation)

- Ide.Plugin.Cabal.Completion.Types: ParseCabal :: ParseCabal
- Ide.Plugin.Cabal.Completion.Types: data ParseCabal
- Ide.Plugin.Cabal.Completion.Types: instance Control.DeepSeq.NFData Ide.Plugin.Cabal.Completion.Types.ParseCabal
- Ide.Plugin.Cabal.Completion.Types: instance Data.Hashable.Class.Hashable Ide.Plugin.Cabal.Completion.Types.ParseCabal
- Ide.Plugin.Cabal.Completion.Types: instance GHC.Classes.Eq Ide.Plugin.Cabal.Completion.Types.ParseCabal
- Ide.Plugin.Cabal.Completion.Types: instance GHC.Generics.Generic Ide.Plugin.Cabal.Completion.Types.ParseCabal
- Ide.Plugin.Cabal.Completion.Types: instance GHC.Show.Show Ide.Plugin.Cabal.Completion.Types.ParseCabal
+ Ide.Plugin.Cabal.Completion.Types: GetCabalDiagnostics :: GetCabalDiagnostics
+ Ide.Plugin.Cabal.Completion.Types: data GetCabalDiagnostics
+ Ide.Plugin.Cabal.Completion.Types: instance Control.DeepSeq.NFData Ide.Plugin.Cabal.Completion.Types.GetCabalDiagnostics
+ Ide.Plugin.Cabal.Completion.Types: instance Data.Hashable.Class.Hashable Ide.Plugin.Cabal.Completion.Types.GetCabalDiagnostics
+ Ide.Plugin.Cabal.Completion.Types: instance GHC.Classes.Eq Ide.Plugin.Cabal.Completion.Types.GetCabalDiagnostics
+ Ide.Plugin.Cabal.Completion.Types: instance GHC.Generics.Generic Ide.Plugin.Cabal.Completion.Types.GetCabalDiagnostics
+ Ide.Plugin.Cabal.Completion.Types: instance GHC.Show.Show Ide.Plugin.Cabal.Completion.Types.GetCabalDiagnostics
- Ide.Plugin.Cabal.Diagnostics: data Diagnostic
+ Ide.Plugin.Cabal.Diagnostics: data () => Diagnostic
- Ide.Plugin.Cabal.LicenseSuggest: data Diagnostic
+ Ide.Plugin.Cabal.LicenseSuggest: data () => Diagnostic
- Ide.Plugin.Cabal.LicenseSuggest: data Text
+ Ide.Plugin.Cabal.LicenseSuggest: data () => Text
- Ide.Plugin.Cabal.Parse: data GenericPackageDescription
+ Ide.Plugin.Cabal.Parse: data () => GenericPackageDescription
- Ide.Plugin.Cabal.Parse: data NonEmpty a
+ Ide.Plugin.Cabal.Parse: data () => NonEmpty a
- Ide.Plugin.Cabal.Parse: data PError
+ Ide.Plugin.Cabal.Parse: data () => PError
- Ide.Plugin.Cabal.Parse: data PWarning
+ Ide.Plugin.Cabal.Parse: data () => PWarning
- Ide.Plugin.Cabal.Parse: data Position
+ Ide.Plugin.Cabal.Parse: data () => Position
- Ide.Plugin.Cabal.Parse: data Version
+ Ide.Plugin.Cabal.Parse: data () => Version

Files

hls-cabal-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               hls-cabal-plugin-version:            2.5.0.0+version:            2.6.0.0 synopsis:           Cabal integration plugin with Haskell Language Server description:   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -49,10 +49,10 @@     , directory     , filepath     , extra                 >=1.7.4-    , ghcide                == 2.5.0.0+    , ghcide                == 2.6.0.0     , hashable-    , hls-plugin-api        == 2.5.0.0-    , hls-graph             == 2.5.0.0+    , hls-plugin-api        == 2.6.0.0+    , hls-graph             == 2.6.0.0     , lens     , lsp                   ^>=2.3     , lsp-types             ^>=2.1@@ -84,7 +84,7 @@     , filepath     , ghcide     , hls-cabal-plugin-    , hls-test-utils    == 2.5.0.0+    , hls-test-utils    == 2.6.0.0     , lens     , lsp     , lsp-types
src/Ide/Plugin/Cabal.hs view
@@ -80,8 +80,8 @@  descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState descriptor recorder plId =-  (defaultCabalPluginDescriptor plId)-    { pluginRules = cabalRules recorder+  (defaultCabalPluginDescriptor plId "Provides a variety of IDE features in cabal files")+    { pluginRules = cabalRules recorder plId     , pluginHandlers =         mconcat           [ mkPluginHandler LSP.SMethod_TextDocumentCodeAction licenseSuggestCodeAction@@ -139,31 +139,35 @@ -- Plugin Rules -- ---------------------------------------------------------------- -cabalRules :: Recorder (WithPriority Log) -> Rules ()-cabalRules recorder = do+cabalRules :: Recorder (WithPriority Log) -> PluginId -> Rules ()+cabalRules recorder plId = do   -- Make sure we initialise the cabal files-of-interest.   ofInterestRules recorder   -- Rule to produce diagnostics for cabal files.-  define (cmapWithPrio LogShake recorder) $ \Types.ParseCabal file -> do-    -- whenever this key is marked as dirty (e.g., when a user writes stuff to it),-    -- we rerun this rule because this rule *depends* on GetModificationTime.-    (t, mCabalSource) <- use_ GetFileContents file-    log' Debug $ LogModificationTime file t-    contents <- case mCabalSource of-      Just sources ->-        pure $ Encoding.encodeUtf8 sources-      Nothing -> do-        liftIO $ BS.readFile $ fromNormalizedFilePath file+  define (cmapWithPrio LogShake recorder) $ \Types.GetCabalDiagnostics file -> do+    config <- getPluginConfigAction plId+    if not (plcGlobalOn config && plcDiagnosticsOn config)+        then pure ([], Nothing)+        else do+          -- whenever this key is marked as dirty (e.g., when a user writes stuff to it),+          -- we rerun this rule because this rule *depends* on GetModificationTime.+          (t, mCabalSource) <- use_ GetFileContents file+          log' Debug $ LogModificationTime file t+          contents <- case mCabalSource of+            Just sources ->+              pure $ Encoding.encodeUtf8 sources+            Nothing -> do+              liftIO $ BS.readFile $ fromNormalizedFilePath file -    (pWarnings, pm) <- liftIO $ Parse.parseCabalFileContents contents-    let warningDiags = fmap (Diagnostics.warningDiagnostic file) pWarnings-    case pm of-      Left (_cabalVersion, pErrorNE) -> do-        let errorDiags = NE.toList $ NE.map (Diagnostics.errorDiagnostic file) pErrorNE-            allDiags = errorDiags <> warningDiags-        pure (allDiags, Nothing)-      Right gpd -> do-        pure (warningDiags, Just gpd)+          (pWarnings, pm) <- liftIO $ Parse.parseCabalFileContents contents+          let warningDiags = fmap (Diagnostics.warningDiagnostic file) pWarnings+          case pm of+            Left (_cabalVersion, pErrorNE) -> do+              let errorDiags = NE.toList $ NE.map (Diagnostics.errorDiagnostic file) pErrorNE+                  allDiags = errorDiags <> warningDiags+              pure (allDiags, Nothing)+            Right gpd -> do+              pure (warningDiags, Just gpd)    action $ do     -- Run the cabal kick. This code always runs when 'shakeRestart' is run.@@ -183,7 +187,7 @@ kick :: Action () kick = do   files <- HashMap.keys <$> getCabalFilesOfInterestUntracked-  void $ uses Types.ParseCabal files+  void $ uses Types.GetCabalDiagnostics files  -- ---------------------------------------------------------------- -- Code Actions@@ -292,7 +296,7 @@         let completer = Completions.contextToCompleter ctx         let completerData = CompleterTypes.CompleterData               { getLatestGPD = do-                mGPD <- runIdeAction "cabal-plugin.modulesCompleter.gpd" (shakeExtras ide) $ useWithStaleFast Types.ParseCabal $ toNormalizedFilePath fp+                mGPD <- runIdeAction "cabal-plugin.modulesCompleter.gpd" (shakeExtras ide) $ useWithStaleFast Types.GetCabalDiagnostics $ toNormalizedFilePath fp                 pure $ fmap fst mGPD               , cabalPrefixInfo = prefInfo               , stanzaName =
src/Ide/Plugin/Cabal/Completion/Types.hs view
@@ -37,14 +37,14 @@     LogUseWithStaleFastNoResult -> "Package description couldn't be read"     LogMapLookUpOfKnownKeyFailed key -> "Lookup of key in map failed even though it should exist" <+> pretty key -type instance RuleResult ParseCabal = Parse.GenericPackageDescription+type instance RuleResult GetCabalDiagnostics = Parse.GenericPackageDescription -data ParseCabal = ParseCabal+data GetCabalDiagnostics = GetCabalDiagnostics   deriving (Eq, Show, Typeable, Generic) -instance Hashable ParseCabal+instance Hashable GetCabalDiagnostics -instance NFData ParseCabal+instance NFData GetCabalDiagnostics  -- | The context a cursor can be in within a cabal file. --