Skip to content

Rebase on ghcide HEAD #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ runLspMode lspArgs@LspArguments {..} = do
hPutStrLn stderr $ " in directory: " <> dir
hPutStrLn stderr "If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!"

runLanguageServer options (pluginHandler plugins) getInitialConfig getConfigFromNotification $ \getLspId event vfs caps wProg wIndefProg _getConfig -> do
runLanguageServer options (pluginHandler plugins) getInitialConfig getConfigFromNotification $ \getLspId event vfs caps wProg wIndefProg _getConfig _rootPath -> do
t <- t
hPutStrLn stderr $ "Started LSP server in " ++ showDuration t
sessionLoader <- loadSession dir
Expand Down
2 changes: 1 addition & 1 deletion ghcide
Submodule ghcide updated 51 files
+0 −9 .azure/linux-stack.yml
+1 −10 .azure/windows-stack.yml
+4 −0 .ghci
+56 −0 CHANGELOG.md
+7 −7 README.md
+6 −5 exe/Main.hs
+21 −13 ghcide.cabal
+26 −0 nix/sources.json
+134 −0 nix/sources.nix
+26 −14 session-loader/Development/IDE/Session.hs
+107 −0 shell.nix
+1 −1 src-ghc810/Development/IDE/GHC/HieAst.hs
+1 −1 src-ghc86/Development/IDE/GHC/HieAst.hs
+1 −1 src-ghc88/Development/IDE/GHC/HieAst.hs
+46 −0 src/Development/IDE.hs
+10 −8 src/Development/IDE/Core/FileStore.hs
+15 −3 src/Development/IDE/Core/OfInterest.hs
+1 −1 src/Development/IDE/Core/Preprocessor.hs
+9 −0 src/Development/IDE/Core/RuleTypes.hs
+12 −14 src/Development/IDE/Core/Rules.hs
+1 −1 src/Development/IDE/Core/Service.hs
+67 −104 src/Development/IDE/Core/Shake.hs
+59 −2 src/Development/IDE/GHC/Compat.hs
+29 −17 src/Development/IDE/GHC/Util.hs
+1 −2 src/Development/IDE/LSP/HoverDefinition.hs
+2 −2 src/Development/IDE/LSP/LanguageServer.hs
+7 −9 src/Development/IDE/LSP/Notifications.hs
+8 −6 src/Development/IDE/LSP/Outline.hs
+239 −105 src/Development/IDE/Plugin/CodeAction.hs
+20 −1 src/Development/IDE/Plugin/CodeAction/PositionIndexed.hs
+3 −40 src/Development/IDE/Plugin/CodeAction/RuleTypes.hs
+8 −24 src/Development/IDE/Plugin/CodeAction/Rules.hs
+2 −1 src/Development/IDE/Plugin/Completions/Logic.hs
+16 −8 src/Development/IDE/Spans/Common.hs
+75 −0 src/Development/IDE/Types/Action.hs
+75 −0 src/Development/IDE/Types/Exports.hs
+24 −4 src/Development/IDE/Types/Options.hs
+0 −1 stack.yaml
+0 −1 stack84.yaml
+0 −1 stack88.yaml
+1 −1 test/data/boot/hie.yaml
+1 −1 test/data/hover/GotoHover.hs
+8 −0 test/data/ignore-fatal/IgnoreFatal.hs
+1 −0 test/data/ignore-fatal/cabal.project
+4 −0 test/data/ignore-fatal/hie.yaml
+10 −0 test/data/ignore-fatal/ignore-fatal.cabal
+3 −0 test/data/rootUri/dirA/Foo.hs
+9 −0 test/data/rootUri/dirA/foo.cabal
+3 −0 test/data/rootUri/dirB/Foo.hs
+9 −0 test/data/rootUri/dirB/foo.cabal
+207 −43 test/exe/Main.hs
7 changes: 1 addition & 6 deletions src/Ide/Plugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ import qualified Data.List as List
import qualified Data.Map as Map
import Data.Maybe
import qualified Data.Text as T
import Development.IDE.Core.Rules
import Development.IDE.Core.Shake
import Development.IDE hiding (pluginRules)
import Development.IDE.LSP.Server
import Development.IDE.Plugin hiding (pluginRules)
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Logger
import Development.Shake hiding ( Diagnostic, command )
import GHC.Generics
import Ide.Plugin.Config
import Ide.Plugin.Formatter
Expand Down
2 changes: 1 addition & 1 deletion src/Ide/Plugin/Brittany.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Data.Coerce
import Data.Semigroup
import Data.Text (Text)
import qualified Data.Text as T
import Development.IDE.Types.Location
import Development.IDE
import Language.Haskell.Brittany
import Language.Haskell.LSP.Types as J
import qualified Language.Haskell.LSP.Types.Lens as J
Expand Down
36 changes: 7 additions & 29 deletions src/Ide/Plugin/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,10 @@ import Data.String (IsString (fromString))
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time (getCurrentTime)
import Development.IDE.Core.Rules (runAction)
import Development.IDE.Core.RuleTypes (GetModSummary (..),
GhcSession (..))
import Development.IDE.Core.Shake (use_)
import Development.IDE.GHC.Util (evalGhcEnv, hscEnv,
textToStringBuffer)
import Development.IDE.Types.Location (toNormalizedFilePath',
uriToFilePath')
import Development.IDE
import DynamicLoading (initializePlugins)
import DynFlags (targetPlatform)
import GHC (Ghc, TcRnExprMode(..), DynFlags, ExecResult (..), GeneralFlag (Opt_IgnoreHpcChanges, Opt_IgnoreOptimChanges, Opt_ImplicitImportQualified),
import Development.IDE.GHC.Compat (Ghc, TcRnExprMode(..), DynFlags, ExecResult (..), GeneralFlag (Opt_IgnoreHpcChanges, Opt_IgnoreOptimChanges, Opt_ImplicitImportQualified),
GhcLink (LinkInMemory),
GhcMode (CompManager),
HscTarget (HscInterpreted),
Expand Down Expand Up @@ -179,25 +172,10 @@ runEvalCmd lsp state EvalParams {..} = response' $ do
contents <- liftIO $ getVirtualFileFunc lsp $ toNormalizedUri _uri
text <- handleMaybe "contents" $ virtualFileText <$> contents

{- Note: GhcSessionDeps

Depending on GhcSession means we do need to reload all the module
dependencies in the GHC session(from interface files, hopefully).

The GhcSessionDeps dependency would allow us to reuse a GHC session preloaded
with all the dependencies. Unfortunately, the ModSummary objects that
GhcSessionDeps puts in the GHC session are not suitable for reuse since they
clear out the timestamps; this is done to avoid internal ghcide bugs and
can probably be relaxed so that plugins like Eval can reuse them. Once that's
done, we want to switch back to GhcSessionDeps:

-- https://github.com/digital-asset/ghcide/pull/694

-}
session <-
liftIO $
runAction "runEvalCmd.ghcSession" state $
use_ GhcSession $ -- See the note on GhcSessionDeps
use_ GhcSessionDeps $
toNormalizedFilePath' $
fp

Expand Down Expand Up @@ -316,15 +294,15 @@ evalGhciLikeCmd cmd arg = do
(ty, kind) <- typeKind True $ T.unpack input
pure
$ Just
$ T.unlines
$ T.unlines
$ map ("-- " <>)
[ input <> " :: " <> tppr kind
, "= " <> tppr ty
]
]
"type" -> do
let (emod, expr) = parseExprMode arg
ty <- exprType emod $ T.unpack expr
pure $ Just $
pure $ Just $
"-- " <> expr <> " :: " <> tppr ty <> "\n"
_ -> E.throw $ GhciLikeCmdNotImplemented cmd arg

Expand All @@ -346,7 +324,7 @@ instance Show GhciLikeCmdException where
showsPrec _ GhciLikeCmdNotImplemented{..} =
showString "unknown command '" .
showString (T.unpack ghciCmdName) . showChar '\''

instance E.Exception GhciLikeCmdException

parseGhciLikeCmd :: Text -> Maybe (Text, Text)
Expand Down
14 changes: 4 additions & 10 deletions src/Ide/Plugin/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,15 @@ import qualified Data.HashSet as HashSet
import Data.Hashable
import qualified Data.Text as T
import Data.Typeable
import Development.IDE.Core.OfInterest
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Rules
import Development.IDE.Core.Service
import Development.IDE.Core.Shake
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Location
import Development.IDE.Types.Logger
import Development.Shake hiding ( Diagnostic )
import Development.IDE as D
import Development.IDE.GHC.Compat (ParsedModule(ParsedModule))
import Development.IDE.Core.Rules (useE)
import Development.IDE.Core.Shake (getDiagnostics, getHiddenDiagnostics)
import GHC.Generics
import Ide.Plugin
import Ide.Types
import Language.Haskell.LSP.Types
import Text.Regex.TDFA.Text()
import Development.IDE.GHC.Compat (ParsedModule(ParsedModule))

-- ---------------------------------------------------------------------

Expand Down
10 changes: 2 additions & 8 deletions src/Ide/Plugin/Example2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Ide.Plugin.Example2
descriptor
) where

import Control.DeepSeq ( NFData )
import Control.DeepSeq (NFData)
import Control.Monad.Trans.Maybe
import Data.Aeson
import Data.Binary
Expand All @@ -23,15 +23,9 @@ import qualified Data.HashSet as HashSet
import Data.Hashable
import qualified Data.Text as T
import Data.Typeable
import Development.IDE.Core.OfInterest
import Development.IDE.Core.RuleTypes
import Development.IDE as D
import Development.IDE.Core.Rules
import Development.IDE.Core.Service
import Development.IDE.Core.Shake
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Location
import Development.IDE.Types.Logger
import Development.Shake hiding ( Diagnostic )
import GHC.Generics
import Ide.Plugin
import Ide.Types
Expand Down
3 changes: 1 addition & 2 deletions src/Ide/Plugin/Floskell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ where
import qualified Data.ByteString.Lazy as BS
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Location
import Development.IDE as D
import Floskell
import Ide.Plugin.Formatter
import Ide.Types
Expand Down
12 changes: 1 addition & 11 deletions src/Ide/Plugin/Formatter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,10 @@ where

import qualified Data.Map as Map
import qualified Data.Text as T
import Development.IDE.Core.FileStore
import Development.IDE.Core.Rules
import Development.IDE.Core.Shake
-- import Development.IDE.LSP.Server
-- import Development.IDE.Plugin
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Location
-- import Development.Shake hiding ( Diagnostic )
-- import Ide.Logger
import Development.IDE
import Ide.Types
import Development.IDE.Types.Logger
import Ide.Plugin.Config
import qualified Language.Haskell.LSP.Core as LSP
-- import Language.Haskell.LSP.Messages
import Language.Haskell.LSP.Types
import Text.Regex.TDFA.Text()

Expand Down
7 changes: 1 addition & 6 deletions src/Ide/Plugin/Fourmolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ where

import Control.Exception
import qualified Data.Text as T
import Development.IDE.Core.Rules
import Development.IDE.Core.RuleTypes (GhcSession (GhcSession))
import Development.IDE.Core.Shake (use)
import Development.IDE.GHC.Util (hscEnv)
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Location
import Development.IDE as D
import qualified DynFlags as D
import qualified EnumSet as S
import GHC
Expand Down
7 changes: 3 additions & 4 deletions src/Ide/Plugin/GhcIde.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ module Ide.Plugin.GhcIde
) where

import Data.Aeson
import Development.IDE.Core.Service
import Development.IDE
import Development.IDE.Plugin.Completions
import Development.IDE.Plugin.CodeAction
import Development.IDE.LSP.HoverDefinition
import Development.IDE.LSP.Outline
import Development.IDE.Plugin.CodeAction
import Development.IDE.Plugin.Completions
import Development.IDE.Types.Logger
import Ide.Plugin
import Ide.Types
import Language.Haskell.LSP.Types
Expand Down
9 changes: 1 addition & 8 deletions src/Ide/Plugin/ImportLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ import Data.Map (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes, fromMaybe)
import qualified Data.Text as T
import Development.IDE.Core.RuleTypes (GhcSessionDeps (GhcSessionDeps),
TcModuleResult (tmrModule),
TypeCheck (TypeCheck))
import Development.IDE.Core.Shake (use, IdeState (..))
import Development.IDE
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Error (realSpan, realSrcSpanToRange)
import Development.IDE.GHC.Util (HscEnvEq, hscEnv, prettyPrint)
import GHC.Generics (Generic)
import Ide.Plugin
import Ide.Types
Expand All @@ -40,8 +35,6 @@ import RnNames (findImportUsage,
getMinimalImports)
import TcRnMonad (initTcWithGbl)
import TcRnTypes (TcGblEnv (tcg_used_gres))
import Development.IDE.Core.Service (runAction)
import Development.Shake (Action)

importCommandId :: CommandId
importCommandId = "ImportLensCommand"
Expand Down
7 changes: 1 addition & 6 deletions src/Ide/Plugin/Ormolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ where

import Control.Exception
import qualified Data.Text as T
import Development.IDE.Core.Rules
import Development.IDE.Core.RuleTypes (GhcSession (GhcSession))
import Development.IDE.Core.Shake (use)
import Development.IDE.GHC.Util (hscEnv)
import Development.IDE.Types.Diagnostics as D
import Development.IDE.Types.Location
import Development.IDE
import qualified DynFlags as D
import qualified EnumSet as S
import GHC
Expand Down
2 changes: 1 addition & 1 deletion src/Ide/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Ide.Types
import qualified GHC.Generics as Generics
import qualified Language.Haskell.LSP.Types as J
import qualified Language.Haskell.LSP.Types.Lens as J
import Development.IDE.Types.Diagnostics as D
import Development.IDE as D
import Language.Haskell.LSP.Types

-- ---------------------------------------------------------------------
Expand Down
24 changes: 3 additions & 21 deletions src/Ide/Plugin/Retrie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,9 @@ import Data.String (IsString (fromString))
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Typeable (Typeable)
import Development.IDE.Core.FileStore (getFileContents)
import Development.IDE.Core.Rules
import Development.IDE.Core.RuleTypes as Ghcide (GetModIface (..),
GetModSummary (..),
GhcSessionDeps (..),
HiFileResult (..),
TypeCheck (..),
tmrModule)
import Development.IDE.Core.Shake (IdeRule,
IdeState (shakeExtras),
ideLogger, knownFilesVar,
runIdeAction, use,
useWithStaleFast, use_)
import Development.IDE.GHC.Error (isInsideSrcSpan,
realSrcSpanToRange)
import Development.IDE.GHC.Util (hscEnv, prettyPrint, runGhcEnv)
import Development.IDE.Types.Location
import Development.IDE.Types.Logger (Logger (logPriority),
Priority (..))
import Development.Shake (RuleResult)
import GHC (GenLocated (L), GhcRn,
import Development.IDE
import Development.IDE.Core.Shake (ShakeExtras(knownFilesVar))
import Development.IDE.GHC.Compat (GenLocated (L), GhcRn,
HsBindLR (FunBind),
HsGroup (..),
HsValBindsLR (..), HscEnv, IdP,
Expand Down
4 changes: 1 addition & 3 deletions src/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import qualified Data.Map as Map
import qualified Data.Set as S
import Data.String
import qualified Data.Text as T
import Development.IDE.Core.Rules
import Development.IDE.Types.Location
import Development.Shake
import Development.IDE
import Ide.Plugin.Config
import qualified Language.Haskell.LSP.Core as LSP
import Language.Haskell.LSP.Types
Expand Down