Skip to content

Commit 129e584

Browse files
authored
Merge branch 'master' into fourmolu-cli
2 parents 236d244 + 7e361f0 commit 129e584

File tree

110 files changed

+1691
-559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1691
-559
lines changed

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
# change of the strategy may require changing the bootstrapping/run code
5555

5656
steps:
57-
- uses: actions/checkout@v2
57+
- uses: actions/checkout@v3
5858

5959
- run: git fetch origin master # check the master branch for benchmarking
6060

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-18.04
2626

2727
steps:
28-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
2929

3030
- name: Set hls release version
3131
run: |
@@ -117,7 +117,7 @@ jobs:
117117
# from https://github.com/actions/upload-release-asset/issues/47#issuecomment-659071145
118118
- name: Upload binaries tarball to the release
119119
if: ${{ github.event.release.upload_url != '' }}
120-
uses: actions/github-script@v2
120+
uses: actions/github-script@v6
121121
with:
122122
github-token: ${{secrets.GITHUB_TOKEN}}
123123
script: |

.github/workflows/caching.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
]
9696

9797
steps:
98-
- uses: actions/checkout@v2
98+
- uses: actions/checkout@v3
9999

100100
- uses: ./.github/actions/setup-build
101101
with:

.github/workflows/flags.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
]
5656

5757
steps:
58-
- uses: actions/checkout@v2
58+
- uses: actions/checkout@v3
5959

6060
- uses: ./.github/actions/setup-build
6161
with:

.github/workflows/hackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
steps:
5151

52-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
5353

5454
- uses: ./.github/actions/setup-build
5555
with:

.github/workflows/hlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: "Hlint check run"
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414

1515
- name: 'Installing'
1616
uses: rwe/actions-hlint-setup@v1

.github/workflows/nix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
os: [ubuntu-latest, macOS-latest]
5555

5656
steps:
57-
- uses: actions/checkout@v2
57+
- uses: actions/checkout@v3
5858

5959
- uses: cachix/install-nix-action@v16
6060
with:
@@ -88,7 +88,7 @@ jobs:
8888
os: [ubuntu-latest, macOS-latest]
8989

9090
steps:
91-
- uses: actions/checkout@v2
91+
- uses: actions/checkout@v3
9292

9393
- uses: cachix/install-nix-action@v16
9494
with:

.github/workflows/test.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
ghc: '8.8.4'
108108

109109
steps:
110-
- uses: actions/checkout@v2
110+
- uses: actions/checkout@v3
111111

112112
- uses: ./.github/actions/setup-build
113113
with:
@@ -133,6 +133,10 @@ jobs:
133133
path: "**/.tasty-rerun-log*"
134134
key: v1-${{ runner.os }}-${{ matrix.ghc }}-test-log-${{ github.sha }}
135135

136+
- if: matrix.test
137+
name: Test hls-graph
138+
run: cabal test hls-graph --test-options="$TEST_OPTS"
139+
136140
- if: needs.pre_job.outputs.should_skip_ghcide != 'true' && matrix.test
137141
name: Test ghcide
138142
# run the tests without parallelism to avoid running out of memory
@@ -164,7 +168,7 @@ jobs:
164168
name: Test hls-floskell-plugin
165169
run: cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-floskell-plugin --test-options="$TEST_OPTS"
166170

167-
- if: matrix.test && matrix.ghc != '9.2.1'
171+
- if: matrix.test
168172
name: Test hls-class-plugin
169173
run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-class-plugin --test-options="$TEST_OPTS"
170174

@@ -224,7 +228,7 @@ jobs:
224228
name: Test hls-module-name-plugin test suite
225229
run: cabal test hls-module-name-plugin --test-options="$TEST_OPTS" || cabal test hls-module-name-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-module-name-plugin --test-options="$TEST_OPTS"
226230

227-
- if: matrix.test && matrix.ghc != '9.2.1'
231+
- if: matrix.test
228232
name: Test hls-alternate-number-format-plugin test suite
229233
run: cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS" || cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS"
230234

@@ -236,6 +240,10 @@ jobs:
236240
name: Test hls-selection-range-plugin test suite
237241
run: cabal test hls-selection-range-plugin --test-options="$TEST_OPTS" || cabal test hls-selection-range-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-selection-range-plugin --test-options="$TEST_OPTS"
238242

243+
- if: matrix.test
244+
name: Test hls-change-type-signature test suite
245+
run: cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" || cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS"
246+
239247
test_post_job:
240248
if: always()
241249
runs-on: ubuntu-latest

bindist/GNUmakefile.in

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ BINDIR ?= $(PREFIX)/bin
55

66
HLS_VERSION := @@HLS_VERSION@@
77

8+
FIND := find
89
INSTALL := install
910
INSTALL_D := $(INSTALL) -d
1011
INSTALL_X := $(INSTALL) -vm 755
@@ -18,10 +19,7 @@ install:
1819
$(INSTALL_D) "$(DESTDIR)$(BINDIR)"
1920
$(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/lib"
2021
$(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin"
21-
for f in $(wildcard lib/*/*) ; do \
22-
$(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/`dirname $$f`" && \
23-
$(INSTALL_X) "$$f" "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$f" ; \
24-
done
22+
$(FIND) lib -mindepth 2 -type f -exec sh -c '$(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/`dirname $$1`" && $(INSTALL_X) "$$1" "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$1"' sh '{}' \;
2523
for b in $(wildcard bin/*) ; do \
2624
$(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/" && \
2725
$(INSTALL_X) "$$b" "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$b" ; \
@@ -31,7 +29,7 @@ install:
3129
"$$h" > "$(DESTDIR)$(BINDIR)/$${h%.in}" && \
3230
$(CHMOD_X) "$(DESTDIR)$(BINDIR)/$${h%.in}" ; \
3331
done
34-
$(LN_S) "`scripts/relpath.sh "$(BINDIR)" "$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/haskell-language-server-wrapper"`" \
32+
$(LN_S) "`scripts/relpath.sh "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/haskell-language-server-wrapper"`" \
3533
"$(DESTDIR)$(BINDIR)/haskell-language-server-wrapper"
3634

3735
version:

cabal-ghc90.project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ packages:
2727
./plugins/hls-call-hierarchy-plugin
2828
./plugins/hls-alternate-number-format-plugin
2929
./plugins/hls-selection-range-plugin
30+
./plugins/hls-change-type-signature-plugin
3031

3132
tests: true
3233

@@ -36,7 +37,7 @@ package *
3637

3738
write-ghc-environment-files: never
3839

39-
index-state: 2022-02-25T21:47:10Z
40+
index-state: 2022-03-08T10:53:01Z
4041

4142
constraints:
4243
-- These plugins don't work on GHC9 yet

cabal-ghc921.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ packages:
2727
./plugins/hls-call-hierarchy-plugin
2828
./plugins/hls-alternate-number-format-plugin
2929
./plugins/hls-selection-range-plugin
30+
./plugins/hls-change-type-signature-plugin
3031

3132
with-compiler: ghc-9.2.1
3233

@@ -38,14 +39,13 @@ package *
3839

3940
write-ghc-environment-files: never
4041

41-
index-state: 2022-02-25T21:47:10Z
42+
index-state: 2022-03-08T10:53:01Z
4243

4344
constraints:
4445
-- These plugins don't build/work on GHC92 yet
4546
haskell-language-server
4647
+ignore-plugins-ghc-bounds
4748
-brittany
48-
-class
4949
-haddockComments
5050
-hlint
5151
-retrie

cabal.project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ packages:
2727
./plugins/hls-alternate-number-format-plugin
2828
./plugins/hls-qualify-imported-names-plugin
2929
./plugins/hls-selection-range-plugin
30+
./plugins/hls-change-type-signature-plugin
3031

3132
-- Standard location for temporary packages needed for particular environments
3233
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
@@ -41,7 +42,7 @@ package *
4142

4243
write-ghc-environment-files: never
4344

44-
index-state: 2022-02-25T21:47:10Z
45+
index-state: 2022-03-08T10:53:01Z
4546

4647
constraints:
4748
hyphenation +embed

docs/features.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Many of these are standard LSP features, but a lot of special features are provi
1818
| [Highlight references](#highlight-references) | `textDocument/documentHighlight` |
1919
| [Code actions](#code-actions) | `textDocument/codeAction` |
2020
| [Code lenses](#code-lenses) | `textDocument/codeLens` |
21-
| [Selection range](#selection-range) | `textDocument/selectionRange` |
21+
| [Selection range](#selection-range) | `textDocument/selectionRange` |
2222

2323
The individual sections below also identify which [HLS plugin](./what-is-hls.md#hls-plugins) is responsible for providing the given functionality, which is useful if you want to raise an issue report or contribute!
2424
Additionally, not all plugins are supported on all versions of GHC, see the [GHC version support page](supported-versions.md) for details.
@@ -237,6 +237,26 @@ Provides a variety of code actions for interactive code development, see <https:
237237

238238
![Wingman Demo](https://user-images.githubusercontent.com/307223/92657198-3d4be400-f2a9-11ea-8ad3-f541c8eea891.gif)
239239

240+
### Change Type Signature
241+
242+
Provided by: `hls-change-type-signature-plugin`
243+
244+
Code action kind: `quickfix`
245+
246+
Change/Update a type signature to match implementation.
247+
248+
Status: Until GHC 9.4, the implementation is ad-hoc and relies on GHC error messages to create a new signature. Not all GHC error messages are supported.
249+
250+
Known Limitations:
251+
- Not all GHC error messages are supported
252+
- Top-level and Function-local bindings with the same names can cause issues, such as incorrect signature changes or no code actions available.
253+
254+
![Change Type Signature Demo](../plugins/hls-change-type-signature-plugin/change1.gif)
255+
256+
![Change Type Signature Demo](../plugins/hls-change-type-signature-plugin/change2.gif)
257+
258+
[Link to Docs](../plugins/hls-change-type-signature/README.md)
259+
240260
## Code lenses
241261

242262
### Add type signature

exe/Main.hs

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
{-# LANGUAGE OverloadedStrings #-}
55
module Main(main) where
66

7+
import Control.Monad.IO.Class (liftIO)
78
import Data.Function ((&))
8-
import Development.IDE.Types.Logger (Priority (Debug, Info),
9+
import Data.Text (Text)
10+
import qualified Development.IDE.Types.Logger as Logger
11+
import Development.IDE.Types.Logger (Priority (Debug, Info, Error),
912
WithPriority (WithPriority, priority),
1013
cfilter, cmapWithPrio,
1114
makeDefaultStderrRecorder,
12-
withDefaultRecorder)
15+
withDefaultRecorder, renderStrict, layoutPretty, defaultLayoutOptions, Doc)
1316
import Ide.Arguments (Arguments (..),
1417
GhcideArguments (..),
1518
getArguments)
1619
import Ide.Main (defaultMain)
1720
import qualified Ide.Main as IdeMain
21+
import Ide.PluginUtils (pluginDescToIdePlugins)
22+
import Ide.Types (PluginDescriptor (pluginNotificationHandlers), defaultPluginDescriptor, mkPluginNotificationHandler)
23+
import Language.LSP.Server as LSP
24+
import Language.LSP.Types as LSP
1825
import qualified Plugins
19-
import Prettyprinter (Pretty (pretty))
26+
import Prettyprinter (Pretty (pretty), vsep)
2027

2128
data Log
2229
= LogIdeMain IdeMain.Log
@@ -34,6 +41,16 @@ main = do
3441
pluginCliRecorder <- cmapWithPrio pretty <$> makeDefaultStderrRecorder Nothing Info
3542
args <- getArguments "haskell-language-server" (Plugins.idePlugins (cmapWithPrio LogPlugins pluginCliRecorder) False)
3643

44+
(lspLogRecorder, cb1) <- Logger.withBacklog Logger.lspClientLogRecorder
45+
(lspMessageRecorder, cb2) <- Logger.withBacklog Logger.lspClientMessageRecorder
46+
-- This plugin just installs a handler for the `initialized` notification, which then
47+
-- picks up the LSP environment and feeds it to our recorders
48+
let lspRecorderPlugin = (defaultPluginDescriptor "LSPRecorderCallback")
49+
{ pluginNotificationHandlers = mkPluginNotificationHandler LSP.SInitialized $ \_ _ _ -> do
50+
env <- LSP.getLspEnv
51+
liftIO $ (cb1 <> cb2) env
52+
}
53+
3754
let (minPriority, logFilePath, includeExamplePlugins) =
3855
case args of
3956
Ghcide GhcideArguments{ argsTesting, argsDebugOn, argsLogFile, argsExamplePlugin } ->
@@ -42,9 +59,29 @@ main = do
4259
_ -> (Info, Nothing, False)
4360

4461
withDefaultRecorder logFilePath Nothing minPriority $ \textWithPriorityRecorder -> do
45-
let recorder =
46-
textWithPriorityRecorder
47-
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
48-
& cmapWithPrio pretty
62+
let
63+
recorder = cmapWithPrio pretty $ mconcat
64+
[textWithPriorityRecorder
65+
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
66+
, lspMessageRecorder
67+
& cfilter (\WithPriority{ priority } -> priority >= Error)
68+
& cmapWithPrio renderDoc
69+
, lspLogRecorder
70+
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
71+
& cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions)
72+
]
73+
plugins = (Plugins.idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
74+
75+
defaultMain
76+
(cmapWithPrio LogIdeMain recorder)
77+
args
78+
(plugins <> pluginDescToIdePlugins [lspRecorderPlugin])
79+
80+
renderDoc :: Doc a -> Text
81+
renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vsep
82+
["Error condition, please check your setup and/or the [issue tracker](" <> issueTrackerUrl <> "): "
83+
,d
84+
]
4985

50-
defaultMain (cmapWithPrio LogIdeMain recorder) args (Plugins.idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
86+
issueTrackerUrl :: Doc a
87+
issueTrackerUrl = "https://github.com/haskell/haskell-language-server/issues"

exe/Plugins.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ import qualified Ide.Plugin.AlternateNumberFormat as AlternateNumberFormat
7979
import Ide.Plugin.SelectionRange as SelectionRange
8080
#endif
8181

82+
#if changeTypeSignature
83+
import Ide.Plugin.ChangeTypeSignature as ChangeTypeSignature
84+
#endif
8285
-- formatters
8386

8487
#if floskell
@@ -184,6 +187,9 @@ idePlugins recorder includeExamples = pluginDescToIdePlugins allPlugins
184187
#endif
185188
#if selectionRange
186189
SelectionRange.descriptor "selectionRange" :
190+
#endif
191+
#if changeTypeSignature
192+
ChangeTypeSignature.descriptor "changeTypeSignature" :
187193
#endif
188194
-- The ghcide descriptors should come last so that the notification handlers
189195
-- (which restart the Shake build) run after everything else

exe/Wrapper.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ launchHaskellLanguageServer parsedArgs = do
115115
#else
116116
let Cradle { cradleOptsProg = CradleAction { runGhcCmd } } = cradle
117117
-- we need to be compatible with NoImplicitPrelude
118-
ghcBinary <- (fmap trim <$> runGhcCmd ["-v0", "-package-env=-", "-e", "do e <- System.Environment.getExecutablePath ; System.IO.putStr e"])
118+
ghcBinary <- (fmap trim <$> runGhcCmd ["-v0", "-package-env=-", "-ignore-dot-ghci", "-e", "Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)"])
119119
>>= cradleResult "Failed to get project GHC executable path"
120120
libdir <- HieBios.getRuntimeGhcLibDir cradle
121121
>>= cradleResult "Failed to get project GHC libdir path"

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
flake = false;
6161
};
6262
hie-bios = {
63-
url = "https://hackage.haskell.org/package/hie-bios-0.9.0/hie-bios-0.9.0.tar.gz";
63+
url = "https://hackage.haskell.org/package/hie-bios-0.9.1/hie-bios-0.9.1.tar.gz";
6464
flake = false;
6565
};
6666
};
@@ -112,7 +112,7 @@
112112
with haskell.lib; {
113113
# Patches don't apply
114114
github = overrideCabal hsuper.github (drv: { patches = []; });
115-
# GHCIDE requires hie-bios ^>=0.9.0
115+
# GHCIDE requires hie-bios ^>=0.9.1
116116
hie-bios = hself.callCabal2nix "hie-bios" inputs.hie-bios {};
117117
# We need an older version
118118
hiedb = hself.hiedb_0_4_1_0;

0 commit comments

Comments
 (0)