Skip to content

Commit 8434386

Browse files
authored
Merge branch 'master' into apply-refact-exts
2 parents decf082 + a4627e5 commit 8434386

39 files changed

+463
-584
lines changed

.github/mergify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pull_request_rules:
3232
- status-success=test (windows-latest, 8.6.5, true)
3333
- status-success=test (windows-latest, 8.10.2.2)
3434
- status-success=test (windows-latest, 8.10.1)
35-
- status-success=test (windows-latest, 8.6.4)
35+
# - status-success=test (windows-latest, 8.6.4)
3636

3737
- 'status-success=ci/circleci: ghc-8.10.3'
3838
- 'status-success=ci/circleci: ghc-8.10.2'

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ jobs:
4040
ghc: '8.10.2.2'
4141
- os: windows-latest
4242
ghc: '8.10.1'
43-
- os: windows-latest
44-
ghc: '8.6.4'
43+
# This build get stuck frequently
44+
# - os: windows-latest
45+
# ghc: '8.6.4'
4546

4647
steps:
4748
# Cancel queued workflows from earlier commits in this branch

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ background](https://neilmitchell.blogspot.com/2020/01/one-haskell-ide-to-rule-th
4949

5050
## Features
5151

52-
- Code evaluation codelens (inspired by [Dante](https://github.com/jyp/dante#-reploid)). You can evaluate code by writing it in a comment of the form -- >>>
52+
- Code evaluation codelens ([Tutorial](plugins/hls-eval-plugin/README.md)):
5353

54-
![Eval](https://i.imgur.com/bh992sT.gif)
54+
![Eval Demo](plugins/hls-eval-plugin/demo.gif)
5555

5656
- Type information and documentation on hover. Note that currently, in order for docs to be displayed for dependencies, they must have been built with GHC's `-haddock` flag:
5757

@@ -295,7 +295,7 @@ Here is a list of the additional settings currently supported by `haskell-langua
295295
- Format on imports (`haskell.formatOnImportOn`, default true): whether to format after adding an import
296296
- Maximum number of problems to report (`haskell.maxNumberOfProblems`, default 100): the maximum number of problems the server will send to the client
297297
- Diagnostics on change (`haskell.diagnosticsOnChange`, default true): (currently unused)
298-
- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets (currently unused until we have snippets to provide)
298+
- Completion snippets (`haskell.completionSnippetsOn`, default true): whether to support completion snippets
299299
- Liquid Haskell (`haskell.liquidOn`, default false): whether to enable Liquid Haskell support (currently unused until the Liquid Haskell support is functional again)
300300
- Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support
301301

cabal.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ packages:
44
./shake-bench
55
./ghcide
66
./hls-plugin-api
7-
./hls-exactprint-utils
87
./plugins/tactics
98
./plugins/hls-class-plugin
109
./plugins/hls-eval-plugin

ghcide/.hlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
- Development.IDE.Core.Compile
8080
- Development.IDE.Core.Rules
8181
- Development.IDE.GHC.Compat
82+
- Development.IDE.GHC.ExactPrint
8283
- Development.IDE.GHC.Orphans
8384
- Development.IDE.GHC.Util
8485
- Development.IDE.Import.FindImports

ghcide/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
### 0.7.1 (2020-01-13)
2+
3+
* Fix sticky diagnostics bug (#1188) - (Pepe Iborra)
4+
* Use completionSnippetsOn flag (#1195) - (Yuya Kono)
5+
* Update tested-with GHC in cabal config - (jneira)
6+
* Do not disable parallel GC by default (#1190) - (Pepe Iborra)
7+
* Fix module outline becoming stale after switching branches (#1189) - (Pepe Iborra)
8+
* Make adding missing constraint work in presence of 'forall' (fixes #1164) (#1177) - (Jan Hrcek)
9+
* Bump haskell-lsp to 0.23 (#1146) - (Potato Hatsue)
10+
* Fix #723 (Instance declarations in hs-boot files result in GHC errors) (#781) - (Ben Simms)
11+
* Also suggest importing methods without parent class (#766) - (Thomas Winant)
12+
* Update links to issues/PRs in ghcide tests. (#1142) - (Peter Wicks Stringfield)
13+
* fix suggestAddTypeAnnotation regex (#760) - (Kostas Dermentzis)
14+
115
### 0.7.0 (2020-01-03)
216

17+
* Ghcide now loads HLS plugins internally - (Pepe Iborra)
318
* Retry a failed cradle if the cradle descriptor changes (#762) - (Pepe Iborra)
419
* Fix extend imports regression (#769) - (Pepe Iborra)
520
* Perform memory measurement on SIGUSR1 (#761) - (Pepe Iborra)

ghcide/bench/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ versions:
5858
# - v0.4.0
5959
# - v0.5.0
6060
# - v0.6.0
61+
# - v0.7.0
62+
# - v0.7.1
6163
- upstream: origin/master
6264
- HEAD

ghcide/ghcide.cabal

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cabal-version: 1.20
22
build-type: Simple
33
category: Development
44
name: ghcide
5-
version: 0.7.0.0
5+
version: 0.7.1.0
66
license: Apache-2.0
77
license-file: LICENSE
88
author: Digital Asset and Ghcide contributors
@@ -51,6 +51,7 @@ library
5151
fuzzy,
5252
filepath,
5353
fingertree,
54+
ghc-exactprint,
5455
Glob,
5556
haddock-library >= 1.8,
5657
hashable,
@@ -66,6 +67,7 @@ library
6667
prettyprinter-ansi-terminal,
6768
prettyprinter,
6869
regex-tdfa >= 1.3.1.0,
70+
retrie,
6971
rope-utf16-splay,
7072
safe,
7173
safe-exceptions,
@@ -144,6 +146,7 @@ library
144146
Development.IDE.Core.Tracing
145147
Development.IDE.GHC.Compat
146148
Development.IDE.GHC.Error
149+
Development.IDE.GHC.ExactPrint
147150
Development.IDE.GHC.Orphans
148151
Development.IDE.GHC.Util
149152
Development.IDE.Import.DependencyInformation

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
-- using the "Shaker" abstraction layer for in-memory use.
1212
--
1313
module Development.IDE.Core.Rules(
14+
-- * Types
1415
IdeState, GetDependencies(..), GetParsedModule(..), TransitiveDependencies(..),
1516
Priority(..), GhcSessionIO(..), GetClientSettings(..),
17+
-- * Functions
1618
priorityTypeCheck,
1719
priorityGenerateCore,
1820
priorityFilesOfInterest,
@@ -27,8 +29,33 @@ module Development.IDE.Core.Rules(
2729
highlightAtPoint,
2830
getDependencies,
2931
getParsedModule,
32+
getParsedModuleWithComments,
3033
getClientConfigAction,
31-
getParsedModuleWithComments
34+
-- * Rules
35+
CompiledLinkables(..),
36+
IsHiFileStable(..),
37+
getParsedModuleRule,
38+
getParsedModuleWithCommentsRule,
39+
getLocatedImportsRule,
40+
getDependencyInformationRule,
41+
reportImportCyclesRule,
42+
getDependenciesRule,
43+
typeCheckRule,
44+
getDocMapRule,
45+
loadGhcSession,
46+
getModIfaceFromDiskRule,
47+
getModIfaceRule,
48+
getModIfaceWithoutLinkableRule,
49+
getModSummaryRule,
50+
isHiFileStableRule,
51+
getModuleGraphRule,
52+
knownFilesRule,
53+
getClientSettingsRule,
54+
getHieAstsRule,
55+
getBindingsRule,
56+
needsCompilationRule,
57+
generateCoreRule,
58+
getImportMapRule
3259
) where
3360

3461
import Fingerprint

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -815,20 +815,20 @@ defineEarlyCutoff op = addBuiltinRule noLint noIdentity $ \(Q (key, file)) (old
815815
(do v <- op key file; liftIO $ evaluate $ force v) $
816816
\(e :: SomeException) -> pure (Nothing, ([ideErrorText file $ T.pack $ show e | not $ isBadDependency e],Nothing))
817817
modTime <- liftIO $ (currentValue . fst =<<) <$> getValues state GetModificationTime file
818-
(bs, diags, diagsV, res) <- case res of
818+
(bs, res) <- case res of
819819
Nothing -> do
820820
staleV <- liftIO $ getValues state key file
821821
pure $ case staleV of
822-
Nothing -> (toShakeValue ShakeResult bs, diags, Vector.fromList diags, Failed)
822+
Nothing -> (toShakeValue ShakeResult bs, Failed)
823823
Just v -> case v of
824-
(Succeeded ver v, diags) ->
825-
(toShakeValue ShakeStale bs, Vector.toList diags, diags, Stale ver v)
826-
(Stale ver v, diags) ->
827-
(toShakeValue ShakeStale bs, Vector.toList diags, diags, Stale ver v)
828-
(Failed, diags) ->
829-
(toShakeValue ShakeResult bs, Vector.toList diags, diags, Failed)
830-
Just v -> pure (maybe ShakeNoCutoff ShakeResult bs, diags, Vector.fromList diags, Succeeded (vfsVersion =<< modTime) v)
831-
liftIO $ setValues state key file res diagsV
824+
(Succeeded ver v, _) ->
825+
(toShakeValue ShakeStale bs, Stale ver v)
826+
(Stale ver v, _) ->
827+
(toShakeValue ShakeStale bs, Stale ver v)
828+
(Failed, _) ->
829+
(toShakeValue ShakeResult bs, Failed)
830+
Just v -> pure (maybe ShakeNoCutoff ShakeResult bs, Succeeded (vfsVersion =<< modTime) v)
831+
liftIO $ setValues state key file res (Vector.fromList diags)
832832
updateFileDiagnostics file (Key key) extras $ map (\(_,y,z) -> (y,z)) diags
833833
let eq = case (bs, fmap decodeShakeValue old) of
834834
(ShakeResult a, Just (ShakeResult b)) -> a == b

hls-exactprint-utils/src/Ide/TreeTransform.hs renamed to ghcide/src/Development/IDE/GHC/ExactPrint.hs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE DerivingStrategies #-}
33
{-# LANGUAGE GADTs #-}
4-
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5-
{-# LANGUAGE LambdaCase #-}
64
{-# LANGUAGE OverloadedStrings #-}
75
{-# LANGUAGE RankNTypes #-}
8-
{-# LANGUAGE RecordWildCards #-}
9-
{-# LANGUAGE ScopedTypeVariables #-}
106

11-
module Ide.TreeTransform
7+
module Development.IDE.GHC.ExactPrint
128
( Graft(..),
139
graft,
1410
graftDecls,
@@ -34,6 +30,7 @@ import Control.Monad.Trans.Class
3430
import Control.Monad.Trans.Except
3531
import Control.Monad.Zip
3632
import qualified Data.DList as DL
33+
import Data.Either.Extra (mapLeft)
3734
import Data.Functor.Classes
3835
import Data.Functor.Contravariant
3936
import qualified Data.Text as T
@@ -309,7 +306,7 @@ annotate :: ASTElement ast => DynFlags -> Located ast -> TransformT (Either Stri
309306
annotate dflags ast = do
310307
uniq <- show <$> uniqueSrcSpanT
311308
let rendered = render dflags ast
312-
(anns, expr') <- lift $ either (Left . show) Right $ parseAST dflags uniq rendered
309+
(anns, expr') <- lift $ mapLeft show $ parseAST dflags uniq rendered
313310
let anns' = setPrecedingLines expr' 0 1 anns
314311
pure (anns', expr')
315312

@@ -318,7 +315,7 @@ annotateDecl :: DynFlags -> LHsDecl GhcPs -> TransformT (Either String) (Anns, L
318315
annotateDecl dflags ast = do
319316
uniq <- show <$> uniqueSrcSpanT
320317
let rendered = render dflags ast
321-
(anns, expr') <- lift $ either (Left . show) Right $ parseDecl dflags uniq rendered
318+
(anns, expr') <- lift $ mapLeft show $ parseDecl dflags uniq rendered
322319
let anns' = setPrecedingLines expr' 1 0 anns
323320
pure (anns', expr')
324321
------------------------------------------------------------------------------

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ import Development.IDE.GHC.Util
3030
import Development.IDE.LSP.Server
3131
import TcRnDriver (tcRnImportDecls)
3232
import Data.Maybe
33+
import Ide.Plugin.Config (Config(completionSnippetsOn))
34+
import Ide.PluginUtils (getClientConfig)
3335

3436
#if defined(GHC_LIB)
3537
import Development.IDE.Import.DependencyInformation
3638
#endif
3739

38-
plugin :: Plugin c
40+
plugin :: Plugin Config
3941
plugin = Plugin produceCompletions setHandlersCompletion
4042

4143
produceCompletions :: Rules ()
@@ -116,7 +118,7 @@ instance Binary NonLocalCompletions
116118

117119
-- | Generate code actions.
118120
getCompletionsLSP
119-
:: LSP.LspFuncs cofd
121+
:: LSP.LspFuncs Config
120122
-> IdeState
121123
-> CompletionParams
122124
-> IO (Either ResponseError CompletionResponseResult)
@@ -142,12 +144,13 @@ getCompletionsLSP lsp ide
142144
-> return (Completions $ List [])
143145
(Just pfix', _) -> do
144146
let clientCaps = clientCapabilities $ shakeExtras ide
145-
Completions . List <$> getCompletions ideOpts cci' parsedMod bindMap pfix' clientCaps (WithSnippets True)
147+
snippets <- WithSnippets . completionSnippetsOn <$> getClientConfig lsp
148+
Completions . List <$> getCompletions ideOpts cci' parsedMod bindMap pfix' clientCaps snippets
146149
_ -> return (Completions $ List [])
147150
_ -> return (Completions $ List [])
148151
_ -> return (Completions $ List [])
149152

150-
setHandlersCompletion :: PartialHandlers c
153+
setHandlersCompletion :: PartialHandlers Config
151154
setHandlersCompletion = PartialHandlers $ \WithMessage{..} x -> return x{
152155
LSP.completionHandler = withResponse RspCompletion getCompletionsLSP
153156
}

ghcide/test/exe/Main.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ diagnosticTests = testGroup "diagnostics"
201201
}
202202
changeDoc doc [change]
203203
expectDiagnostics [("Testing.hs", [(DsError, (0, 15), "parse error")])]
204+
, testSessionWait "update syntax error" $ do
205+
let content = T.unlines [ "module Testing(missing) where" ]
206+
doc <- createDoc "Testing.hs" "haskell" content
207+
expectDiagnostics [("Testing.hs", [(DsError, (0, 15), "Not in scope: 'missing'")])]
208+
let change = TextDocumentContentChangeEvent
209+
{ _range = Just (Range (Position 0 15) (Position 0 16))
210+
, _rangeLength = Nothing
211+
, _text = "l"
212+
}
213+
changeDoc doc [change]
214+
expectDiagnostics [("Testing.hs", [(DsError, (0, 15), "Not in scope: 'lissing'")])]
204215
, testSessionWait "variable not in scope" $ do
205216
let content = T.unlines
206217
[ "module Testing where"

hie-cabal.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ cradle:
7979
- path: "./test/functional"
8080
component: "haskell-language-server:test:func-test"
8181

82+
- path: "./plugins/hls-eval-plugin/test/Eval.hs"
83+
component: "haskell-language-server:test:func-test"
84+
8285
- path: "./plugins/tactics/src"
8386
component: "haskell-language-server:test:func-test"
8487

@@ -103,9 +106,6 @@ cradle:
103106
- path: "./hls-plugin-api/src"
104107
component: "lib:hls-plugin-api"
105108

106-
- path: "./hls-exactprint-utils/src"
107-
component: "lib:hls-exactprint-utils"
108-
109109
- path: "./plugins/hls-class-plugin/src"
110110
component: "lib:hls-class-plugin"
111111

hie-stack.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ cradle:
3434
- path: "./test/functional"
3535
component: "haskell-language-server:test:func-test"
3636

37+
- path: "./plugins/hls-eval-plugin/test/Eval.hs"
38+
component: "haskell-language-server:test:func-test"
39+
3740
- path: "./test/wrapper"
3841
component: "haskell-language-server:test:wrapper-test"
3942

4043
- path: "./hls-plugin-api/src"
4144
component: "hls-plugin-api:lib"
4245

43-
- path: "./hls-exactprint-utils/src"
44-
component: "hls-exactprint-utils:lib"
45-
4646
# Plugins:
4747

4848
- path: "./plugins/hls-class-plugin/src"

0 commit comments

Comments
 (0)