From ee99ab4d6af1383429e189eafb131db0ca4b3f2d Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sun, 5 May 2019 20:41:56 +0200 Subject: [PATCH 1/9] Explicitly list everything from ghc-mod-core that is actually used --- .../Haskell/Ide/Engine/ArtifactMap.hs | 2 +- hie-plugin-api/Haskell/Ide/Engine/Ghc.hs | 18 +++++++++--------- .../Haskell/Ide/Engine/GhcModuleCache.hs | 2 +- .../Haskell/Ide/Engine/ModuleCache.hs | 8 ++++---- .../Haskell/Ide/Engine/PluginUtils.hs | 2 +- .../Haskell/Ide/Engine/PluginsIdeMonads.hs | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs b/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs index 8e45e6a6c..4f98994bf 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs @@ -9,7 +9,7 @@ import qualified GHC import GHC (TypecheckedModule) import qualified SrcLoc as GHC import qualified Var -import qualified GhcMod.Gap as GM +import qualified GhcMod.Gap as GM ( GhcRn, GhcTc, GhcPs ) import Language.Haskell.LSP.Types diff --git a/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs b/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs index 569613f41..2ddacb90b 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs @@ -21,18 +21,18 @@ import Bag import Control.Monad.IO.Class import Data.IORef import qualified Data.Map.Strict as Map +import Data.Monoid ((<>)) import qualified Data.Set as Set import qualified Data.Text as T import ErrUtils -import qualified GhcMod.DynFlags as GM -import qualified GhcMod.Error as GM -import qualified GhcMod.Gap as GM -import qualified GhcMod.ModuleLoader as GM -import qualified GhcMod.Monad as GM -import Data.Monoid ((<>)) -import qualified GhcMod.Target as GM -import qualified GhcMod.Types as GM -import qualified GhcMod.Utils as GM +import qualified GhcMod.DynFlags as GM ( withDynFlags ) +import qualified GhcMod.Error as GM ( gcatches, GHandler(..), ghcExceptionDoc ) +import qualified GhcMod.Gap as GM ( mkErrStyle', renderGm ) +import qualified GhcMod.ModuleLoader as GM ( getModulesGhc' ) +import qualified GhcMod.Monad as GM ( GmlT(..), getMMappedFiles, GmState(..), GhcModT, cradle ) +import qualified GhcMod.Target as GM ( cabalResolvedComponents ) +import qualified GhcMod.Types as GM ( IOish, GhcModError(..), GmGhcSession(..), GhcModState(..), GmModuleGraph(..), Cradle(..), gmcHomeModuleGraph ) +import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) import Haskell.Ide.Engine.MonadFunctions import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.PluginUtils diff --git a/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs index c56a4ca67..034d59e93 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs @@ -8,7 +8,7 @@ import qualified Data.Map as Map import Data.Dynamic (Dynamic) import Data.Typeable (TypeRep) -import qualified GhcMod.Types as GM +import qualified GhcMod.Types as GM ( Cradle(..) ) import GHC (TypecheckedModule, ParsedModule) diff --git a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs index 9c984a247..1d756c87b 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs @@ -35,10 +35,10 @@ import Exception (ExceptionMonad) import System.Directory import System.FilePath -import qualified GhcMod.Cradle as GM -import qualified GhcMod.Monad as GM -import qualified GhcMod.Types as GM -import qualified GhcMod.Utils as GM +import qualified GhcMod.Cradle as GM ( findCradle' ) +import qualified GhcMod.Monad as GM ( GmEnv(..), GmLog(..), GmlT(..), GmOut(..), cradle, options ) +import qualified GhcMod.Types as GM ( Cradle(..), GhcModEnv(..), MonadIO(..), Options(..) ) +import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) import qualified GHC as GHC import Haskell.Ide.Engine.ArtifactMap diff --git a/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs b/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs index 6648294ef..0c4f21ed2 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs @@ -45,7 +45,7 @@ import Data.Monoid import qualified Data.Text as T import qualified Data.Text.IO as T import Data.Maybe -import qualified GhcMod.Utils as GM +import qualified GhcMod.Utils as GM ( makeAbsolute' ) import FastString import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.MonadFunctions diff --git a/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs b/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs index 53e873b5f..b2b52bb91 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs @@ -117,8 +117,8 @@ import Data.Typeable ( TypeRep , Typeable ) -import qualified GhcMod.Monad as GM -import qualified GhcMod.Types as GM +import qualified GhcMod.Monad as GM ( GhcModT, runGhcModT, GmlT(..), gmlGetSession, gmlSetSession ) +import qualified GhcMod.Types as GM ( MonadIO(..), GmLogLevel(..), Options(..), defaultOptions, OutputOpts(..) ) import GHC.Generics import GHC ( HscEnv ) import qualified DynFlags as GHC From 96d99e3713ab028e70138b383608d8fcfc14eacb Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Wed, 8 May 2019 23:51:15 +0200 Subject: [PATCH 2/9] WIP on thinning the ghc-mod API to just what HIE uses --- .../Haskell/Ide/Engine/ArtifactMap.hs | 3 ++- hie-plugin-api/Haskell/Ide/Engine/Context.hs | 7 ++--- hie-plugin-api/Haskell/Ide/Engine/Ghc.hs | 27 +++++++++++++------ .../Haskell/Ide/Engine/GhcModuleCache.hs | 3 ++- .../Haskell/Ide/Engine/ModuleCache.hs | 14 +++++++--- .../Haskell/Ide/Engine/PluginUtils.hs | 3 ++- .../Haskell/Ide/Engine/PluginsIdeMonads.hs | 8 ++++-- src/Haskell/Ide/Engine/Plugin/HaRe.hs | 7 +++-- src/Haskell/Ide/Engine/Support/HieExtras.hs | 18 +++++++++---- submodules/ghc-mod | 2 +- 10 files changed, 64 insertions(+), 28 deletions(-) diff --git a/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs b/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs index 4f98994bf..41c8dc5d3 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs @@ -9,7 +9,8 @@ import qualified GHC import GHC (TypecheckedModule) import qualified SrcLoc as GHC import qualified Var -import qualified GhcMod.Gap as GM ( GhcRn, GhcTc, GhcPs ) +-- import qualified GhcMod.Gap as GM ( GhcRn, GhcTc, GhcPs ) +import qualified GhcModCore as GM ( GhcRn, GhcTc, GhcPs ) import Language.Haskell.LSP.Types diff --git a/hie-plugin-api/Haskell/Ide/Engine/Context.hs b/hie-plugin-api/Haskell/Ide/Engine/Context.hs index 5780f68cf..ef256c1fa 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Context.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Context.hs @@ -3,7 +3,8 @@ module Haskell.Ide.Engine.Context where import Data.Generics import Language.Haskell.LSP.Types import GHC -import GhcMod.Gap (GhcPs) -- for GHC 8.2.2 +-- import qualified GhcMod.Gap as GM (GhcPs) -- for GHC 8.2.2 +import qualified GhcModCore as GM (GhcPs) -- for GHC 8.2.2 import Haskell.Ide.Engine.PluginUtils -- | A context of a declaration in the program @@ -20,7 +21,7 @@ data Context = TypeContext getContext :: Position -> ParsedModule -> Maybe Context getContext pos pm = everything join (Nothing `mkQ` go `extQ` goInline) decl where decl = hsmodDecls $ unLoc $ pm_parsed_source pm - go :: LHsDecl GhcPs -> Maybe Context + go :: LHsDecl GM.GhcPs -> Maybe Context go (L (RealSrcSpan r) (SigD {})) | pos `isInsideRange` r = Just TypeContext | otherwise = Nothing @@ -28,7 +29,7 @@ getContext pos pm = everything join (Nothing `mkQ` go `extQ` goInline) decl | pos `isInsideRange` r = Just ValueContext | otherwise = Nothing go _ = Nothing - goInline :: GHC.LHsType GhcPs -> Maybe Context + goInline :: GHC.LHsType GM.GhcPs -> Maybe Context goInline (GHC.L (GHC.RealSrcSpan r) _) | pos `isInsideRange` r = Just TypeContext | otherwise = Nothing diff --git a/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs b/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs index 2ddacb90b..8d7f5d2ba 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs @@ -25,14 +25,25 @@ import Data.Monoid ((<>)) import qualified Data.Set as Set import qualified Data.Text as T import ErrUtils -import qualified GhcMod.DynFlags as GM ( withDynFlags ) -import qualified GhcMod.Error as GM ( gcatches, GHandler(..), ghcExceptionDoc ) -import qualified GhcMod.Gap as GM ( mkErrStyle', renderGm ) -import qualified GhcMod.ModuleLoader as GM ( getModulesGhc' ) -import qualified GhcMod.Monad as GM ( GmlT(..), getMMappedFiles, GmState(..), GhcModT, cradle ) -import qualified GhcMod.Target as GM ( cabalResolvedComponents ) -import qualified GhcMod.Types as GM ( IOish, GhcModError(..), GmGhcSession(..), GhcModState(..), GmModuleGraph(..), Cradle(..), gmcHomeModuleGraph ) -import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) + +-- import qualified GhcMod.DynFlags as GM ( withDynFlags ) +-- import qualified GhcMod.Error as GM ( gcatches, GHandler(..), ghcExceptionDoc ) +-- import qualified GhcMod.Gap as GM ( mkErrStyle', renderGm ) +-- import qualified GhcMod.ModuleLoader as GM ( getModulesGhc' ) +-- import qualified GhcMod.Monad as GM ( GmlT(..), getMMappedFiles, GmState(..), GhcModT, cradle ) +-- import qualified GhcMod.Target as GM ( cabalResolvedComponents ) +-- import qualified GhcMod.Types as GM ( IOish, GhcModError(..), GmGhcSession(..), GhcModState(..), GmModuleGraph(..), Cradle(..), gmcHomeModuleGraph ) +-- import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) + +import qualified GhcModCore as GM ( withDynFlags + , gcatches, GHandler(..), ghcExceptionDoc + , mkErrStyle', renderGm + , getModulesGhc' + , GmlT(..), getMMappedFiles, GmState(..), GhcModT, cradle + , cabalResolvedComponents + , IOish, GhcModError(..), GmGhcSession(..), GhcModState(..), GmModuleGraph(..), Cradle(..), gmcHomeModuleGraph + , mkRevRedirMapFunc ) + import Haskell.Ide.Engine.MonadFunctions import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.PluginUtils diff --git a/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs index 034d59e93..716c2f3f2 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs @@ -8,7 +8,8 @@ import qualified Data.Map as Map import Data.Dynamic (Dynamic) import Data.Typeable (TypeRep) -import qualified GhcMod.Types as GM ( Cradle(..) ) +-- import qualified GhcMod.Types as GM ( Cradle(..) ) +import qualified GhcModCore as GM ( Cradle(..) ) import GHC (TypecheckedModule, ParsedModule) diff --git a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs index 1d756c87b..4ea50675f 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs @@ -35,10 +35,16 @@ import Exception (ExceptionMonad) import System.Directory import System.FilePath -import qualified GhcMod.Cradle as GM ( findCradle' ) -import qualified GhcMod.Monad as GM ( GmEnv(..), GmLog(..), GmlT(..), GmOut(..), cradle, options ) -import qualified GhcMod.Types as GM ( Cradle(..), GhcModEnv(..), MonadIO(..), Options(..) ) -import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) +-- import qualified GhcMod.Cradle as GM ( findCradle' ) +-- import qualified GhcMod.Monad as GM ( GmEnv(..), GmLog(..), GmlT(..), GmOut(..), cradle, options ) +-- import qualified GhcMod.Types as GM ( Cradle(..), GhcModEnv(..), MonadIO(..), Options(..) ) +-- import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) + +import qualified GhcModCore as GM ( findCradle' + , GmEnv(..), GmLog(..), GmlT(..), GmOut(..), cradle, options + , Cradle(..), GhcModEnv(..), MonadIO(..), Options(..) + , mkRevRedirMapFunc ) + import qualified GHC as GHC import Haskell.Ide.Engine.ArtifactMap diff --git a/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs b/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs index c049c6f92..eaeea6eb8 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs @@ -45,7 +45,8 @@ import Data.Monoid import qualified Data.Text as T import qualified Data.Text.IO as T import Data.Maybe -import qualified GhcMod.Utils as GM ( makeAbsolute' ) +-- import qualified GhcMod.Utils as GM ( makeAbsolute' ) +import qualified GhcModCore as GM ( makeAbsolute' ) import FastString import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.MonadFunctions diff --git a/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs b/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs index b2b52bb91..5f9e5a15d 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs @@ -117,8 +117,12 @@ import Data.Typeable ( TypeRep , Typeable ) -import qualified GhcMod.Monad as GM ( GhcModT, runGhcModT, GmlT(..), gmlGetSession, gmlSetSession ) -import qualified GhcMod.Types as GM ( MonadIO(..), GmLogLevel(..), Options(..), defaultOptions, OutputOpts(..) ) +-- import qualified GhcMod.Monad as GM ( GhcModT, runGhcModT, GmlT(..), gmlGetSession, gmlSetSession ) +-- import qualified GhcMod.Types as GM ( MonadIO(..), GmLogLevel(..), Options(..), defaultOptions, OutputOpts(..) ) + +import qualified GhcModCore as GM ( GhcModT, runGhcModT, GmlT(..), gmlGetSession, gmlSetSession + , MonadIO(..), GmLogLevel(..), Options(..), defaultOptions, OutputOpts(..) ) + import GHC.Generics import GHC ( HscEnv ) import qualified DynFlags as GHC diff --git a/src/Haskell/Ide/Engine/Plugin/HaRe.hs b/src/Haskell/Ide/Engine/Plugin/HaRe.hs index 0c9988382..b8392330e 100644 --- a/src/Haskell/Ide/Engine/Plugin/HaRe.hs +++ b/src/Haskell/Ide/Engine/Plugin/HaRe.hs @@ -21,8 +21,11 @@ import qualified Data.Text as T import qualified Data.Text.IO as T import Exception import GHC.Generics (Generic) -import qualified GhcMod.Error as GM -import qualified GhcMod.Utils as GM +-- import qualified GhcMod.Error as GM +-- import qualified GhcMod.Utils as GM + +import qualified GhcModCore as GM (GhcModError(..),withMappedFile,GHandler(..),gcatches) + import Haskell.Ide.Engine.ArtifactMap import Haskell.Ide.Engine.MonadFunctions import Haskell.Ide.Engine.MonadTypes diff --git a/src/Haskell/Ide/Engine/Support/HieExtras.hs b/src/Haskell/Ide/Engine/Support/HieExtras.hs index 844642058..eea0abcab 100644 --- a/src/Haskell/Ide/Engine/Support/HieExtras.hs +++ b/src/Haskell/Ide/Engine/Support/HieExtras.hs @@ -50,11 +50,19 @@ import FastString import Finder import GHC hiding (getContext) import GHC.Generics (Generic) -import qualified GhcMod.Error as GM -import qualified GhcMod.Exe.CaseSplit as GM -import qualified GhcMod.Gap as GM -import qualified GhcMod.LightGhc as GM -import qualified GhcMod.Utils as GM +-- import qualified GhcMod.Error as GM +-- import qualified GhcMod.Exe.CaseSplit as GM +-- import qualified GhcMod.Gap as GM +-- import qualified GhcMod.LightGhc as GM +-- import qualified GhcMod.Utils as GM + +import qualified GhcMod.Error as GM () +import qualified GhcMod.Exe.CaseSplit as GM (splits',SplitResult(..)) +import qualified GhcMod.Gap as GM (listVisibleModuleNames) +import qualified GhcMod.LightGhc as GM (runLightGhc) +import qualified GhcMod.Utils as GM (withMappedFile) +import qualified GhcModCore as GM (GhcModError(..)) + import Haskell.Ide.Engine.ArtifactMap import Haskell.Ide.Engine.Config import Haskell.Ide.Engine.Context diff --git a/submodules/ghc-mod b/submodules/ghc-mod index 17403cede..c03553acf 160000 --- a/submodules/ghc-mod +++ b/submodules/ghc-mod @@ -1 +1 @@ -Subproject commit 17403cedeaa85e5d78d548afc95e1467cc3f5720 +Subproject commit c03553acf2dd4cc8806b6cfc735397141929a512 From 0b2cdf504303e510cdea8153352a6f4ab9c67a5b Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 9 May 2019 22:22:03 +0200 Subject: [PATCH 3/9] More thinning of ghc-mod api --- app/HieWrapper.hs | 1 + hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs | 1 - hie-plugin-api/Haskell/Ide/Engine/Context.hs | 1 - hie-plugin-api/Haskell/Ide/Engine/Ghc.hs | 9 --------- .../Haskell/Ide/Engine/GhcModuleCache.hs | 1 - hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs | 5 ----- hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs | 1 - .../Haskell/Ide/Engine/PluginsIdeMonads.hs | 3 --- src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs | 2 +- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 7 +++---- src/Haskell/Ide/Engine/Plugin/HaRe.hs | 4 +--- src/Haskell/Ide/Engine/Plugin/Haddock.hs | 3 +-- src/Haskell/Ide/Engine/Plugin/HsImport.hs | 2 +- src/Haskell/Ide/Engine/Plugin/Package.hs | 2 +- src/Haskell/Ide/Engine/Scheduler.hs | 4 ++-- src/Haskell/Ide/Engine/Support/HieExtras.hs | 15 +++------------ src/Haskell/Ide/Engine/Transport/LspStdio.hs | 3 +-- submodules/ghc-mod | 2 +- 18 files changed, 16 insertions(+), 50 deletions(-) diff --git a/app/HieWrapper.hs b/app/HieWrapper.hs index 0ddc46dac..12972a3c9 100644 --- a/app/HieWrapper.hs +++ b/app/HieWrapper.hs @@ -10,6 +10,7 @@ import Data.List import Data.Foldable import Data.Version (showVersion) import qualified GhcMod.Monad as GM +import qualified GhcMod.Monad.Types as GM import qualified GhcMod.Types as GM import Haskell.Ide.Engine.MonadFunctions import Haskell.Ide.Engine.Options diff --git a/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs b/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs index 41c8dc5d3..95815811e 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs @@ -9,7 +9,6 @@ import qualified GHC import GHC (TypecheckedModule) import qualified SrcLoc as GHC import qualified Var --- import qualified GhcMod.Gap as GM ( GhcRn, GhcTc, GhcPs ) import qualified GhcModCore as GM ( GhcRn, GhcTc, GhcPs ) import Language.Haskell.LSP.Types diff --git a/hie-plugin-api/Haskell/Ide/Engine/Context.hs b/hie-plugin-api/Haskell/Ide/Engine/Context.hs index ef256c1fa..410410f7f 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Context.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Context.hs @@ -3,7 +3,6 @@ module Haskell.Ide.Engine.Context where import Data.Generics import Language.Haskell.LSP.Types import GHC --- import qualified GhcMod.Gap as GM (GhcPs) -- for GHC 8.2.2 import qualified GhcModCore as GM (GhcPs) -- for GHC 8.2.2 import Haskell.Ide.Engine.PluginUtils diff --git a/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs b/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs index 8d7f5d2ba..bfac52030 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Ghc.hs @@ -26,15 +26,6 @@ import qualified Data.Set as Set import qualified Data.Text as T import ErrUtils --- import qualified GhcMod.DynFlags as GM ( withDynFlags ) --- import qualified GhcMod.Error as GM ( gcatches, GHandler(..), ghcExceptionDoc ) --- import qualified GhcMod.Gap as GM ( mkErrStyle', renderGm ) --- import qualified GhcMod.ModuleLoader as GM ( getModulesGhc' ) --- import qualified GhcMod.Monad as GM ( GmlT(..), getMMappedFiles, GmState(..), GhcModT, cradle ) --- import qualified GhcMod.Target as GM ( cabalResolvedComponents ) --- import qualified GhcMod.Types as GM ( IOish, GhcModError(..), GmGhcSession(..), GhcModState(..), GmModuleGraph(..), Cradle(..), gmcHomeModuleGraph ) --- import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) - import qualified GhcModCore as GM ( withDynFlags , gcatches, GHandler(..), ghcExceptionDoc , mkErrStyle', renderGm diff --git a/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs index 716c2f3f2..9a6f8c380 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/GhcModuleCache.hs @@ -8,7 +8,6 @@ import qualified Data.Map as Map import Data.Dynamic (Dynamic) import Data.Typeable (TypeRep) --- import qualified GhcMod.Types as GM ( Cradle(..) ) import qualified GhcModCore as GM ( Cradle(..) ) import GHC (TypecheckedModule, ParsedModule) diff --git a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs index 4ea50675f..d23f975de 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs @@ -35,11 +35,6 @@ import Exception (ExceptionMonad) import System.Directory import System.FilePath --- import qualified GhcMod.Cradle as GM ( findCradle' ) --- import qualified GhcMod.Monad as GM ( GmEnv(..), GmLog(..), GmlT(..), GmOut(..), cradle, options ) --- import qualified GhcMod.Types as GM ( Cradle(..), GhcModEnv(..), MonadIO(..), Options(..) ) --- import qualified GhcMod.Utils as GM ( mkRevRedirMapFunc ) - import qualified GhcModCore as GM ( findCradle' , GmEnv(..), GmLog(..), GmlT(..), GmOut(..), cradle, options , Cradle(..), GhcModEnv(..), MonadIO(..), Options(..) diff --git a/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs b/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs index eaeea6eb8..557ec615a 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs @@ -45,7 +45,6 @@ import Data.Monoid import qualified Data.Text as T import qualified Data.Text.IO as T import Data.Maybe --- import qualified GhcMod.Utils as GM ( makeAbsolute' ) import qualified GhcModCore as GM ( makeAbsolute' ) import FastString import Haskell.Ide.Engine.MonadTypes diff --git a/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs b/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs index 5f9e5a15d..0be920042 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs @@ -117,9 +117,6 @@ import Data.Typeable ( TypeRep , Typeable ) --- import qualified GhcMod.Monad as GM ( GhcModT, runGhcModT, GmlT(..), gmlGetSession, gmlSetSession ) --- import qualified GhcMod.Types as GM ( MonadIO(..), GmLogLevel(..), Options(..), defaultOptions, OutputOpts(..) ) - import qualified GhcModCore as GM ( GhcModT, runGhcModT, GmlT(..), gmlGetSession, gmlSetSession , MonadIO(..), GmLogLevel(..), Options(..), defaultOptions, OutputOpts(..) ) diff --git a/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs b/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs index c57eb5687..dafc79313 100644 --- a/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs +++ b/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs @@ -19,7 +19,7 @@ import Data.Maybe import Data.Monoid ((<>)) import qualified Data.Text as T import GHC.Generics -import qualified GhcMod.Utils as GM +import qualified GhcModCore as GM ( mkRevRedirMapFunc, withMappedFile ) import Haskell.Ide.Engine.MonadFunctions import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.PluginUtils diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index 8eb1efff1..78186a983 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -37,10 +37,8 @@ import Data.Monoid ((<>)) import qualified Data.Text as T import Name import GHC.Generics -import qualified GhcMod as GM -import qualified GhcMod.Gap as GM -import qualified GhcMod.SrcUtils as GM -import qualified GhcMod.Types as GM +import qualified GhcMod as GM ( lint, info ) +import qualified GhcModCore as GM ( defaultLintOpts, Expression(..), pretty, defaultLintOpts, Expression(..), GhcPs ) import Haskell.Ide.Engine.Ghc import Haskell.Ide.Engine.MonadTypes hiding (defaultOptions) import Haskell.Ide.Engine.PluginUtils @@ -89,6 +87,7 @@ checkCmd = CmdSync setTypecheckedModule lintCmd :: CommandFunc Uri T.Text lintCmd = CmdSync lintCmd' +-- TODO:AZ why are we not calling hlint directly? lintCmd' :: Uri -> IdeGhcM (IdeResult T.Text) lintCmd' uri = pluginGetFile "lint: " uri $ \file -> diff --git a/src/Haskell/Ide/Engine/Plugin/HaRe.hs b/src/Haskell/Ide/Engine/Plugin/HaRe.hs index b8392330e..d5c02bb52 100644 --- a/src/Haskell/Ide/Engine/Plugin/HaRe.hs +++ b/src/Haskell/Ide/Engine/Plugin/HaRe.hs @@ -21,10 +21,8 @@ import qualified Data.Text as T import qualified Data.Text.IO as T import Exception import GHC.Generics (Generic) --- import qualified GhcMod.Error as GM --- import qualified GhcMod.Utils as GM -import qualified GhcModCore as GM (GhcModError(..),withMappedFile,GHandler(..),gcatches) +import qualified GhcModCore as GM (GhcModError(..),withMappedFile,GHandler(..),gcatches) import Haskell.Ide.Engine.ArtifactMap import Haskell.Ide.Engine.MonadFunctions diff --git a/src/Haskell/Ide/Engine/Plugin/Haddock.hs b/src/Haskell/Ide/Engine/Plugin/Haddock.hs index eb0620922..7cbefc3cb 100644 --- a/src/Haskell/Ide/Engine/Plugin/Haddock.hs +++ b/src/Haskell/Ide/Engine/Plugin/Haddock.hs @@ -18,8 +18,7 @@ import Data.Function import Data.Maybe import Data.List import GHC -import qualified GhcMod.LightGhc as GM -import qualified GhcMod.Monad as GM +import qualified GhcModCore as GM ( LightGhc(..), runLightGhc ) import GhcMonad import Haskell.Ide.Engine.MonadFunctions import Haskell.Ide.Engine.MonadTypes diff --git a/src/Haskell/Ide/Engine/Plugin/HsImport.hs b/src/Haskell/Ide/Engine/Plugin/HsImport.hs index aff815917..1737e66f9 100644 --- a/src/Haskell/Ide/Engine/Plugin/HsImport.hs +++ b/src/Haskell/Ide/Engine/Plugin/HsImport.hs @@ -17,7 +17,7 @@ import Data.Monoid ( (<>) ) import qualified Data.Text as T import qualified Data.Text.IO as T import qualified GHC.Generics as Generics -import qualified GhcMod.Utils as GM +import qualified GhcModCore as GM ( mkRevRedirMapFunc, withMappedFile ) import HsImport import Haskell.Ide.Engine.Config import Haskell.Ide.Engine.MonadTypes diff --git a/src/Haskell/Ide/Engine/Plugin/Package.hs b/src/Haskell/Ide/Engine/Plugin/Package.hs index fa3e5b747..767c38eed 100644 --- a/src/Haskell/Ide/Engine/Plugin/Package.hs +++ b/src/Haskell/Ide/Engine/Plugin/Package.hs @@ -44,7 +44,7 @@ import System.FilePath #endif import Control.Monad.IO.Class import System.Directory -import qualified GhcMod.Utils as GM +import qualified GhcModCore as GM ( mkRevRedirMapFunc ) import Distribution.Types.GenericPackageDescription import Distribution.Types.CondTree import qualified Distribution.PackageDescription.PrettyPrint as PP diff --git a/src/Haskell/Ide/Engine/Scheduler.hs b/src/Haskell/Ide/Engine/Scheduler.hs index d3de638ea..89e7b7717 100644 --- a/src/Haskell/Ide/Engine/Scheduler.hs +++ b/src/Haskell/Ide/Engine/Scheduler.hs @@ -32,7 +32,6 @@ import Control.Monad import qualified Data.Set as Set import qualified Data.Map as Map import qualified Data.Text as T -import qualified GhcMod.Types as GM import qualified Language.Haskell.LSP.Core as Core import qualified Language.Haskell.LSP.Types as J @@ -348,7 +347,8 @@ ghcDispatcher env@DispatcherEnv { docVersionTVar } errorHandler callbackHandler -- | Runs the passed monad only if the request identified by the passed LspId -- has not already been cancelled. unlessCancelled - :: GM.MonadIO m => DispatcherEnv -> J.LspId -> ErrorHandler -> m () -> m () + -- :: GM.MonadIO m => DispatcherEnv -> J.LspId -> ErrorHandler -> m () -> m () + :: MonadIO m => DispatcherEnv -> J.LspId -> ErrorHandler -> m () -> m () unlessCancelled env lid errorHandler callback = do cancelled <- liftIO $ STM.atomically isCancelled if cancelled diff --git a/src/Haskell/Ide/Engine/Support/HieExtras.hs b/src/Haskell/Ide/Engine/Support/HieExtras.hs index eea0abcab..30aea954a 100644 --- a/src/Haskell/Ide/Engine/Support/HieExtras.hs +++ b/src/Haskell/Ide/Engine/Support/HieExtras.hs @@ -50,18 +50,9 @@ import FastString import Finder import GHC hiding (getContext) import GHC.Generics (Generic) --- import qualified GhcMod.Error as GM --- import qualified GhcMod.Exe.CaseSplit as GM --- import qualified GhcMod.Gap as GM --- import qualified GhcMod.LightGhc as GM --- import qualified GhcMod.Utils as GM - -import qualified GhcMod.Error as GM () -import qualified GhcMod.Exe.CaseSplit as GM (splits',SplitResult(..)) -import qualified GhcMod.Gap as GM (listVisibleModuleNames) -import qualified GhcMod.LightGhc as GM (runLightGhc) -import qualified GhcMod.Utils as GM (withMappedFile) -import qualified GhcModCore as GM (GhcModError(..)) + +import qualified GhcMod as GM (splits',SplitResult(..)) +import qualified GhcModCore as GM (GhcModError(..), listVisibleModuleNames,runLightGhc, withMappedFile ) import Haskell.Ide.Engine.ArtifactMap import Haskell.Ide.Engine.Config diff --git a/src/Haskell/Ide/Engine/Transport/LspStdio.hs b/src/Haskell/Ide/Engine/Transport/LspStdio.hs index 8a60d0b84..a993c7a3c 100644 --- a/src/Haskell/Ide/Engine/Transport/LspStdio.hs +++ b/src/Haskell/Ide/Engine/Transport/LspStdio.hs @@ -38,8 +38,7 @@ import qualified Data.Set as S import qualified Data.SortedList as SL import qualified Data.Text as T import Data.Text.Encoding -import qualified GhcMod.Monad.Types as GM -import qualified GhcModCore as GM +import qualified GhcModCore as GM ( loadMappedFileSource, getMMappedFiles ) import Haskell.Ide.Engine.Config import qualified Haskell.Ide.Engine.Ghc as HIE import Haskell.Ide.Engine.LSP.CodeActions diff --git a/submodules/ghc-mod b/submodules/ghc-mod index c03553acf..83e607ac8 160000 --- a/submodules/ghc-mod +++ b/submodules/ghc-mod @@ -1 +1 @@ -Subproject commit c03553acf2dd4cc8806b6cfc735397141929a512 +Subproject commit 83e607ac8ec8137c280e9d1a81d2d1b93fb2ed8e From 6c56b1b3c9442f58f945374386b4824a7611a3ae Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 9 May 2019 23:29:38 +0200 Subject: [PATCH 4/9] Use even slimmer ghc-mod --- submodules/ghc-mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/ghc-mod b/submodules/ghc-mod index 83e607ac8..d7196637c 160000 --- a/submodules/ghc-mod +++ b/submodules/ghc-mod @@ -1 +1 @@ -Subproject commit 83e607ac8ec8137c280e9d1a81d2d1b93fb2ed8e +Subproject commit d7196637cc72bacbbf2e11921ecbb0a10a9ca09f From b31462aabbff784aaf0d8955ffd63ef4c014d6a2 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Fri, 10 May 2019 22:19:27 +0200 Subject: [PATCH 5/9] Narrowing --- haskell-ide-engine.cabal | 1 - src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs | 4 ++-- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 24 +++++++++++--------- submodules/ghc-mod | 2 +- test/unit/GhcModPluginSpec.hs | 23 ++++++++++--------- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/haskell-ide-engine.cabal b/haskell-ide-engine.cabal index c9bbc0cc8..a36f8747b 100644 --- a/haskell-ide-engine.cabal +++ b/haskell-ide-engine.cabal @@ -107,7 +107,6 @@ executable hie other-modules: Paths_haskell_ide_engine build-depends: base , directory - , ghc-mod-core , haskell-ide-engine , haskell-lsp , hie-plugin-api diff --git a/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs b/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs index dafc79313..3b7cd5e02 100644 --- a/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs +++ b/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs @@ -111,9 +111,9 @@ lintCmd = CmdSync $ \uri -> do -- AZ:TODO: Why is this in IdeGhcM? lintCmd' :: Uri -> IdeGhcM (IdeResult PublishDiagnosticsParams) lintCmd' uri = pluginGetFile "lintCmd: " uri $ \fp -> do - eitherErrorResult <- GM.withMappedFile fp $ \file' -> + eitherErrorResult <- GM.withMappedFile fp $ \file' -> liftIO (try $ runExceptT $ runLintCmd file' [] :: IO (Either IOException (Either [Diagnostic] [Idea]))) - + case eitherErrorResult of Left err -> return diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index 78186a983..4691ef547 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -22,7 +22,7 @@ module Haskell.Ide.Engine.Plugin.GhcMod , extractRenamableTerms , extractUnusedTerm , infoCmd' - , lintCmd' + -- , lintCmd' , newTypeCmd , symbolProvider ) where @@ -37,8 +37,10 @@ import Data.Monoid ((<>)) import qualified Data.Text as T import Name import GHC.Generics -import qualified GhcMod as GM ( lint, info ) -import qualified GhcModCore as GM ( defaultLintOpts, Expression(..), pretty, defaultLintOpts, Expression(..), GhcPs ) +-- import qualified GhcMod as GM ( lint, info ) +import qualified GhcMod as GM ( info ) +-- import qualified GhcModCore as GM ( defaultLintOpts, Expression(..), pretty, defaultLintOpts, Expression(..), GhcPs ) +import qualified GhcModCore as GM ( Expression(..), pretty, Expression(..), GhcPs ) import Haskell.Ide.Engine.Ghc import Haskell.Ide.Engine.MonadTypes hiding (defaultOptions) import Haskell.Ide.Engine.PluginUtils @@ -65,7 +67,7 @@ ghcmodDescriptor plId = PluginDescriptor <> "from modern IDEs in any editor." , pluginCommands = [ PluginCommand "check" "check a file for GHC warnings and errors" checkCmd - , PluginCommand "lint" "Check files using `hlint'" lintCmd + -- , PluginCommand "lint" "Check files using `hlint'" lintCmd , PluginCommand "info" "Look up an identifier in the context of FILE (like ghci's `:info')" infoCmd , PluginCommand "type" "Get the type of the expression under (LINE,COL)" typeCmd , PluginCommand "casesplit" "Generate a pattern match for a binding under (LINE,COL)" Hie.splitCaseCmd @@ -84,14 +86,14 @@ checkCmd = CmdSync setTypecheckedModule -- --------------------------------------------------------------------- -lintCmd :: CommandFunc Uri T.Text -lintCmd = CmdSync lintCmd' +-- lintCmd :: CommandFunc Uri T.Text +-- lintCmd = CmdSync lintCmd' --- TODO:AZ why are we not calling hlint directly? -lintCmd' :: Uri -> IdeGhcM (IdeResult T.Text) -lintCmd' uri = - pluginGetFile "lint: " uri $ \file -> - fmap T.pack <$> Hie.runGhcModCommand (GM.lint GM.defaultLintOpts file) +-- -- TODO:AZ why are we not calling hlint directly? +-- lintCmd' :: Uri -> IdeGhcM (IdeResult T.Text) +-- lintCmd' uri = +-- pluginGetFile "lint: " uri $ \file -> +-- fmap T.pack <$> Hie.runGhcModCommand (GM.lint GM.defaultLintOpts file) -- --------------------------------------------------------------------- diff --git a/submodules/ghc-mod b/submodules/ghc-mod index d7196637c..84a818261 160000 --- a/submodules/ghc-mod +++ b/submodules/ghc-mod @@ -1 +1 @@ -Subproject commit d7196637cc72bacbbf2e11921ecbb0a10a9ca09f +Subproject commit 84a818261a381129819493bf2bd1ade2f3d2f0d9 diff --git a/test/unit/GhcModPluginSpec.hs b/test/unit/GhcModPluginSpec.hs index 22877d0a4..590e6b287 100644 --- a/test/unit/GhcModPluginSpec.hs +++ b/test/unit/GhcModPluginSpec.hs @@ -9,7 +9,7 @@ import qualified Data.Map as Map import Data.Monoid #endif import qualified Data.Set as S -import qualified Data.Text as T +-- import qualified Data.Text as T import Haskell.Ide.Engine.Ghc import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.Plugin.GhcMod @@ -59,16 +59,17 @@ ghcmodSpec = -- --------------------------------- it "runs the lint command" $ withCurrentDirectory "./test/testdata" $ do - fp <- makeAbsolute "FileWithWarning.hs" - let uri = filePathToUri fp - act = lintCmd' uri - arg = uri -#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,2,2,0))) - res = IdeResultOk (T.pack fp <> ":6:9: Warning: Redundant do\NULFound:\NUL do return (3 + x)\NULPerhaps:\NUL return (3 + x)\n") -#else - res = IdeResultOk (T.pack fp <> ":6:9: Warning: Redundant do\NULFound:\NUL do return (3 + x)\NULWhy not:\NUL return (3 + x)\n") -#endif - testCommand testPlugins act "ghcmod" "lint" arg res + pendingWith "make sure we test this elsewhere" +-- fp <- makeAbsolute "FileWithWarning.hs" +-- let uri = filePathToUri fp +-- act = lintCmd' uri +-- arg = uri +-- #if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,2,2,0))) +-- res = IdeResultOk (T.pack fp <> ":6:9: Warning: Redundant do\NULFound:\NUL do return (3 + x)\NULPerhaps:\NUL return (3 + x)\n") +-- #else +-- res = IdeResultOk (T.pack fp <> ":6:9: Warning: Redundant do\NULFound:\NUL do return (3 + x)\NULWhy not:\NUL return (3 + x)\n") +-- #endif +-- testCommand testPlugins act "ghcmod" "lint" arg res -- --------------------------------- From 3e8c19ce815bca5f67d24728ac86e9b1fdadbd70 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 11 May 2019 13:27:44 +0200 Subject: [PATCH 6/9] Restore missing import in ghc-mod-core Gap.hs --- submodules/ghc-mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/ghc-mod b/submodules/ghc-mod index 84a818261..28371ff38 160000 --- a/submodules/ghc-mod +++ b/submodules/ghc-mod @@ -1 +1 @@ -Subproject commit 84a818261a381129819493bf2bd1ade2f3d2f0d9 +Subproject commit 28371ff38fbc227db722b768783a9274c14ecea7 From 151a845738bb8a90779c3884396737c11db05814 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 11 May 2019 14:23:11 +0200 Subject: [PATCH 7/9] Not currently using (<>), remove import --- test/unit/GhcModPluginSpec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/GhcModPluginSpec.hs b/test/unit/GhcModPluginSpec.hs index 590e6b287..6aa552b5f 100644 --- a/test/unit/GhcModPluginSpec.hs +++ b/test/unit/GhcModPluginSpec.hs @@ -6,7 +6,7 @@ import Control.Exception import qualified Data.HashMap.Strict as H import qualified Data.Map as Map #if __GLASGOW_HASKELL__ < 804 -import Data.Monoid +-- import Data.Monoid #endif import qualified Data.Set as S -- import qualified Data.Text as T From 2abdfabc7d5a3d5ac3ab0bb507931a9ba3a377e6 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 11 May 2019 17:41:10 +0200 Subject: [PATCH 8/9] Getting rid of lint and info GhcMod plugin commands --- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 43 +++++++++---------------- submodules/cabal-helper | 2 +- submodules/ghc-mod | 2 +- test/dispatcher/Main.hs | 2 +- test/unit/GhcModPluginSpec.hs | 17 +++++----- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index 4691ef547..7929e2416 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -21,8 +21,6 @@ module Haskell.Ide.Engine.Plugin.GhcMod , extractMissingSignature , extractRenamableTerms , extractUnusedTerm - , infoCmd' - -- , lintCmd' , newTypeCmd , symbolProvider ) where @@ -37,10 +35,7 @@ import Data.Monoid ((<>)) import qualified Data.Text as T import Name import GHC.Generics --- import qualified GhcMod as GM ( lint, info ) -import qualified GhcMod as GM ( info ) --- import qualified GhcModCore as GM ( defaultLintOpts, Expression(..), pretty, defaultLintOpts, Expression(..), GhcPs ) -import qualified GhcModCore as GM ( Expression(..), pretty, Expression(..), GhcPs ) +import qualified GhcModCore as GM ( pretty, GhcPs ) import Haskell.Ide.Engine.Ghc import Haskell.Ide.Engine.MonadTypes hiding (defaultOptions) import Haskell.Ide.Engine.PluginUtils @@ -66,10 +61,14 @@ ghcmodDescriptor plId = PluginDescriptor <> "in editors. It strives to offer most of the features one has come to expect " <> "from modern IDEs in any editor." , pluginCommands = - [ PluginCommand "check" "check a file for GHC warnings and errors" checkCmd - -- , PluginCommand "lint" "Check files using `hlint'" lintCmd - , PluginCommand "info" "Look up an identifier in the context of FILE (like ghci's `:info')" infoCmd + [ + -- This one is used in the dispatcher tests, and is a wrapper around what we are already using anyway + PluginCommand "check" "check a file for GHC warnings and errors" checkCmd + + -- PluginCommand "info" "Look up an identifier in the context of FILE (like ghci's `:info')" infoCmd , PluginCommand "type" "Get the type of the expression under (LINE,COL)" typeCmd + + -- This one is registered in the vscode plugin, for some reason , PluginCommand "casesplit" "Generate a pattern match for a binding under (LINE,COL)" Hie.splitCaseCmd ] , pluginCodeActionProvider = Just codeActionProvider @@ -86,17 +85,6 @@ checkCmd = CmdSync setTypecheckedModule -- --------------------------------------------------------------------- --- lintCmd :: CommandFunc Uri T.Text --- lintCmd = CmdSync lintCmd' - --- -- TODO:AZ why are we not calling hlint directly? --- lintCmd' :: Uri -> IdeGhcM (IdeResult T.Text) --- lintCmd' uri = --- pluginGetFile "lint: " uri $ \file -> --- fmap T.pack <$> Hie.runGhcModCommand (GM.lint GM.defaultLintOpts file) - --- --------------------------------------------------------------------- - customOptions :: Options customOptions = defaultOptions { fieldLabelModifier = camelTo2 '_' . drop 2} @@ -110,14 +98,14 @@ instance FromJSON InfoParams where instance ToJSON InfoParams where toJSON = genericToJSON customOptions -infoCmd :: CommandFunc InfoParams T.Text -infoCmd = CmdSync $ \(IP uri expr) -> - infoCmd' uri expr +-- infoCmd :: CommandFunc InfoParams T.Text +-- infoCmd = CmdSync $ \(IP uri expr) -> +-- infoCmd' uri expr -infoCmd' :: Uri -> T.Text -> IdeGhcM (IdeResult T.Text) -infoCmd' uri expr = - pluginGetFile "info: " uri $ \file -> - fmap T.pack <$> Hie.runGhcModCommand (GM.info file (GM.Expression (T.unpack expr))) +-- infoCmd' :: Uri -> T.Text -> IdeGhcM (IdeResult T.Text) +-- infoCmd' uri expr = +-- pluginGetFile "info: " uri $ \file -> +-- fmap T.pack <$> Hie.runGhcModCommand (GM.info file (GM.Expression (T.unpack expr))) -- --------------------------------------------------------------------- data TypeParams = @@ -135,6 +123,7 @@ typeCmd :: CommandFunc TypeParams [(Range,T.Text)] typeCmd = CmdSync $ \(TP _bool uri pos) -> liftToGhc $ newTypeCmd pos uri +-- AZ: currently only used in tests, but newTypeCmd :: Position -> Uri -> IdeM (IdeResult [(Range, T.Text)]) newTypeCmd newPos uri = pluginGetFile "newTypeCmd: " uri $ \fp -> diff --git a/submodules/cabal-helper b/submodules/cabal-helper index 754e60fbc..eafed5e8c 160000 --- a/submodules/cabal-helper +++ b/submodules/cabal-helper @@ -1 +1 @@ -Subproject commit 754e60fbce458ee4311a3ed59e5de6ee80f5a512 +Subproject commit eafed5e8c1d82b8daa35775b52361132f2e70261 diff --git a/submodules/ghc-mod b/submodules/ghc-mod index 28371ff38..43476965b 160000 --- a/submodules/ghc-mod +++ b/submodules/ghc-mod @@ -1 +1 @@ -Subproject commit 28371ff38fbc227db722b768783a9274c14ecea7 +Subproject commit 43476965b5d715f7fcdadd9e14d5e0c53cdb9385 diff --git a/test/dispatcher/Main.hs b/test/dispatcher/Main.hs index c7056ab99..4d8113363 100644 --- a/test/dispatcher/Main.hs +++ b/test/dispatcher/Main.hs @@ -166,7 +166,7 @@ funcSpec = describe "functional dispatch" $ do -- And now we get the deferred response (once the module is loaded) ("req1",Right res) <- atomically $ readTChan logChan let Just ds = fromDynJSON res :: Maybe [DocumentSymbol] - DocumentSymbol mainName _ mainKind _ mainRange _ _ = head ds + DocumentSymbol mainName _ mainKind _ mainRange _ _ = head ds mainName `shouldBe` "main" mainKind `shouldBe` SkFunction mainRange `shouldBe` Range (Position 2 0) (Position 2 23) diff --git a/test/unit/GhcModPluginSpec.hs b/test/unit/GhcModPluginSpec.hs index 6aa552b5f..0a413d652 100644 --- a/test/unit/GhcModPluginSpec.hs +++ b/test/unit/GhcModPluginSpec.hs @@ -73,14 +73,14 @@ ghcmodSpec = -- --------------------------------- - it "runs the info command" $ withCurrentDirectory "./test/testdata" $ do - fp <- makeAbsolute "HaReRename.hs" - let uri = filePathToUri fp - act = infoCmd' uri "main" - arg = IP uri "main" - res = IdeResultOk "main :: IO () \t-- Defined at HaReRename.hs:2:1\n" - -- ghc-mod tries to load the test file in the context of the hie project if we do not cd first. - testCommand testPlugins act "ghcmod" "info" arg res + -- it "runs the info command" $ withCurrentDirectory "./test/testdata" $ do + -- fp <- makeAbsolute "HaReRename.hs" + -- let uri = filePathToUri fp + -- act = infoCmd' uri "main" + -- arg = IP uri "main" + -- res = IdeResultOk "main :: IO () \t-- Defined at HaReRename.hs:2:1\n" + -- -- ghc-mod tries to load the test file in the context of the hie project if we do not cd first. + -- testCommand testPlugins act "ghcmod" "info" arg res -- ---------------------------------------------------------------------------- @@ -97,6 +97,7 @@ ghcmodSpec = ] testCommand testPlugins act "ghcmod" "type" arg res + it "runs the type command, find function type" $ withCurrentDirectory "./test/testdata" $ do fp <- makeAbsolute "HaReRename.hs" let uri = filePathToUri fp From 288e65541f888f558a816efac6b41a95e4d3296d Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sun, 12 May 2019 10:10:46 +0200 Subject: [PATCH 9/9] More cleanup --- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 22 +--------------------- test/unit/JsonSpec.hs | 6 +++--- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index 7929e2416..ab994f179 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -12,7 +12,6 @@ module Haskell.Ide.Engine.Plugin.GhcMod -- * For tests , Bindings(..) , FunctionSig(..) - , InfoParams(..) , TypeDef(..) , TypeParams(..) , TypedHoles(..) -- only to keep the GHC 8.4 and below unused field warning happy @@ -88,26 +87,8 @@ checkCmd = CmdSync setTypecheckedModule customOptions :: Options customOptions = defaultOptions { fieldLabelModifier = camelTo2 '_' . drop 2} -data InfoParams = - IP { ipFile :: Uri - , ipExpr :: T.Text - } deriving (Eq,Show,Generic) - -instance FromJSON InfoParams where - parseJSON = genericParseJSON customOptions -instance ToJSON InfoParams where - toJSON = genericToJSON customOptions - --- infoCmd :: CommandFunc InfoParams T.Text --- infoCmd = CmdSync $ \(IP uri expr) -> --- infoCmd' uri expr - --- infoCmd' :: Uri -> T.Text -> IdeGhcM (IdeResult T.Text) --- infoCmd' uri expr = --- pluginGetFile "info: " uri $ \file -> --- fmap T.pack <$> Hie.runGhcModCommand (GM.info file (GM.Expression (T.unpack expr))) - -- --------------------------------------------------------------------- + data TypeParams = TP { tpIncludeConstraints :: Bool , tpFile :: Uri @@ -123,7 +104,6 @@ typeCmd :: CommandFunc TypeParams [(Range,T.Text)] typeCmd = CmdSync $ \(TP _bool uri pos) -> liftToGhc $ newTypeCmd pos uri --- AZ: currently only used in tests, but newTypeCmd :: Position -> Uri -> IdeM (IdeResult [(Range, T.Text)]) newTypeCmd newPos uri = pluginGetFile "newTypeCmd: " uri $ \fp -> diff --git a/test/unit/JsonSpec.hs b/test/unit/JsonSpec.hs index cef8e9b13..2fe2e4f12 100644 --- a/test/unit/JsonSpec.hs +++ b/test/unit/JsonSpec.hs @@ -37,7 +37,7 @@ jsonSpec = do describe "General JSON instances round trip" $ do -- Plugin params prop "ApplyOneParams" (propertyJsonRoundtrip :: ApplyOneParams -> Bool) - prop "InfoParams" (propertyJsonRoundtrip :: InfoParams -> Bool) + prop "TypeParams" (propertyJsonRoundtrip :: TypeParams -> Bool) prop "HarePoint" (propertyJsonRoundtrip :: HarePoint -> Bool) prop "HarePointWithText" (propertyJsonRoundtrip :: HarePointWithText -> Bool) prop "HareRange" (propertyJsonRoundtrip :: HareRange -> Bool) @@ -62,8 +62,8 @@ smallList = resize 3 . listOf instance Arbitrary ApplyOneParams where arbitrary = AOP <$> arbitrary <*> arbitrary <*> arbitrary -instance Arbitrary InfoParams where - arbitrary = IP <$> arbitrary <*> arbitrary +instance Arbitrary TypeParams where + arbitrary = TP <$> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary HarePoint where arbitrary = HP <$> arbitrary <*> arbitrary