Skip to content

Commit edb10a7

Browse files
authored
Merge branch 'master' into filter-atpoint-results
2 parents 66b2614 + 5d5f7e4 commit edb10a7

File tree

10 files changed

+91
-90
lines changed

10 files changed

+91
-90
lines changed

.github/actions/setup-build/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
runs:
2424
using: "composite"
2525
steps:
26-
- uses: haskell/actions/setup@v1
26+
- uses: haskell/actions/setup@v2
2727
id: HaskEnvSetup
2828
with:
2929
ghc-version : ${{ inputs.ghc }}
@@ -74,7 +74,7 @@ runs:
7474
# We have to restore package sources before `cabal update`
7575
# because it overwrites the hackage index with the cached one
7676
- name: Hackage sources cache
77-
uses: actions/cache@v2
77+
uses: actions/cache@v3
7878
env:
7979
cache-name: hackage-sources
8080
with:
@@ -99,7 +99,7 @@ runs:
9999

100100
- name: Compiled deps cache
101101
id: compiled-deps
102-
uses: actions/cache@v2
102+
uses: actions/cache@v3
103103
env:
104104
cache-name: compiled-deps
105105
with:

.github/workflows/caching.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ jobs:
8080
strategy:
8181
fail-fast: false
8282
matrix:
83-
ghc: [ "9.2.4"
83+
# This list of GHC versions must fit to the list of GHC versions
84+
# specified in 'test.yml'
85+
ghc: [ "9.4.2"
86+
, "9.4.1"
87+
, "9.2.4"
8488
, "9.2.3"
8589
, "9.0.2"
8690
, "8.10.7"
@@ -89,6 +93,9 @@ jobs:
8993
, "macOS-latest"
9094
, "windows-latest"
9195
]
96+
exclude:
97+
- os: windows-latest
98+
ghc: '9.4.1'
9299

93100
steps:
94101
- uses: actions/checkout@v3

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
- uses: actions/checkout@v3
2727
- uses: ./.github/actions/setup-build
2828
with:
29+
# select a stable GHC version
30+
ghc: 9.2.5
2931
os: ${{ runner.os }}
3032
shorten-hls: false
3133

.github/workflows/test.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
runs-on: ${{ matrix.os }}
5757
strategy:
5858
fail-fast: true
59+
# when you edit this list of GHC versions,
60+
# **don't forget**
61+
# to update the ghc versions in 'caching.yml'.
5962
matrix:
6063
ghc: [ "9.4.2"
6164
, "9.4.1"
@@ -66,7 +69,15 @@ jobs:
6669
]
6770
os: [ "ubuntu-latest"
6871
, "macOS-latest"
72+
, "windows-latest"
6973
]
74+
# don't build these versions
75+
# they are broken for good reasons, e.g. compiler is bugged
76+
# on that platform.
77+
exclude:
78+
- os: windows-latest
79+
ghc: '9.4.1'
80+
# Mark which GHC versions on which platform we want to test.
7081
include:
7182
# only test supported ghc major versions
7283
- os: ubuntu-latest
@@ -93,9 +104,6 @@ jobs:
93104
- os: windows-latest
94105
ghc: '8.10.7'
95106
test: true
96-
# only build rest of supported ghc versions for windows
97-
- os: windows-latest
98-
ghc: '9.2.3'
99107

100108
steps:
101109
- uses: actions/checkout@v3
@@ -115,7 +123,7 @@ jobs:
115123
run: |
116124
echo "TEST_OPTS=-j1 --rerun-update --rerun-filter failures,exceptions" >> $GITHUB_ENV
117125
118-
- name: Cache test log bewteen attempts of the same run
126+
- name: Cache test log between attempts of the same run
119127
uses: actions/cache@v3
120128
env:
121129
cache-name: cache-test-log

docs/contributing/releases.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Releases and distributable binaries
22

33
Starting with 0.2.1.0 haskell-language-server provides pre-built binaries on
4-
each [GitHub
5-
release](https://github.com/haskell/haskell-language-server/releases). These
6-
binaries are used by the [vscode-hie-server
7-
extension](https://github.com/alanz/vscode-hie-server) to provide automatic
8-
installation for users on VS Code, but they can also be installed manually
4+
each [GitHub release](https://github.com/haskell/haskell-language-server/releases).
5+
These binaries are used by the [vscode-haskell extension](https://github.com/haskell/vscode-haskell)
6+
to provide automatic installation for users on VS Code, but they can also be installed manually
97
when added to the path.
108

119
Starting with 0.8.0.0 haskell-language-server and all its related packages
12-
(core libraries like ghcide, plugins and hls itself) is being released in
10+
(core libraries like ghcide, plugins and hls itself) is being released on
1311
[hackage](https://hackage.haskell.org/package/haskell-language-server) as well.
14-
This allow cabal users to install it with `cabal install haskell-language-server`
12+
This allows cabal users to install it with `cabal install haskell-language-server`
1513
and it is being used in nix environments.
1614

15+
Since 1.7.0.0, HLS binaries are no longer uploaded to GitHub but to [downloads.haskell.org](https://downloads.haskell.org/~hls/).
16+
[GHCup](https://www.haskell.org/ghcup/) uses these binaries to enable automatic installation of HLS binaries in
17+
various lsp-client plugins, such as [vscode-haskell](https://github.com/haskell/vscode-haskell).
18+
1719
## Minimal checklist
1820

1921
### prerelease sanity checks

hls-test-utils/src/Test/Hls/Util.hs

Lines changed: 19 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,40 @@
66
{-# LANGUAGE OverloadedStrings #-}
77
{-# LANGUAGE TypeOperators #-}
88
module Test.Hls.Util
9-
(
9+
( -- * Test Capabilities
1010
codeActionSupportCaps
1111
, expectCodeAction
12-
, dontExpectCodeAction
13-
, expectDiagnostic
14-
, expectNoMoreDiagnostics
15-
, expectSameLocations
16-
, failIfSessionTimeout
17-
, flushStackEnvironment
18-
, fromAction
19-
, fromCommand
20-
, getCompletionByLabel
12+
-- * Environment specifications
13+
-- for ignoring tests
2114
, ghcVersion, GhcVersion(..)
2215
, hostOS, OS(..)
2316
, matchesCurrentEnv, EnvSpec(..)
24-
, noLiteralCaps
2517
, ignoreForGhcVersions
2618
, ignoreInEnv
2719
, onlyRunForGhcVersions
28-
, inspectCodeAction
29-
, inspectCommand
30-
, inspectDiagnostic
3120
, knownBrokenOnWindows
3221
, knownBrokenForGhcVersions
3322
, knownBrokenInEnv
3423
, onlyWorkForGhcVersions
35-
, setupBuildToolFiles
24+
-- * Extract code actions
25+
, fromAction
26+
, fromCommand
27+
-- * Session Assertion Helpers
28+
, dontExpectCodeAction
29+
, expectDiagnostic
30+
, expectNoMoreDiagnostics
31+
, expectSameLocations
32+
, failIfSessionTimeout
33+
, getCompletionByLabel
34+
, noLiteralCaps
35+
, inspectCodeAction
36+
, inspectCommand
37+
, inspectDiagnostic
3638
, SymbolLocation
3739
, waitForDiagnosticsFrom
3840
, waitForDiagnosticsFromSource
3941
, waitForDiagnosticsFromSourceWithTimeout
42+
-- * Temporary directories
4043
, withCurrentDirectoryInTmp
4144
, withCurrentDirectoryInTmp'
4245
, withCanonicalTempDir
@@ -61,7 +64,6 @@ import qualified Language.LSP.Types.Capabilities as C
6164
import Language.LSP.Types.Lens (textDocument)
6265
import qualified Language.LSP.Types.Lens as L
6366
import System.Directory
64-
import System.Environment
6567
import System.FilePath
6668
import System.Info.Extra (isMac, isWindows)
6769
import qualified System.IO.Extra
@@ -87,34 +89,9 @@ codeActionSupportCaps = def & textDocument ?~ textDocumentCaps
8789
literalSupport = CodeActionLiteralSupport def
8890

8991
-- ---------------------------------------------------------------------
90-
91-
setupBuildToolFiles :: IO ()
92-
setupBuildToolFiles = do
93-
forM_ files setupDirectFilesIn
94-
95-
setupDirectFilesIn :: FilePath -> IO ()
96-
setupDirectFilesIn f =
97-
writeFile (f ++ "hie.yaml") hieYamlCradleDirectContents
98-
99-
92+
-- Environment specification for ignoring tests
10093
-- ---------------------------------------------------------------------
10194

102-
files :: [FilePath]
103-
files =
104-
[ "./test/testdata/"
105-
-- , "./test/testdata/addPackageTest/cabal-exe/"
106-
-- , "./test/testdata/addPackageTest/hpack-exe/"
107-
-- , "./test/testdata/addPackageTest/cabal-lib/"
108-
-- , "./test/testdata/addPackageTest/hpack-lib/"
109-
-- , "./test/testdata/addPragmas/"
110-
-- , "./test/testdata/badProjects/cabal/"
111-
-- , "./test/testdata/completion/"
112-
-- , "./test/testdata/definition/"
113-
-- , "./test/testdata/gototest/"
114-
-- , "./test/testdata/redundantImportTest/"
115-
-- , "./test/testdata/wErrorTest/"
116-
]
117-
11895
data EnvSpec = HostOS OS | GhcVer GhcVersion
11996
deriving (Show, Eq)
12097

@@ -168,30 +145,6 @@ onlyRunForGhcVersions vers =
168145

169146
-- ---------------------------------------------------------------------
170147

171-
hieYamlCradleDirectContents :: String
172-
hieYamlCradleDirectContents = unlines
173-
[ "# WARNING: THIS FILE IS AUTOGENERATED IN test/utils/TestUtils.hs. IT WILL BE OVERWRITTEN ON EVERY TEST RUN"
174-
, "cradle:"
175-
, " direct:"
176-
, " arguments:"
177-
, " - -i."
178-
]
179-
180-
181-
-- ---------------------------------------------------------------------
182-
183-
flushStackEnvironment :: IO ()
184-
flushStackEnvironment = do
185-
-- We need to clear these environment variables to prevent
186-
-- collisions with stack usages
187-
-- See https://github.com/commercialhaskell/stack/issues/4875
188-
unsetEnv "GHC_PACKAGE_PATH"
189-
unsetEnv "GHC_ENVIRONMENT"
190-
unsetEnv "HASKELL_PACKAGE_SANDBOX"
191-
unsetEnv "HASKELL_PACKAGE_SANDBOXES"
192-
193-
-- ---------------------------------------------------------------------
194-
195148
-- | Like 'withCurrentDirectory', but will copy the directory over to the system
196149
-- temporary directory first to avoid haskell-language-server's source tree from
197150
-- interfering with the cradle.

plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,19 @@ smallerRangesForBindingExport lies b =
18411841
ranges' _ = []
18421842

18431843
rangesForBinding' :: String -> LIE GhcPs -> [SrcSpan]
1844-
rangesForBinding' b (L (locA -> l) x@IEVar{}) | T.unpack (printOutputable x) == b = [l]
1844+
#if !MIN_VERSION_ghc(9,2,0)
1845+
rangesForBinding' b (L (locA -> l) (IEVar _ nm))
1846+
| L _ (IEPattern (L _ b')) <- nm
1847+
, T.unpack (printOutputable b') == b
1848+
= [l]
1849+
#else
1850+
rangesForBinding' b (L (locA -> l) (IEVar _ nm))
1851+
| L _ (IEPattern _ (L _ b')) <- nm
1852+
, T.unpack (printOutputable b') == b
1853+
= [l]
1854+
#endif
1855+
rangesForBinding' b (L (locA -> l) x@IEVar{})
1856+
| T.unpack (printOutputable x) == b = [l]
18451857
rangesForBinding' b (L (locA -> l) x@IEThingAbs{}) | T.unpack (printOutputable x) == b = [l]
18461858
rangesForBinding' b (L (locA -> l) (IEThingAll _ x)) | T.unpack (printOutputable x) == b = [l]
18471859
#if !MIN_VERSION_ghc(9,2,0)

test/functional/FunctionalCodeAction.hs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ importTests = testGroup "import suggestions" [
106106
packageTests :: TestTree
107107
packageTests = testGroup "add package suggestions" [
108108
ignoreTestBecause "no support for adding dependent packages via code action" $ testCase "adds to .cabal files" $ do
109-
flushStackEnvironment
110109
runSession hlsCommand fullCaps "test/testdata/addPackageTest/cabal-exe" $ do
111110
doc <- openDoc "AddPackage.hs" "haskell"
112111

@@ -177,16 +176,21 @@ redundantImportTests = testGroup "redundant import code actions" [
177176
doc <- openDoc "src/CodeActionRedundant.hs" "haskell"
178177

179178
diags <- waitForDiagnosticsFromSource doc "typecheck"
180-
liftIO $ expectDiagnostic diags ["The import of", "Data.List", "is redundant"]
179+
liftIO $ expectDiagnostic diags [ "The import of", "Data.List", "is redundant" ]
180+
liftIO $ expectDiagnostic diags [ "Empty", "from module", "Data.Sequence" ]
181181

182182
mActions <- getAllCodeActions doc
183183

184184
let allActions = map fromAction mActions
185185
actionTitles = map (view L.title) allActions
186186

187-
liftIO $ actionTitles `shouldContain` ["Remove import", "Remove all redundant imports"]
187+
liftIO $ actionTitles `shouldContain`
188+
[ "Remove import"
189+
, "Remove Empty from import"
190+
, "Remove all redundant imports"
191+
]
188192

189-
let mbRemoveAction = find (\x -> x ^. L.title == "Remove import") allActions
193+
let mbRemoveAction = find (\x -> x ^. L.title == "Remove all redundant imports") allActions
190194

191195
case mbRemoveAction of
192196
Just removeAction -> do
@@ -203,7 +207,17 @@ redundantImportTests = testGroup "redundant import code actions" [
203207
-- provides workspace edit property which skips round trip to
204208
-- the server
205209
contents <- documentContents doc
206-
liftIO $ contents @?= "{-# OPTIONS_GHC -Wunused-imports #-}\nmodule CodeActionRedundant where\nmain :: IO ()\nmain = putStrLn \"hello\"\n"
210+
liftIO $ contents @?= T.unlines
211+
[ "{-# OPTIONS_GHC -Wunused-imports #-}"
212+
, "{-# LANGUAGE PatternSynonyms #-}"
213+
, "module CodeActionRedundant where"
214+
, "-- We need a non-reduntant import in the import list"
215+
, "-- to properly test the removal of the singular redundant item"
216+
, "import Data.Sequence (singleton)"
217+
, "main :: IO ()"
218+
, "main = putStrLn \"hello\""
219+
, " where unused = Data.Sequence.singleton 42"
220+
]
207221

208222
, testCase "doesn't touch other imports" $ runSession hlsCommand noLiteralCaps "test/testdata/redundantImportTest/" $ do
209223
doc <- openDoc "src/MultipleImports.hs" "haskell"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{-# OPTIONS_GHC -Wunused-imports #-}
2+
{-# LANGUAGE PatternSynonyms #-}
23
module CodeActionRedundant where
34
import Data.List
5+
-- We need a non-reduntant import in the import list
6+
-- to properly test the removal of the singular redundant item
7+
import Data.Sequence (pattern Empty, singleton)
48
main :: IO ()
59
main = putStrLn "hello"
10+
where unused = Data.Sequence.singleton 42

test/wrapper/Main.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import System.Process
55
import Test.Hls
66

77
main :: IO ()
8-
main = do
9-
flushStackEnvironment
10-
defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]
8+
main = defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]
119

1210
projectGhcVersionTests :: TestTree
1311
projectGhcVersionTests = testGroup "--project-ghc-version"

0 commit comments

Comments
 (0)