hls-explicit-imports-plugin 1.0.1.2 → 1.0.2.0
raw patch · 3 files changed
+14/−13 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.0.1.2+version: 1.0.2.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>@@ -24,9 +24,9 @@ , containers , deepseq , ghc- , ghcide ^>=1.4 || ^>=1.5+ , ghcide ^>=1.6 , hls-graph- , hls-plugin-api >=1.1 && <1.3+ , hls-plugin-api ^>=1.3 , lsp , text , unordered-containers
src/Ide/Plugin/ExplicitImports.hs view
@@ -6,7 +6,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeFamilies #-}-+{-# LANGUAGE ViewPatterns #-} module Ide.Plugin.ExplicitImports ( descriptor@@ -42,7 +42,9 @@ -- | The "main" function of a plugin descriptor :: PluginId -> PluginDescriptor IdeState-descriptor = descriptorForModules (/= moduleName pRELUDE)+descriptor =+ -- (almost) no one wants to see an explicit import list for Prelude+ descriptorForModules (/= moduleName pRELUDE) descriptorForModules :: (ModuleName -> Bool)@@ -70,7 +72,7 @@ PluginCommand importCommandId "Explicit import command" runImportCommand -- | The type of the parameters accepted by our command-data ImportCommandParams = ImportCommandParams WorkspaceEdit+newtype ImportCommandParams = ImportCommandParams WorkspaceEdit deriving (Generic) deriving anyclass (FromJSON, ToJSON) @@ -180,7 +182,7 @@ exportedModuleStrings ParsedModule{pm_parsed_source = L _ HsModule{..}} | Just export <- hsmodExports, exports <- unLoc export- = map show exports+ = map prettyPrint exports exportedModuleStrings _ = [] minimalImportsRule :: Rules ()@@ -194,7 +196,7 @@ let importsMap = Map.fromList [ (realSrcSpanStart l, T.pack (prettyPrint i))- | L (RealSrcSpan l _) i <- fromMaybe [] mbMinImports+ | L (locA -> RealSrcSpan l _) i <- fromMaybe [] mbMinImports ] res = [ (i, Map.lookup (realSrcSpanStart l) importsMap)@@ -240,15 +242,14 @@ notExported _ _ = False extractMinimalImports _ _ = return ([], Nothing) -mkExplicitEdit :: (ModuleName -> Bool) -> PositionMapping -> LImportDecl pass -> T.Text -> Maybe TextEdit-mkExplicitEdit pred posMapping (L src imp) explicit+mkExplicitEdit :: (ModuleName -> Bool) -> PositionMapping -> LImportDecl GhcRn -> T.Text -> Maybe TextEdit+mkExplicitEdit pred posMapping (L (locA -> src) imp) explicit -- Explicit import list case | ImportDecl {ideclHiding = Just (False, _)} <- imp = Nothing | not (isQualifiedImport imp), RealSrcSpan l _ <- src, L _ mn <- ideclName imp,- -- (almost) no one wants to see an explicit import list for Prelude pred mn, Just rng <- toCurrentRange posMapping $ realSrcSpanToRange l = Just $ TextEdit rng explicit
test/Main.hs view
@@ -84,6 +84,6 @@ pointRange :: Int -> Int -> Range pointRange- (subtract 1 -> line)- (subtract 1 -> col) =+ (subtract 1 -> fromIntegral -> line)+ (subtract 1 -> fromIntegral -> col) = Range (Position line col) (Position line $ col + 1)