hls-explicit-imports-plugin 1.1.0.1 → 1.2.0.0
raw patch · 3 files changed
+21/−7 lines, 3 filesdep ~ghcidedep ~hls-plugin-apiPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghcide, hls-plugin-api
API changes (from Hackage documentation)
Files
hls-explicit-imports-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: hls-explicit-imports-plugin-version: 1.1.0.1+version: 1.2.0.0 synopsis: Explicit imports plugin for Haskell Language Server description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -15,6 +15,10 @@ test/testdata/*.hs test/testdata/*.yaml +source-repository head+ type: git+ location: https://github.com/haskell/haskell-language-server.git+ library buildable: True exposed-modules: Ide.Plugin.ExplicitImports@@ -25,9 +29,9 @@ , containers , deepseq , ghc- , ghcide ^>=1.7 || ^>=1.8+ , ghcide ^>=1.9 , hls-graph- , hls-plugin-api ^>=1.4 || ^>=1.5+ , hls-plugin-api ^>=1.6 , lsp , text , unordered-containers
src/Ide/Plugin/ExplicitImports.hs view
@@ -118,7 +118,7 @@ -- haskell-lsp provides conversion functions | Just nfp <- uriToNormalizedFilePath $ toNormalizedUri _uri = liftIO $ do- mbMinImports <- runAction "" state $ useWithStale MinimalImports nfp+ mbMinImports <- runAction "MinimalImports" state $ useWithStale MinimalImports nfp case mbMinImports of -- Implement the provider logic: -- for every import, if it's lacking a explicit list, generate a code lens@@ -212,6 +212,7 @@ Map.fromList [ (realSrcSpanStart l, printOutputable i) | L (locA -> RealSrcSpan l _) i <- fromMaybe [] mbMinImports+ , not (isImplicitPrelude i) ] res = [ (i, Map.lookup (realSrcSpanStart l) importsMap)@@ -219,7 +220,16 @@ , RealSrcSpan l _ <- [getLoc i] ] return ([], MinimalImportsResult res <$ mbMinImports)+ where+ isImplicitPrelude :: (Outputable a) => a -> Bool+ isImplicitPrelude importDecl =+ T.isPrefixOf implicitPreludeImportPrefix (printOutputable importDecl) +-- | This is the prefix of an implicit prelude import which should be ignored,+-- when considering the minimal imports rule+implicitPreludeImportPrefix :: T.Text+implicitPreludeImportPrefix = "import (implicit) Prelude"+ -------------------------------------------------------------------------------- -- | Use the ghc api to extract a minimal, explicit set of imports for this module@@ -306,7 +316,7 @@ oneLineText = T.unwords $ T.lines input -- Now, split at the max columns, leaving space for the summary text we're going to add -- (conservatively assuming we won't need to print a number larger than 100)- (prefix, suffix) = T.splitAt (maxColumns - (T.length (summaryText 100))) oneLineText+ (prefix, suffix) = T.splitAt (maxColumns - T.length (summaryText 100)) oneLineText -- We also want to truncate the last item so we get a "clean" break, rather than half way through -- something. The conditional here is just because 'breakOnEnd' doesn't give us quite the right thing -- if there are actually no commas.
test/Main.hs view
@@ -15,8 +15,8 @@ import System.FilePath ((<.>), (</>)) import Test.Hls -explicitImportsPlugin :: PluginDescriptor IdeState-explicitImportsPlugin = ExplicitImports.descriptor mempty "explicitImports"+explicitImportsPlugin :: PluginTestDescriptor ExplicitImports.Log+explicitImportsPlugin = mkPluginTestDescriptor ExplicitImports.descriptor "explicitImports" longModule :: T.Text longModule = "F" <> T.replicate 80 "o"