hls-module-name-plugin 2.2.0.0 → 2.3.0.0
raw patch · 2 files changed
+15/−12 lines, 2 filesdep ~ghcidedep ~hls-plugin-apidep ~hls-test-utilsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghcide, hls-plugin-api, hls-test-utils
API changes (from Hackage documentation)
Files
hls-module-name-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-module-name-plugin-version: 2.2.0.0+version: 2.3.0.0 synopsis: Module name plugin for Haskell Language Server description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -33,8 +33,8 @@ , containers , directory , filepath- , ghcide == 2.2.0.0- , hls-plugin-api == 2.2.0.0+ , ghcide == 2.3.0.0+ , hls-plugin-api == 2.3.0.0 , lsp , text , transformers@@ -53,4 +53,4 @@ , base , filepath , hls-module-name-plugin- , hls-test-utils == 2.2.0.0+ , hls-test-utils == 2.3.0.0
src/Ide/Plugin/ModuleName.hs view
@@ -25,11 +25,12 @@ import Control.Monad.Trans.Except import Control.Monad.Trans.Maybe import Data.Aeson (toJSON)-import Data.Char (isLower)-import Data.List (intercalate, isPrefixOf,- minimumBy)+import Data.Char (isLower, isUpper)+import Data.List (intercalate, minimumBy,+ stripPrefix, uncons) import qualified Data.List.NonEmpty as NE import qualified Data.Map as Map+import Data.Maybe (mapMaybe) import Data.Ord (comparing) import Data.String (IsString) import qualified Data.Text as T@@ -154,15 +155,17 @@ mdlPath <- liftIO $ makeAbsolute filePath logWith recorder Debug (AbsoluteFilePath mdlPath) - let prefixes = filter (`isPrefixOf` mdlPath) paths- pure (map (moduleNameFrom mdlPath) prefixes)+ let suffixes = mapMaybe (`stripPrefix` mdlPath) paths+ pure (map moduleNameFrom suffixes) where- moduleNameFrom mdlPath prefix =+ moduleNameFrom = T.pack . intercalate "."+ -- Do not suggest names whose components start from a lower-case char,+ -- they are guaranteed to be malformed.+ . filter (maybe False (isUpper . fst) . uncons) . splitDirectories- . drop (length prefix)- $ dropExtension mdlPath+ . dropExtension -- | The module name, as stated in the module codeModuleName :: IdeState -> NormalizedFilePath -> IO (Maybe (Range, T.Text))