hls-tactics-plugin 1.6.1.0 → 1.6.2.0
raw patch · 11 files changed
+78/−19 lines, 11 filesdep ~ghcidedep ~hls-plugin-apidep ~hls-test-utilsnew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: ghcide, hls-plugin-api, hls-test-utils
API changes (from Hackage documentation)
+ Ide.Plugin.Tactic: LogWingmanLanguageServer :: Log -> Log
+ Ide.Plugin.Tactic: newtype Log
+ Wingman.LanguageServer: LogShake :: Log -> Log
+ Wingman.LanguageServer: instance GHC.Show.Show Wingman.LanguageServer.Log
+ Wingman.LanguageServer: instance Prettyprinter.Internal.Pretty Wingman.LanguageServer.Log
+ Wingman.LanguageServer: newtype Log
+ Wingman.Naming: illegalNames :: Set OccName
+ Wingman.Plugin: LogWingmanLanguageServer :: Log -> Log
+ Wingman.Plugin: instance GHC.Show.Show Wingman.Plugin.Log
+ Wingman.Plugin: instance Prettyprinter.Internal.Pretty Wingman.Plugin.Log
+ Wingman.Plugin: newtype Log
- Ide.Plugin.Tactic: descriptor :: PluginId -> PluginDescriptor IdeState
+ Ide.Plugin.Tactic: descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
- Wingman.LanguageServer: wingmanRules :: PluginId -> Rules ()
+ Wingman.LanguageServer: wingmanRules :: Recorder (WithPriority Log) -> PluginId -> Rules ()
- Wingman.Plugin: descriptor :: PluginId -> PluginDescriptor IdeState
+ Wingman.Plugin: descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
Files
- hls-tactics-plugin.cabal +4/−4
- src/Ide/Plugin/Tactic.hs +1/−1
- src/Wingman/Debug.hs +4/−2
- src/Wingman/Judgements.hs +2/−1
- src/Wingman/LanguageServer.hs +15/−5
- src/Wingman/Naming.hs +23/−1
- src/Wingman/Plugin.hs +13/−4
- test/CodeAction/DestructSpec.hs +1/−0
- test/Utils.hs +1/−1
- test/golden/DestructInt.expected.hs +7/−0
- test/golden/DestructInt.hs +7/−0
hls-tactics-plugin.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 category: Development name: hls-tactics-plugin-version: 1.6.1.0+version: 1.6.2.0 synopsis: Wingman plugin for Haskell Language Server description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -82,9 +82,9 @@ , ghc-boot-th , ghc-exactprint , ghc-source-gen ^>=0.4.1- , ghcide ^>=1.6+ , ghcide ^>=1.7 , hls-graph- , hls-plugin-api ^>=1.3+ , hls-plugin-api ^>=1.4 , hyphenation , lens , lsp@@ -160,7 +160,7 @@ , ghcide , hls-plugin-api , hls-tactics-plugin- , hls-test-utils ^>=1.2+ , hls-test-utils ^>=1.3 , hspec , hspec-expectations , lens
src/Ide/Plugin/Tactic.hs view
@@ -1,5 +1,5 @@ -- | A plugin that uses tactics to synthesize code-module Ide.Plugin.Tactic (descriptor) where+module Ide.Plugin.Tactic (descriptor, Log(..)) where import Wingman.Plugin
src/Wingman/Debug.hs view
@@ -18,8 +18,10 @@ import Control.DeepSeq import Control.Exception import Data.Either (fromRight)+import qualified Data.Text as T import qualified Debug.Trace-import Development.IDE.GHC.Compat (PlainGhcException, Outputable(..), SDoc, showSDocUnsafe)+import Development.IDE.GHC.Compat (PlainGhcException, Outputable(..), SDoc)+import Development.IDE.GHC.Util (printOutputable) import System.IO.Unsafe (unsafePerformIO) ------------------------------------------------------------------------------@@ -30,7 +32,7 @@ unsafeRender' :: SDoc -> String unsafeRender' sdoc = unsafePerformIO $ do- let z = showSDocUnsafe sdoc+ let z = T.unpack $ printOutputable sdoc -- We might not have unsafeGlobalDynFlags (like during testing), in which -- case GHC panics. Instead of crashing, let's just fail to print. !res <- try @PlainGhcException $ evaluate $ deepseq z z
src/Wingman/Judgements.hs view
@@ -34,7 +34,8 @@ where go (occName -> occ, t) | Just ty <- t- , isAlpha . head . occNameString $ occ = Just $ HyInfo occ UserPrv $ CType ty+ , (h:_) <- occNameString occ+ , isAlpha h = Just $ HyInfo occ UserPrv $ CType ty | otherwise = Nothing
src/Wingman/LanguageServer.hs view
@@ -36,7 +36,7 @@ import Development.IDE.GHC.Compat hiding (empty) import qualified Development.IDE.GHC.Compat.Util as FastString import Development.IDE.GHC.Error (realSrcSpanToRange)-import Development.IDE.GHC.ExactPrint+import Development.IDE.GHC.ExactPrint hiding (LogShake, Log) import Development.IDE.Graph (Action, RuleResult, Rules, action) import Development.IDE.Graph.Classes (Hashable, NFData) import Development.IDE.Spans.LocalBindings (Bindings, getDefiningBindings)@@ -63,8 +63,18 @@ import Wingman.Range import Wingman.StaticPlugin (pattern WingmanMetaprogram, pattern MetaprogramSyntax) import Wingman.Types+import Development.IDE.Types.Logger (Recorder, cmapWithPrio, WithPriority, Pretty (pretty))+import qualified Development.IDE.Core.Shake as Shake +newtype Log + = LogShake Shake.Log+ deriving Show++instance Pretty Log where+ pretty = \case + LogShake shakeLog -> pretty shakeLog+ tacticDesc :: T.Text -> T.Text tacticDesc name = "fill the hole using the " <> name <> " tactic" @@ -550,9 +560,9 @@ type instance RuleResult GetMetaprograms = [(Tracked 'Current RealSrcSpan, T.Text)] -wingmanRules :: PluginId -> Rules ()-wingmanRules plId = do- define $ \WriteDiagnostics nfp ->+wingmanRules :: Recorder (WithPriority Log) -> PluginId -> Rules ()+wingmanRules recorder plId = do+ define (cmapWithPrio LogShake recorder) $ \WriteDiagnostics nfp -> usePropertyAction #hole_severity plId properties >>= \case Nothing -> pure (mempty, Just ()) Just severity ->@@ -585,7 +595,7 @@ , Just () ) - defineNoDiagnostics $ \GetMetaprograms nfp -> do+ defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \GetMetaprograms nfp -> do TrackedStale tcg tcg_map <- fmap tmrTypechecked <$> useWithStale_ TypeCheck nfp let scrutinees = traverse (metaprogramQ . tcg_binds) tcg return $ Just $ flip mapMaybe scrutinees $ \aged@(unTrack -> (ss, program)) -> do
src/Wingman/Naming.hs view
@@ -220,7 +220,29 @@ . foldMap (\n -> bool (pure n) mempty $ check n) $ tn <> fmap (<> "'") tn where- check n = S.member (mkVarOcc n) in_scope+ check n = S.member (mkVarOcc n) $ illegalNames <> in_scope+++illegalNames :: Set OccName+illegalNames = S.fromList $ fmap mkVarOcc+ [ "case"+ , "of"+ , "class"+ , "data"+ , "do"+ , "type"+ , "if"+ , "then"+ , "else"+ , "let"+ , "in"+ , "mdo"+ , "newtype"+ , "proc"+ , "rec"+ , "where"+ ]+ ------------------------------------------------------------------------------
src/Wingman/Plugin.hs view
@@ -9,20 +9,29 @@ import Wingman.AbstractLSP import Wingman.AbstractLSP.TacticActions (makeTacticInteraction) import Wingman.EmptyCase-import Wingman.LanguageServer+import Wingman.LanguageServer hiding (Log)+import qualified Wingman.LanguageServer as WingmanLanguageServer import Wingman.LanguageServer.Metaprogram (hoverProvider) import Wingman.StaticPlugin+import Development.IDE.Types.Logger (Recorder, cmapWithPrio, WithPriority, Pretty (pretty)) +newtype Log+ = LogWingmanLanguageServer WingmanLanguageServer.Log + deriving Show -descriptor :: PluginId -> PluginDescriptor IdeState-descriptor plId+instance Pretty Log where+ pretty = \case+ LogWingmanLanguageServer log -> pretty log++descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState+descriptor recorder plId = installInteractions ( emptyCaseInteraction : fmap makeTacticInteraction [minBound .. maxBound] ) $ (defaultPluginDescriptor plId) { pluginHandlers = mkPluginHandler STextDocumentHover hoverProvider- , pluginRules = wingmanRules plId+ , pluginRules = wingmanRules (cmapWithPrio LogWingmanLanguageServer recorder) plId , pluginConfigDescriptor = defaultConfigDescriptor { configCustomConfig = mkCustomConfig properties
test/CodeAction/DestructSpec.hs view
@@ -20,6 +20,7 @@ destructTest "b" 7 10 "DestructTyFam" destructTest "b" 7 10 "DestructDataFam" destructTest "b" 17 10 "DestructTyToDataFam"+ destructTest "t" 6 10 "DestructInt" describe "layout" $ do destructTest "b" 4 3 "LayoutBind"
test/Utils.hs view
@@ -35,7 +35,7 @@ plugin :: PluginDescriptor IdeState-plugin = Tactic.descriptor "tactics"+plugin = Tactic.descriptor mempty "tactics" ------------------------------------------------------------------------------ -- | Get a range at the given line and column corresponding to having nothing
+ test/golden/DestructInt.expected.hs view
@@ -0,0 +1,7 @@+import Data.Int++data Test = Test Int32++test :: Test -> Int32+test (Test in') = _w0+
+ test/golden/DestructInt.hs view
@@ -0,0 +1,7 @@+import Data.Int++data Test = Test Int32++test :: Test -> Int32+test t = _+