Skip to content

Commit af9cd22

Browse files
authored
Merge branch 'master' into support-structured-diagnostics
2 parents f4d5c24 + fea0135 commit af9cd22

File tree

16 files changed

+117
-29
lines changed

16 files changed

+117
-29
lines changed

.github/mergify.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,19 @@ queue_rules:
22
- name: default
33
# Mergify always respects the branch protection settings
44
# so we can left empty mergify own ones
5-
conditions: []
6-
7-
pull_request_rules:
8-
- name: Automatically merge pull requests
9-
conditions:
5+
queue_conditions:
106
- label=merge me
117
- '#approved-reviews-by>=1'
12-
actions:
13-
queue:
14-
method: squash
15-
name: default
16-
# The queue action automatically updates PRs that
17-
# have entered the queue, but in order to do that
18-
# they must have passed CI. Since our CI is a bit
19-
# flaky, PRs can fail to get in, which then means
20-
# they don't get updated, which is extra annoying.
21-
# This just adds the updating as an independent
22-
# step.
8+
merge_conditions: []
9+
merge_method: squash
10+
11+
pull_request_rules:
2312
- name: Automatically update pull requests
2413
conditions:
2514
- label=merge me
2615
actions:
2716
update:
17+
- name: refactored queue action rule
18+
conditions: []
19+
actions:
20+
queue:

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ packages:
88
./hls-test-utils
99

1010

11-
index-state: 2024-10-21T00:00:00Z
11+
index-state: 2024-11-02T00:00:00Z
1212

1313
tests: True
1414
test-show-details: direct

ghcide/src/Development/IDE/GHC/Compat/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ initObjLinker env =
674674
loadDLL :: HscEnv -> String -> IO (Maybe String)
675675
loadDLL env str = do
676676
res <- GHCi.loadDLL (GHCi.hscInterp env) str
677-
#if MIN_VERSION_ghc(9,11,0)
677+
#if MIN_VERSION_ghc(9,11,0) || (MIN_VERSION_ghc(9, 8, 3) && !MIN_VERSION_ghc(9, 9, 0))
678678
pure $
679679
case res of
680680
Left err_msg -> Just err_msg

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/CabalAdd.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath caba
156156
-- | Gives the build targets that are used in the `CabalAdd`.
157157
-- Note the unorthodox usage of `readBuildTargets`:
158158
-- If the relative path to the haskell file is provided,
159-
-- the `readBuildTargets` will return a main build target.
160-
-- This behaviour is acceptable for now, but changing to a way of getting
161-
-- all build targets in a file is advised.
159+
-- the `readBuildTargets` will return build targets, where this
160+
-- module is mentioned (in exposed-modules or other-modules).
162161
getBuildTargets :: GenericPackageDescription -> FilePath -> FilePath -> IO [BuildTarget]
163162
getBuildTargets gpd cabalFilePath haskellFilePath = do
164163
let haskellFileRelativePath = makeRelative (dropFileName cabalFilePath) haskellFilePath
@@ -167,10 +166,10 @@ addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath caba
167166
mkCodeAction :: FilePath -> Maybe String -> (T.Text, T.Text) -> CodeAction
168167
mkCodeAction cabalFilePath target (suggestedDep, suggestedVersion) =
169168
let
170-
versionTitle = if T.null suggestedVersion then T.empty else " version " <> suggestedVersion
169+
versionTitle = if T.null suggestedVersion then T.empty else "-" <> suggestedVersion
171170
targetTitle = case target of
172171
Nothing -> T.empty
173-
Just t -> " target " <> T.pack t
172+
Just t -> " at " <> T.pack t
174173
title = "Add dependency " <> suggestedDep <> versionTitle <> targetTitle
175174
version = if T.null suggestedVersion then Nothing else Just suggestedVersion
176175

plugins/hls-cabal-plugin/test/CabalAdd.hs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,30 @@ cabalAddTests :: TestTree
2727
cabalAddTests =
2828
testGroup
2929
"CabalAdd Tests"
30-
[ runHaskellTestCaseSession "Code Actions - Can add hidden package" ("cabal-add-testdata" </> "cabal-add-exe")
30+
[ runHaskellTestCaseSession "Code Actions - Can add hidden package to an executable" ("cabal-add-testdata" </> "cabal-add-exe")
3131
(generateAddDependencyTestSession "cabal-add-exe.cabal" ("src" </> "Main.hs") "split" [253])
32-
, runHaskellTestCaseSession "Code Actions - Guard against HPack" ("cabal-add-testdata" </> "cabal-add-packageYaml")
33-
(generatePackageYAMLTestSession ("src" </> "Main.hs"))
3432
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a library" ("cabal-add-testdata" </> "cabal-add-lib")
3533
(generateAddDependencyTestSession "cabal-add-lib.cabal" ("src" </> "MyLib.hs") "split" [348])
3634
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a test" ("cabal-add-testdata" </> "cabal-add-tests")
3735
(generateAddDependencyTestSession "cabal-add-tests.cabal" ("test" </> "Main.hs") "split" [478])
3836
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a benchmark" ("cabal-add-testdata" </> "cabal-add-bench")
3937
(generateAddDependencyTestSession "cabal-add-bench.cabal" ("bench" </> "Main.hs") "split" [403])
38+
39+
, runHaskellTestCaseSession "Code Actions - Can add hidden package to an executable, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
40+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("src" </> "Main.hs") "split" [269])
41+
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a library, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
42+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("lib" </> "MyLib.hs") "split" [413])
43+
, runHaskellTestCaseSession "Code Actions - Can add hidden package to an internal library, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
44+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("lib" </> "InternalLib.hs") "split" [413])
45+
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a test, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
46+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("test" </> "Main.hs") "split" [655])
47+
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a benchmark, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
48+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("bench" </> "Main.hs") "split" [776])
49+
50+
51+
, runHaskellTestCaseSession "Code Actions - Guard against HPack" ("cabal-add-testdata" </> "cabal-add-packageYaml")
52+
(generatePackageYAMLTestSession ("src" </> "Main.hs"))
53+
4054
, testHiddenPackageSuggestions "Check CabalAdd's parser, no version"
4155
[ "It is a member of the hidden package 'base'"
4256
, "It is a member of the hidden package 'Blammo-wai'"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Main (main) where
2+
3+
import Data.List.Split
4+
5+
main :: IO ()
6+
main = putStrLn "Test suite not yet implemented."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
cabal-version: 2.4
2+
name: cabal-add-multitarget
3+
version: 0.1.0.0
4+
build-type: Simple
5+
6+
executable cabal-add-exe
7+
main-is: Main.hs
8+
hs-source-dirs: src
9+
ghc-options: -Wall
10+
build-depends: base
11+
default-language: Haskell2010
12+
13+
library
14+
exposed-modules: MyLib
15+
other-modules: InternalLib
16+
build-depends: base >= 4 && < 5
17+
hs-source-dirs: lib
18+
ghc-options: -Wall
19+
20+
test-suite cabal-add-tests-test
21+
main-is: Main.hs
22+
hs-source-dirs: test
23+
type: exitcode-stdio-1.0
24+
build-depends: base
25+
default-language: Haskell2010
26+
27+
benchmark benchmark
28+
main-is: Main.hs
29+
build-depends: base
30+
hs-source-dirs: bench
31+
type: exitcode-stdio-1.0
32+
ghc-options: -threaded
33+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module InternalLib (internalFunc) where
2+
3+
import Data.List.Split
4+
5+
internalFunc :: IO ()
6+
internalFunc = putStrLn "internalFunc"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module MyLib (someFunc) where
2+
3+
import Data.List.Split
4+
5+
someFunc :: IO ()
6+
someFunc = putStrLn "someFunc"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main where
2+
3+
import Data.List.Split
4+
5+
main = putStrLn "Hello, Haskell!"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Main (main) where
2+
3+
import Data.List.Split
4+
5+
main :: IO ()
6+
main = putStrLn "Test suite not yet implemented."

plugins/hls-cabal-plugin/test/testdata/cabal-add-testdata/cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ packages: cabal-add-exe
22
cabal-add-lib
33
cabal-add-tests
44
cabal-add-bench
5+
cabal-add-multitarget
56
cabal-add-packageYaml

plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ suggestDisableWarning diagnostic
128128
pure ("Disable \"" <> w <> "\" warnings", OptGHC w)
129129
| otherwise = []
130130

131-
-- Don't suggest disabling type errors as a solution to all type errors
132131
warningBlacklist :: [T.Text]
133-
warningBlacklist = ["deferred-type-errors"]
132+
warningBlacklist =
133+
-- Don't suggest disabling type errors as a solution to all type errors.
134+
[ "deferred-type-errors"
135+
-- Don't suggest disabling out of scope errors as a solution to all out of scope errors.
136+
, "deferred-out-of-scope-variables"
137+
]
134138

135139
-- ---------------------------------------------------------------------
136140

plugins/hls-pragmas-plugin/test/Main.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,16 @@ codeActionTests' =
109109
_ -> assertFailure $ "Expected one code action, but got: " <> show cas
110110
liftIO $ (ca ^. L.title == "Add \"NamedFieldPuns\"") @? "NamedFieldPuns code action"
111111
executeCodeAction ca
112-
, goldenWithPragmas pragmasSuggestPlugin "doesn't suggest disabling type errors" "DeferredTypeErrors" $ \doc -> do
112+
, goldenWithPragmas pragmasDisableWarningPlugin "doesn't suggest disabling type errors" "DeferredTypeErrors" $ \doc -> do
113113
_ <- waitForDiagnosticsFrom doc
114114
cas <- map fromAction <$> getAllCodeActions doc
115115
liftIO $ "Disable \"deferred-type-errors\" warnings" `notElem` map (^. L.title) cas @? "Doesn't contain deferred-type-errors code action"
116116
liftIO $ length cas == 0 @? "Expected no code actions, but got: " <> show cas
117+
, goldenWithPragmas pragmasDisableWarningPlugin "doesn't suggest disabling out of scope variables" "DeferredOutOfScopeVariables" $ \doc -> do
118+
_ <- waitForDiagnosticsFrom doc
119+
cas <- map fromAction <$> getAllCodeActions doc
120+
liftIO $ "Disable \"deferred-out-of-scope-variables\" warnings" `notElem` map (^. L.title) cas @? "Doesn't contain deferred-out-of-scope-variables code action"
121+
liftIO $ length cas == 0 @? "Expected no code actions, but got: " <> show cas
117122
]
118123

119124
completionTests :: TestTree
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module DeferredOutOfScopeVariables where
2+
3+
f :: ()
4+
f = let x = Doesn'tExist
5+
in undefined
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module DeferredOutOfScopeVariables where
2+
3+
f :: ()
4+
f = let x = Doesn'tExist
5+
in undefined

0 commit comments

Comments
 (0)