hls-class-plugin 1.0.0.1 → 1.0.0.2
raw patch · 3 files changed
+33/−52 lines, 3 filesdep +ghc-api-compatdep −bytestringdep −lsp-testdep −shakedep ~ghcidenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies added: ghc-api-compat
Dependencies removed: bytestring, lsp-test, shake, unordered-containers
Dependency ranges changed: ghcide
API changes (from Hackage documentation)
Files
- hls-class-plugin.cabal +6/−10
- src/Ide/Plugin/Class.hs +1/−2
- test/Main.hs +26/−40
hls-class-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-class-plugin-version: 1.0.0.1+version: 1.0.0.2 synopsis: Class/instance management plugin for Haskell Language Server @@ -25,18 +25,17 @@ hs-source-dirs: src build-depends: , aeson- , base >=4.12 && <5+ , base >=4.12 && <5 , containers , ghc+ , ghc-api-compat , ghc-exactprint- , ghcide ^>=1.2- , hls-plugin-api ^>=1.1+ , ghcide >=1.2 && <1.5+ , hls-plugin-api ^>=1.1 , lens , lsp- , shake , text , transformers- , unordered-containers default-language: Haskell2010 default-extensions:@@ -53,11 +52,8 @@ ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: , base- , bytestring , filepath , hls-class-plugin- , hls-test-utils ^>= 1.0+ , hls-test-utils ^>=1.0 , lens- , lsp-test , lsp-types- , text
src/Ide/Plugin/Class.hs view
@@ -25,7 +25,7 @@ import Development.IDE hiding (pluginHandlers) import Development.IDE.Core.PositionMapping (fromCurrentRange, toCurrentRange)-import Development.IDE.GHC.Compat hiding (getLoc)+import Development.IDE.GHC.Compat import Development.IDE.Spans.AtPoint import qualified GHC.Generics as Generics import GhcPlugins hiding (Var, getLoc,@@ -38,7 +38,6 @@ import Language.LSP.Server import Language.LSP.Types import qualified Language.LSP.Types.Lens as J-import SrcLoc import TcEnv import TcRnMonad
test/Main.hs view
@@ -1,15 +1,14 @@-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeOperators #-}++{-# OPTIONS_GHC -Wall #-} module Main ( main- )-where+ ) where -import Control.Lens hiding ((<.>))-import qualified Data.ByteString.Lazy as BS-import qualified Data.Text.Encoding as T+import Control.Lens (Prism', prism', (^..), (^?))+import Control.Monad (void) import qualified Ide.Plugin.Class as Class import qualified Language.LSP.Types.Lens as J import System.FilePath@@ -18,14 +17,14 @@ main :: IO () main = defaultTestRunner tests -plugin :: PluginDescriptor IdeState-plugin = Class.descriptor "class"+classPlugin :: PluginDescriptor IdeState+classPlugin = Class.descriptor "class" tests :: TestTree tests = testGroup "class" [ testCase "Produces addMinimalMethodPlaceholders code actions for one instance" $ do- runSessionWithServer plugin classPath $ do+ runSessionWithServer classPlugin testDataDir $ do doc <- openDoc "T1.hs" "haskell" _ <- waitForDiagnosticsFromSource doc "typecheck" caResults <- getAllCodeActions doc@@ -34,23 +33,17 @@ [ Just "Add placeholders for '=='" , Just "Add placeholders for '/='" ]- , glodenTest "Creates a placeholder for '=='" "T1" "eq"- $ \(eqAction:_) -> do+ , goldenWithClass "Creates a placeholder for '=='" "T1" "eq" $ \(eqAction:_) -> do executeCodeAction eqAction- , glodenTest "Creates a placeholder for '/='" "T1" "ne"- $ \(_:neAction:_) -> do+ , goldenWithClass "Creates a placeholder for '/='" "T1" "ne" $ \(_:neAction:_) -> do executeCodeAction neAction- , glodenTest "Creates a placeholder for 'fmap'" "T2" "fmap"- $ \(_:_:fmapAction:_) -> do+ , goldenWithClass "Creates a placeholder for 'fmap'" "T2" "fmap" $ \(_:_:fmapAction:_) -> do executeCodeAction fmapAction- , glodenTest "Creates a placeholder for multiple methods 1" "T3" "1"- $ \(mmAction:_) -> do+ , goldenWithClass "Creates a placeholder for multiple methods 1" "T3" "1" $ \(mmAction:_) -> do executeCodeAction mmAction- , glodenTest "Creates a placeholder for multiple methods 2" "T3" "2"- $ \(_:mmAction:_) -> do+ , goldenWithClass "Creates a placeholder for multiple methods 2" "T3" "2" $ \(_:mmAction:_) -> do executeCodeAction mmAction- , glodenTest "Creates a placeholder for a method starting with '_'" "T4" ""- $ \(_fAction:_) -> do+ , goldenWithClass "Creates a placeholder for a method starting with '_'" "T4" "" $ \(_fAction:_) -> do executeCodeAction _fAction ] @@ -59,20 +52,13 @@ InR action -> Just action _ -> Nothing -classPath :: FilePath-classPath = "test" </> "testdata"+goldenWithClass :: TestName -> FilePath -> FilePath -> ([CodeAction] -> Session ()) -> TestTree+goldenWithClass title path desc act =+ goldenWithHaskellDoc classPlugin title testDataDir path (desc <.> "expected") "hs" $ \doc -> do+ _ <- waitForDiagnosticsFromSource doc "typecheck"+ actions <- concatMap (^.. _CACodeAction) <$> getAllCodeActions doc+ act actions+ void $ skipManyTill anyMessage (getDocumentEdit doc) -glodenTest :: String -> FilePath -> FilePath -> ([CodeAction] -> Session ()) -> TestTree-glodenTest name fp deco execute- = goldenGitDiff name (classPath </> fpWithDeco <.> "expected" <.> "hs")- $ runSessionWithServer plugin classPath- $ do- doc <- openDoc (fp <.> "hs") "haskell"- _ <- waitForDiagnosticsFromSource doc "typecheck"- actions <- concatMap (^.. _CACodeAction) <$> getAllCodeActions doc- execute actions- BS.fromStrict . T.encodeUtf8 <$> skipManyTill anyMessage (getDocumentEdit doc)- where- fpWithDeco- | deco == "" = fp- | otherwise = fp <.> deco+testDataDir :: FilePath+testDataDir = "test" </> "testdata"