Skip to content

Commit

Permalink
Bump ghcide to fix GHC panics in LSP tests (digital-asset#4176)
Browse files Browse the repository at this point in the history
fixes digital-asset#4152

changelog_begin
changelog_end
  • Loading branch information
cocreature authored and mergify[bot] committed Jan 24, 2020
1 parent 9ab419f commit 93d7b1a
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 29 deletions.
4 changes: 2 additions & 2 deletions bazel-haskell-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ load("@os_info//:os_info.bzl", "is_windows")
load("@dadew//:dadew.bzl", "dadew_tool_home")
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")

GHCIDE_REV = "e180a626eb05aca2a0c1602022459a7c2633d6f4"
GHCIDE_SHA256 = "9d6e1f125faf7e52647513bf9cf0a874975e2c035ca879466944ad66c51b59d7"
GHCIDE_REV = "8f74783835324ee6dad7faf83b7a62143a48e8c6"
GHCIDE_SHA256 = "36bed2b197dfc296488ed2e994b82193e4505051ffa3050d4844a6c66fab2baa"
GHCIDE_VERSION = "0.0.6"

def daml_haskell_deps():
Expand Down
3 changes: 2 additions & 1 deletion bazel_tools/haskell-ghcide-expose-compat.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ index 930b387..73f4b51 100644
Development.IDE.Import.DependencyInformation
Development.IDE.LSP.LanguageServer
Development.IDE.LSP.Protocol
@@ -118,13 +122,9 @@ library
@@ -118,14 +122,10 @@ library
Development.IDE.Types.Options
other-modules:
Development.IDE.Core.Debouncer
- Development.IDE.Core.Compile
Development.IDE.Core.Preprocessor
Development.IDE.Core.FileExists
- Development.IDE.GHC.Compat
Development.IDE.GHC.CPP
- Development.IDE.GHC.Error
Expand Down
1 change: 1 addition & 0 deletions compiler/damlc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ da_haskell_library(
"//compiler/daml-licenses/licenses:licensing.md",
],
hackage_deps = [
"data-default",
"aeson-pretty",
"aeson",
"ansi-wl-pprint",
Expand Down
1 change: 1 addition & 0 deletions compiler/damlc/daml-doc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ da_haskell_library(
"bytestring",
"cmark-gfm",
"containers",
"data-default",
"directory",
"extra",
"filepath",
Expand Down
3 changes: 2 additions & 1 deletion compiler/damlc/daml-doc/src/DA/Daml/Doc/Extract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import "ghc-lib-parser" Bag (bagToList)

import Control.Monad
import Control.Monad.Trans.Maybe
import Data.Default
import Data.List.Extra
import Data.List.Extended (spanMaybe)
import Data.Maybe
Expand Down Expand Up @@ -180,7 +181,7 @@ haddockParse :: (LSP.FromServerMessage -> IO ()) ->
MaybeT IO [Service.TcModuleResult]
haddockParse diagsLogger opts f = MaybeT $ do
vfs <- makeVFSHandle
service <- Service.initialise Service.mainRule (pure $ LSP.IdInt 0) diagsLogger noLogging opts vfs
service <- Service.initialise def Service.mainRule (pure $ LSP.IdInt 0) diagsLogger noLogging opts vfs
Service.setFilesOfInterest service (Set.fromList f)
Service.runAction service $
runMaybeT $
Expand Down
1 change: 1 addition & 0 deletions compiler/damlc/daml-ide-core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ da_haskell_library(
"aeson",
"base",
"containers",
"data-default",
"directory",
"extra",
"filepath",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Development.IDE.Core.OfInterest
import Development.IDE.Core.Shake
import Development.IDE.Types.Location
import Development.IDE.Types.Options
import qualified Language.Haskell.LSP.Types.Capabilities as LSP
import qualified Language.Haskell.LSP.Messages as LSP
import qualified Language.Haskell.LSP.Types as LSP

Expand Down Expand Up @@ -102,16 +103,18 @@ modifyOpenVirtualResources state f = do
void $ shakeRun state []

initialise
:: Rules ()
:: LSP.ClientCapabilities
-> Rules ()
-> IO LSP.LspId
-> (LSP.FromServerMessage -> IO ())
-> Logger
-> DamlEnv
-> IdeOptions
-> VFSHandle
-> IO IdeState
initialise mainRule getLspId toDiags logger damlEnv options vfs =
initialise caps mainRule getLspId toDiags logger damlEnv options vfs =
IDE.initialise
caps
(do addIdeGlobal damlEnv
mainRule)
getLspId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import qualified DA.Daml.LF.Ast as LF
import Control.Concurrent.STM
import Control.Exception.Extra
import qualified Control.Monad.Reader as Reader
import Data.Default
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import qualified Data.Aeson as Aeson
Expand Down Expand Up @@ -179,7 +180,7 @@ runShakeTest mbScenarioService (ShakeTest m) = do
eventLogger _ = pure ()
vfs <- API.makeVFSHandle
damlEnv <- mkDamlEnv options mbScenarioService
service <- API.initialise (mainRule options) (pure $ IdInt 0) (atomically . eventLogger) noLogging damlEnv (toCompileOpts options (IdeReportProgress False)) vfs
service <- API.initialise def (mainRule options) (pure $ IdInt 0) (atomically . eventLogger) noLogging damlEnv (toCompileOpts options (IdeReportProgress False)) vfs
result <- withSystemTempDirectory "shake-api-test" $ \testDirPath -> do
let ste = ShakeTestEnv
{ steService = service
Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/lib/DA/Cli/Damlc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ execIde telemetry (Debug debug) enableScenarioService ghcOpts mbProfileDir (from
sdkVersion <- getSdkVersion `catchIO` const (pure "Unknown (not started via the assistant)")
Logger.logInfo loggerH (T.pack $ "SDK version: " <> sdkVersion)
runLanguageServer loggerH $ \getLspId sendMsg vfs caps ->
getDamlIdeState opts mbScenarioService loggerH getLspId sendMsg vfs (clientSupportsProgress caps)
getDamlIdeState opts mbScenarioService loggerH caps getLspId sendMsg vfs (clientSupportsProgress caps)


-- | Whether we should write interface files during `damlc compile`.
Expand Down
9 changes: 6 additions & 3 deletions compiler/damlc/lib/DA/Cli/Damlc/IdeState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module DA.Cli.Damlc.IdeState
, withDamlIdeState
) where

import Data.Default
import qualified Language.Haskell.LSP.Messages as LSP

import Control.Exception
Expand All @@ -19,20 +20,22 @@ import Development.IDE.Core.API
import qualified Development.IDE.Types.Logger as IdeLogger
import Development.IDE.Types.Options
import qualified Language.Haskell.LSP.Types as LSP
import qualified Language.Haskell.LSP.Types.Capabilities as LSP

getDamlIdeState
:: Options
-> Maybe Scenario.Handle
-> Logger.Handle IO
-> LSP.ClientCapabilities
-> IO LSP.LspId
-> (LSP.FromServerMessage -> IO ())
-> VFSHandle
-> IdeReportProgress
-> IO IdeState
getDamlIdeState compilerOpts mbScenarioService loggerH getLspId eventHandler vfs reportProgress = do
getDamlIdeState compilerOpts mbScenarioService loggerH caps getLspId eventHandler vfs reportProgress = do
let rule = mainRule compilerOpts
damlEnv <- mkDamlEnv compilerOpts mbScenarioService
initialise rule getLspId eventHandler (toIdeLogger loggerH) damlEnv (toCompileOpts compilerOpts reportProgress) vfs
initialise caps rule getLspId eventHandler (toIdeLogger loggerH) damlEnv (toCompileOpts compilerOpts reportProgress) vfs

-- Wrapper for the common case where the scenario service will be started automatically (if enabled)
-- and we use the builtin VFSHandle.
Expand All @@ -49,7 +52,7 @@ withDamlIdeState opts@Options{..} loggerH eventHandler f = do
-- We only use withDamlIdeState outside of the IDE where we do not care about
-- progress reporting.
bracket
(getDamlIdeState opts mbScenarioService loggerH (pure $ LSP.IdInt 0) eventHandler vfs (IdeReportProgress False))
(getDamlIdeState opts mbScenarioService loggerH def (pure $ LSP.IdInt 0) eventHandler vfs (IdeReportProgress False))
shutdown
f

Expand Down
1 change: 1 addition & 0 deletions compiler/damlc/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ da_haskell_test(
data = ["//compiler/damlc/pkg-db"],
hackage_deps = [
"base",
"data-default",
"extra",
"ghcide",
"haskell-lsp-types",
Expand Down
3 changes: 2 additions & 1 deletion compiler/damlc/tests/src/DA/Test/DamlDocTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module DA.Test.DamlDocTest (main) where

import Data.Default
import qualified Data.Text.Extended as T
import System.IO.Extra
import Test.Tasty
Expand Down Expand Up @@ -108,6 +109,6 @@ shouldGenerate input expected = withTempFile $ \tmpFile -> do
T.writeFileUtf8 tmpFile $ T.unlines $ testModuleHeader <> input
opts <- fmap (\opts -> opts{optHaddock=Haddock True}) $ defaultOptionsIO Nothing
vfs <- makeVFSHandle
ideState <- initialise mainRule (pure $ LSP.IdInt 0) (const $ pure ()) noLogging (toCompileOpts opts (IdeReportProgress False)) vfs
ideState <- initialise def mainRule (pure $ LSP.IdInt 0) (const $ pure ()) noLogging (toCompileOpts opts (IdeReportProgress False)) vfs
Just pm <- runAction ideState $ use GetParsedModule $ toNormalizedFilePath tmpFile
genModuleContent (getDocTestModule pm) @?= T.unlines (doctestHeader <> expected)
5 changes: 3 additions & 2 deletions compiler/damlc/tests/src/DA/Test/DamlcIntegration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Development.IDE.Types.Options(IdeReportProgress(..))
import qualified Data.Aeson.Encode.Pretty as A
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.Char
import Data.Default
import qualified Data.DList as DList
import Data.Foldable
import Data.List.Extra
Expand Down Expand Up @@ -138,10 +139,10 @@ getIntegrationTests registerTODO scenarioService version = do
-- We use a separate service for generated files so that we can test files containing internal imports.
pure $
withResource
(initialise (mainRule opts) (pure $ LSP.IdInt 0) (const $ pure ()) IdeLogger.noLogging damlEnv (toCompileOpts opts (IdeReportProgress False)) vfs)
(initialise def (mainRule opts) (pure $ LSP.IdInt 0) (const $ pure ()) IdeLogger.noLogging damlEnv (toCompileOpts opts (IdeReportProgress False)) vfs)
shutdown $ \service ->
withResource
(initialise (mainRule opts) (pure $ LSP.IdInt 0) (const $ pure ()) IdeLogger.noLogging damlEnv (toCompileOpts opts { optIsGenerated = True } (IdeReportProgress False)) vfs)
(initialise def (mainRule opts) (pure $ LSP.IdInt 0) (const $ pure ()) IdeLogger.noLogging damlEnv (toCompileOpts opts { optIsGenerated = True } (IdeReportProgress False)) vfs)
shutdown $ \serviceGenerated ->
withTestArguments $ \args -> testGroup ("Tests for DAML-LF " ++ renderPretty version) $
map (testCase args version service outdir registerTODO) nongeneratedFiles <>
Expand Down
6 changes: 2 additions & 4 deletions compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,8 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests"
, "show b = 2"
]
setFilesOfInterest [f]
expectTextOnHover (f,3,[0..3]) $ Contains "```daml\n==\n```"
expectTextOnHover (f,3,[0..3]) $ Contains "```daml\n: Text -> Bool\n```"
expectTextOnHover (f,5,[0..3]) $ Contains "```daml\nshow\n```"
expectTextOnHover (f,5,[0..3]) $ Contains "```daml\n: Bool -> Int\n```"
expectTextOnHover (f,3,[0..3]) $ Contains "```daml\n==\n: Text -> Bool\n```\n"
expectTextOnHover (f,5,[0..3]) $ Contains "```daml\nshow\n: Bool -> Int\n```\n"

, testCaseFails' "Type of choice" $ do
f <- makeModule "F"
Expand Down
1 change: 1 addition & 0 deletions compiler/damlc/tests/util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def damlc_integration_test(name, main_function):
"base",
"bytestring",
"containers",
"data-default",
"deepseq",
"directory",
"dlist",
Expand Down
2 changes: 0 additions & 2 deletions compiler/lsp-tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ da_haskell_test(
data = [
"//compiler/damlc",
],
# see https://github.com/digital-asset/daml/issues/4152
flaky = True,
hackage_deps = [
"aeson",
"base",
Expand Down
13 changes: 4 additions & 9 deletions compiler/lsp-tests/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,10 @@ requestTests run _runScenarios = testGroup "requests"
{ _contents = HoverContents $ MarkupContent MkMarkdown $ T.unlines
[ "```daml"
, "Main.add"
, "```"
, "*\t*\t*"
, "```daml"
, ": Int -> Int -> Int"
, "```"
, "*\t*\t*"
, "**Defined at " <> T.pack fp <> ":4:1**"
, "*Defined at " <> T.pack fp <> ":4:1*"
]
, _range = Just $ Range (Position 9 17) (Position 9 20)
}
Expand All @@ -366,11 +363,9 @@ requestTests run _runScenarios = testGroup "requests"
liftIO $ r @?= Just Hover
{ _contents = HoverContents $ MarkupContent MkMarkdown $ T.unlines
[ "```daml"
, ""
, "```"
, "*\t*\t*"
, "```daml"
, ": Numeric n"
, "1.0"
, ": NumericScale n"
, "=> Numeric n"
, "```"
, "*\t*\t*"
]
Expand Down

0 comments on commit 93d7b1a

Please sign in to comment.