Skip to content

Commit f2d997d

Browse files
authored
Merge branch 'master' into cabal-completions-imports
2 parents 2f3680b + c3236eb commit f2d997d

File tree

9 files changed

+110
-130
lines changed

9 files changed

+110
-130
lines changed

ghcide/ghcide.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ library
7474
, ghc >=9.2
7575
, ghc-boot
7676
, ghc-boot-th
77-
, ghc-check >=0.5.0.8
78-
, ghc-paths
7977
, ghc-trace-events
8078
, Glob
8179
, haddock-library >=1.8 && <1.12
@@ -205,7 +203,6 @@ library
205203
Development.IDE.Core.FileExists
206204
Development.IDE.GHC.CPP
207205
Development.IDE.GHC.Warnings
208-
Development.IDE.Session.VersionCheck
209206
Development.IDE.Types.Action
210207

211208
if flag(pedantic)

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 82 additions & 95 deletions
Large diffs are not rendered by default.

ghcide/session-loader/Development/IDE/Session/VersionCheck.hs

Lines changed: 0 additions & 15 deletions
This file was deleted.

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ import Compat.HieTypes hiding
133133
(nodeAnnotations)
134134
import qualified Compat.HieTypes as GHC (nodeAnnotations)
135135
import Compat.HieUtils
136+
import Control.Applicative ((<|>))
136137
import qualified Data.ByteString as BS
137138
import Data.Coerce (coerce)
138139
import Data.List (foldl')
@@ -434,7 +435,7 @@ setHieDir _f d = d { hieDir = Just _f}
434435
dontWriteHieFiles :: DynFlags -> DynFlags
435436
dontWriteHieFiles d = gopt_unset d Opt_WriteHie
436437

437-
setUpTypedHoles ::DynFlags -> DynFlags
438+
setUpTypedHoles :: DynFlags -> DynFlags
438439
setUpTypedHoles df
439440
= flip gopt_unset Opt_AbstractRefHoleFits -- too spammy
440441
$ flip gopt_unset Opt_ShowDocsOfHoleFits -- not used
@@ -447,9 +448,13 @@ setUpTypedHoles df
447448
$ flip gopt_unset Opt_SortValidHoleFits
448449
$ flip gopt_unset Opt_UnclutterValidHoleFits
449450
$ df
450-
{ refLevelHoleFits = Just 1 -- becomes slow at higher levels
451-
, maxRefHoleFits = Just 10 -- quantity does not impact speed
452-
, maxValidHoleFits = Nothing -- quantity does not impact speed
451+
{ refLevelHoleFits = refLevelHoleFits df <|> Just 1 -- becomes slow at higher levels
452+
453+
-- Sometimes GHC can emit a lot of hole fits, this causes editors to be slow
454+
-- or just crash, we limit the hole fits to 10. The number was chosen
455+
-- arbirtarily by the author.
456+
, maxRefHoleFits = maxRefHoleFits df <|> Just 10
457+
, maxValidHoleFits = maxValidHoleFits df <|> Just 10
453458
}
454459

455460

ghcide/src/Development/IDE/Import/FindImports.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,17 @@ locateModule
131131
-> m (Either [FileDiagnostic] Import)
132132
locateModule env comp_info exts targetFor modName mbPkgName isSource = do
133133
case mbPkgName of
134-
-- "this" means that we should only look in the current package
135134
#if MIN_VERSION_ghc(9,3,0)
136-
ThisPkg _ -> do
135+
-- 'ThisPkg' just means some home module, not the current unit
136+
ThisPkg uid
137+
| Just (dirs, reexports) <- lookup uid import_paths
138+
-> lookupLocal uid dirs reexports
139+
| otherwise -> return $ Left $ notFoundErr env modName $ LookupNotFound []
137140
#else
141+
-- "this" means that we should only look in the current package
138142
Just "this" -> do
139-
#endif
140143
lookupLocal (homeUnitId_ dflags) (importPaths dflags) S.empty
144+
#endif
141145
-- if a package name is given we only go look for a package
142146
#if MIN_VERSION_ghc(9,3,0)
143147
OtherPkg uid

ghcide/test/data/multi-unit/b-1.0.0-inplace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ a-1.0.0-inplace
1616
-package
1717
base
1818
-XHaskell98
19+
-XPackageImports
1920
B

ghcide/test/data/multi-unit/b/B.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module B(module B) where
2-
import A
2+
import "a" A
33
qux = foo

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ processHoleSuggestions mm = (holeSuggestions, refSuggestions)
6969
(mrAfter . (=~ t " *Valid (hole fits|substitutions) include"))
7070
validHolesSection
7171
let holeFit = T.strip $ T.takeWhile (/= ':') holeFitLine
72-
guard (not $ T.null holeFit)
72+
guard $ not $ holeFit =~ t "Some hole fits suppressed"
73+
guard $ not $ T.null holeFit
7374
return holeFit
7475
refSuggestions = do -- @[]
7576
-- get the text indented under Valid refinement hole fits

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,29 +2640,29 @@ fillTypedHoleTests = let
26402640
, testSession "postfix hole uses postfix notation of infix operator" $ do
26412641
let mkDoc x = T.unlines
26422642
[ "module Testing where"
2643-
, "test :: Int -> Int -> Int"
2644-
, "test a1 a2 = " <> x <> " a1 a2"
2643+
, "test :: Int -> Maybe Int -> Maybe Int"
2644+
, "test a ma = " <> x <> " (a +) ma"
26452645
]
26462646
doc <- createDoc "Test.hs" "haskell" $ mkDoc "_"
26472647
_ <- waitForDiagnostics
26482648
actions <- getCodeActions doc (Range (Position 2 13) (Position 2 14))
2649-
chosen <- pickActionWithTitle "replace _ with (+)" actions
2649+
chosen <- pickActionWithTitle "replace _ with (<$>)" actions
26502650
executeCodeAction chosen
26512651
modifiedCode <- documentContents doc
2652-
liftIO $ mkDoc "(+)" @=? modifiedCode
2652+
liftIO $ mkDoc "(<$>)" @=? modifiedCode
26532653
, testSession "filling infix type hole uses infix operator" $ do
26542654
let mkDoc x = T.unlines
26552655
[ "module Testing where"
2656-
, "test :: Int -> Int -> Int"
2657-
, "test a1 a2 = a1 " <> x <> " a2"
2656+
, "test :: Int -> Maybe Int -> Maybe Int"
2657+
, "test a ma = (a +) " <> x <> " ma"
26582658
]
26592659
doc <- createDoc "Test.hs" "haskell" $ mkDoc "`_`"
26602660
_ <- waitForDiagnostics
26612661
actions <- getCodeActions doc (Range (Position 2 16) (Position 2 19))
2662-
chosen <- pickActionWithTitle "replace _ with (+)" actions
2662+
chosen <- pickActionWithTitle "replace _ with (<$>)" actions
26632663
executeCodeAction chosen
26642664
modifiedCode <- documentContents doc
2665-
liftIO $ mkDoc "+" @=? modifiedCode
2665+
liftIO $ mkDoc "<$>" @=? modifiedCode
26662666
]
26672667

26682668
addInstanceConstraintTests :: TestTree

0 commit comments

Comments
 (0)