Skip to content

Commit

Permalink
Bump ghcide (digital-asset#3943)
Browse files Browse the repository at this point in the history
* Bump ghcide

* Fix ghcide build

* Include bugfix for Windows
  • Loading branch information
cocreature authored Jan 4, 2020
1 parent 20b2e22 commit 42c586f
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 34 deletions.
8 changes: 5 additions & 3 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 = "ef8de2e7fc55c6f246a9ff322ed3637a7bb71c20"
GHCIDE_SHA256 = "55f4ab090144428471e07e746a4688e35f32460f227c0b9e009450a354076592"
GHCIDE_REV = "64693eddd8fc3659036c3b9c1ddfd88ccc7b4619"
GHCIDE_SHA256 = "69e245ff32af6824c31b8ebd2ea067e746d0fba8b78da7c2ad5095236f78a6c1"
GHCIDE_VERSION = "0.0.5"

def daml_haskell_deps():
Expand Down Expand Up @@ -104,6 +104,7 @@ deps = [
"@stackage//:directory",
"@stackage//:extra",
"@stackage//:filepath",
"@stackage//:fuzzy",
"@stackage//:ghc",
"@stackage//:ghc-boot",
"@stackage//:ghc-boot-th",
Expand All @@ -114,6 +115,7 @@ deps = [
"@stackage//:network-uri",
"@stackage//:prettyprinter",
"@stackage//:prettyprinter-ansi-terminal",
"@stackage//:regex-tdfa",
"@stackage//:rope-utf16-splay",
"@stackage//:safe-exceptions",
"@stackage//:shake",
Expand Down Expand Up @@ -400,6 +402,7 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
"filepath",
"filepattern",
"foldl",
"fuzzy",
"ghc",
"ghc-boot",
"ghc-boot-th",
Expand Down Expand Up @@ -466,7 +469,6 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
"range-set-list",
"recursion-schemes",
"regex-tdfa",
"regex-tdfa-text",
"retry",
"rope-utf16-splay",
"safe",
Expand Down
14 changes: 7 additions & 7 deletions bazel_tools/haskell-ghcide-expose-compat.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/ghcide.cabal b/ghcide.cabal
index d11d000..2ee2c0a 100644
index 930b387..73f4b51 100644
--- a/ghcide.cabal
+++ b/ghcide.cabal
@@ -96,6 +96,7 @@ library
@@ -98,6 +98,7 @@ library
include-dirs:
include
exposed-modules:
+ Development.IDE.Core.Compile
Development.IDE.Core.Completions
Development.IDE.Core.CompletionsTypes
Development.IDE.Core.FileStore
Development.IDE.Core.OfInterest
Development.IDE.Core.PositionMapping
@@ -103,7 +104,10 @@ library
@@ -107,7 +108,10 @@ library
Development.IDE.Core.RuleTypes
Development.IDE.Core.Service
Development.IDE.Core.Shake
Expand All @@ -21,7 +21,7 @@ index d11d000..2ee2c0a 100644
Development.IDE.Import.DependencyInformation
Development.IDE.LSP.LanguageServer
Development.IDE.LSP.Protocol
@@ -114,13 +118,9 @@ library
@@ -118,13 +122,9 @@ library
Development.IDE.Types.Options
other-modules:
Development.IDE.Core.Debouncer
Expand All @@ -34,4 +34,4 @@ index d11d000..2ee2c0a 100644
- Development.IDE.GHC.Warnings
Development.IDE.Import.FindImports
Development.IDE.LSP.CodeAction
Development.IDE.LSP.Definition
Development.IDE.LSP.Completions
1 change: 0 additions & 1 deletion ci/cron/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ da_haskell_binary(
"http-client",
"http-client-tls",
"http-types",
"MissingH",
"process",
"split",
"text",
Expand Down
3 changes: 1 addition & 2 deletions ci/cron/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import qualified Data.Foldable as Foldable
import qualified Data.HashMap.Strict as H
import qualified Data.List as List
import qualified Data.List.Extra as List
import qualified Data.List.Utils as List
import qualified Data.List.Split as Split
import qualified Data.Ord as Ord
import qualified Data.Set as Set
Expand Down Expand Up @@ -128,7 +127,7 @@ build_docs_folder path versions = do
-- maps, and here order matters.
let versions_json = versions
& map (\s -> "\"" <> s <> "\": \"" <> s <> "\"")
& List.join ", "
& List.intercalate ", "
& \s -> "{" <> s <> "}"
writeFile (path <> "/versions.json") versions_json
shell_ $ "mkdir -p " <> path <> "/" <> latest
Expand Down
1 change: 0 additions & 1 deletion compiler/damlc/daml-compiler/src/DA/Daml/Compiler/Dar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import System.Directory.Extra
import System.FilePath
import qualified Data.Yaml as Y

import GHC
import MkIface
import Module
import HscTypes
Expand Down
3 changes: 1 addition & 2 deletions compiler/damlc/daml-compiler/src/DA/Daml/Compiler/DocTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ docTest ideState files = do
-- frequent but sadly it doesn’t make them go away completely.
runActionSync ideState (pure ())
diags <- getDiagnostics ideState
when (any ((Just DsError ==) . _severity . snd) diags) exitFailure

when (any (\(_, _, diag) -> Just DsError == _severity diag) diags) exitFailure
2 changes: 1 addition & 1 deletion compiler/damlc/daml-doc/test/DA/Daml/GHC/Damldoc/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ runDamldoc testfile importPathM = do
}

let diagLogger = \case
EventFileDiagnostics fp diags -> T.hPutStrLn stderr $ showDiagnostics $ map (toNormalizedFilePath fp,) diags
EventFileDiagnostics fp diags -> T.hPutStrLn stderr $ showDiagnostics $ map (toNormalizedFilePath fp,ShowDiag,) diags
_ -> pure ()

-- run the doc generator on that file
Expand Down
1 change: 0 additions & 1 deletion compiler/damlc/daml-ide-core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ da_haskell_library(
"mtl",
"network-uri",
"regex-tdfa",
"regex-tdfa-text",
"stm",
"temporary",
"text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ uriToVirtualResource uri = do

sendFileDiagnostics :: [FileDiagnostic] -> Action ()
sendFileDiagnostics diags =
mapM_ (uncurry sendDiagnostics) (groupSort diags)
mapM_ (uncurry sendDiagnostics) (groupSort $ map (\(file, _showDiag, diag) -> (file, diag)) diags)

-- TODO: Move this to ghcide, perhaps.
sendDiagnostics :: NormalizedFilePath -> [Diagnostic] -> Action ()
Expand Down Expand Up @@ -667,7 +667,7 @@ runScenariosRule =
let scenarios = map fst $ scenariosInModule m
toDiagnostic :: LF.ValueRef -> Either SS.Error SS.ScenarioResult -> Maybe FileDiagnostic
toDiagnostic scenario (Left err) =
Just $ (file,) $ Diagnostic
Just $ (file, ShowDiag,) $ Diagnostic
{ _range = maybe noRange sourceLocToRange mbLoc
, _severity = Just DsError
, _source = Just "Scenario"
Expand Down Expand Up @@ -952,7 +952,7 @@ getDlintDiagnosticsRule =
}
diagnostic :: NormalizedFilePath -> Idea -> FileDiagnostic
diagnostic file i =
(file, LSP.Diagnostic {
(file, ShowDiag, LSP.Diagnostic {
_range = srcSpanToRange $ ideaSpan i
, _severity = Just LSP.DsInfo
, _code = Nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ searchDiagnostics expected@(severity, cursor, message) actuals =
throwError $ ExpectedDiagnostics [expected] actuals
where
match :: D.FileDiagnostic -> Bool
match (fp, d) =
match (fp, _, d) =
Just severity == D._severity d
&& cursorFilePath cursor == fp
&& cursorPosition cursor == D._start ((D._range :: D.Diagnostic -> Range) d)
Expand Down Expand Up @@ -463,7 +463,7 @@ expectOnlyErrors = expectOnlyDiagnostics . map (\(cursor, msg) -> (D.DsError, cu
expectNoErrors :: ShakeTest ()
expectNoErrors = do
diagnostics <- getDiagnostics
let errors = filter (\(_,d) -> D._severity d == Just D.DsError) diagnostics
let errors = filter (\(_,_,d) -> D._severity d == Just D.DsError) diagnostics
unless (null errors) $
throwError (ExpectedNoErrors errors)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ import SdkVersion
conversionError :: String -> ConvertM e
conversionError msg = do
ConversionEnv{..} <- ask
throwError $ (convModuleFilePath,) Diagnostic
throwError $ (convModuleFilePath,ShowDiag,) Diagnostic
{ _range = maybe noRange sourceLocToRange convRange
, _severity = Just DsError
, _source = Just "Core to DAML-LF"
Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/lib/DA/Cli/Damlc/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ execTest inFiles color mbJUnitOutput cliOptions = do
let lfVersion = optDamlLfVersion cliOptions
testRun h inFiles lfVersion color mbJUnitOutput
diags <- getDiagnostics h
when (any ((Just DsError ==) . _severity . snd) diags) exitFailure
when (any (\(_, _, diag) -> Just DsError == _severity diag) diags) exitFailure


testRun :: IdeState -> [NormalizedFilePath] -> LF.Version -> UseColor -> Maybe FilePath -> IO ()
Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/lib/DA/Cli/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ printDiagnostics xs = BS.hPutStrLn stderr $ T.encodeUtf8 $ showDiagnosticsColore

diagnosticsLogger :: FromServerMessage -> IO ()
diagnosticsLogger = \case
EventFileDiagnostics fp diags -> printDiagnostics $ map (toNormalizedFilePath fp,) diags
EventFileDiagnostics fp diags -> printDiagnostics $ map (toNormalizedFilePath fp,ShowDiag,) diags
_ -> pure ()
2 changes: 1 addition & 1 deletion compiler/damlc/tests/src/DA/Test/DamlcIntegration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ checkDiagnostics log expected got = do
| null bad -> Nothing
| otherwise -> Just $ unlines ("Could not find matching diagnostics:" : map show bad)
where checkField :: D.FileDiagnostic -> DiagnosticField -> Bool
checkField (fp, D.Diagnostic{..}) f = case f of
checkField (fp, _, D.Diagnostic{..}) f = case f of
DFilePath p -> toNormalizedFilePath p == fp
DRange r -> r == _range
DSeverity s -> Just s == _severity
Expand Down
6 changes: 4 additions & 2 deletions compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,10 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests"
, "show b = 2"
]
setFilesOfInterest [f]
expectTextOnHover (f,3,[0..3]) $ Contains "==\n : Text -> Bool"
expectTextOnHover (f,5,[0..3]) $ Contains "show\n : Bool -> Int"
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```"

, testCaseFails' "Type of choice" $ do
f <- makeModule "F"
Expand Down
19 changes: 16 additions & 3 deletions compiler/lsp-tests/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,12 @@ requestTests run _runScenarios = testGroup "requests"
r <- getHover main' (Position 9 19)
liftIO $ r @?= Just Hover
{ _contents = HoverContents $ MarkupContent MkMarkdown $ T.unlines
[ "```daml\nMain.add"
, " : Int -> Int -> Int"
[ "```daml"
, "Main.add"
, "```"
, "*\t*\t*"
, "```daml"
, ": Int -> Int -> Int"
, "```"
, "*\t*\t*"
, "**Defined at " <> T.pack fp <> ":4:1**"
Expand All @@ -359,7 +363,16 @@ requestTests run _runScenarios = testGroup "requests"
]
r <- getHover main' (Position 2 27)
liftIO $ r @?= Just Hover
{ _contents = HoverContents $ MarkupContent MkMarkdown "```daml\n: Numeric n\n```\n"
{ _contents = HoverContents $ MarkupContent MkMarkdown $ T.unlines
[ "```daml"
, ""
, "```"
, "*\t*\t*"
, "```daml"
, ": Numeric n"
, "```"
, "*\t*\t*"
]
, _range = Just $ Range (Position 2 27) (Position 2 30)
}
closeDoc main'
Expand Down
1 change: 0 additions & 1 deletion language-support/hs/bindings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ da_haskell_library(
name = "hs-ledger",
srcs = glob(["src/**/*.hs"]),
hackage_deps = [
"MissingH",
"async",
"base",
"bytestring",
Expand Down
5 changes: 4 additions & 1 deletion stack-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ packages:
- extra-1.6.18
- grpc-haskell-0.0.1.0
- grpc-haskell-core-0.0.0.0
- fuzzy-0.1.0.0
- haskell-lsp-0.19.0.0
- haskell-lsp-types-0.19.0.0
- hie-bios-0.3.0
- hie-bios-0.3.2
- hpp-0.6.1
- lsp-test-0.9.0.0
- proto3-suite-0.4.0.0
- proto3-wire-1.1.0
- regex-base-0.94.0.0
- regex-tdfa-1.3.1.0
# Core packages, need to be listed for integer-simple flags.
- integer-simple-0.1.1.1
- text-1.2.3.1

0 comments on commit 42c586f

Please sign in to comment.