Skip to content

Commit ec0bbd1

Browse files
authored
Remove interface loading diagnostics (#579)
* Drop interface loading diagnostics * No reason to skip the --test flag anymore
1 parent e16e841 commit ec0bbd1

File tree

5 files changed

+15
-60
lines changed

5 files changed

+15
-60
lines changed

exe/Main.hs

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ main = do
102102
, optShakeProfiling = argsShakeProfiling
103103
, optTesting = argsTesting
104104
, optThreads = argsThreads
105-
, optInterfaceLoadingDiagnostics = argsTesting
106105
}
107106
debouncer <- newAsyncDebouncer
108107
initialise caps (cradleRules >> mainRule >> pluginRules plugins >> action kick)

src/Development/IDE/Core/Rules.hs

+3-20
Original file line numberDiff line numberDiff line change
@@ -550,36 +550,19 @@ getHiFileRule = defineEarlyCutoff $ \GetHiFile f -> do
550550
HsBootFile -> addBootSuffix (ml_hi_file $ ms_location ms)
551551
_ -> ml_hi_file $ ms_location ms
552552

553-
IdeOptions{optInterfaceLoadingDiagnostics} <- getIdeOptions
554-
555-
let mkInterfaceFilesGenerationDiag f intro
556-
| optInterfaceLoadingDiagnostics = mkDiag $ intro <> msg
557-
| otherwise = []
558-
where
559-
msg =
560-
": additional resource use while generating interface files in the background."
561-
mkDiag = pure
562-
. ideErrorWithSource (Just "interface file loading") (Just DsInfo) f
563-
. T.pack
564-
565553
case sequence depHis of
566-
Nothing -> do
567-
let d = mkInterfaceFilesGenerationDiag f "Missing interface file dependencies"
568-
pure (Nothing, (d, Nothing))
554+
Nothing -> pure (Nothing, ([], Nothing))
569555
Just deps -> do
570556
gotHiFile <- getFileExists hiFile
571557
if not gotHiFile
572-
then do
573-
let d = mkInterfaceFilesGenerationDiag f "Missing interface file"
574-
pure (Nothing, (d, Nothing))
558+
then pure (Nothing, ([], Nothing))
575559
else do
576560
hiVersion <- use_ GetModificationTime hiFile
577561
modVersion <- use_ GetModificationTime f
578562
let sourceModified = modificationTime hiVersion < modificationTime modVersion
579563
if sourceModified
580564
then do
581-
let d = mkInterfaceFilesGenerationDiag f "Stale interface file"
582-
pure (Nothing, (d, Nothing))
565+
pure (Nothing, ([], Nothing))
583566
else do
584567
session <- hscEnv <$> use_ GhcSession f
585568
r <- liftIO $ loadInterface session ms deps

src/Development/IDE/Types/Options.hs

-3
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ data IdeOptions = IdeOptions
5858
-- features such as diagnostics and go-to-definition, in
5959
-- situations in which they would become unavailable because of
6060
-- the presence of type errors, holes or unbound variables.
61-
, optInterfaceLoadingDiagnostics :: Bool
62-
-- ^ Generate Info-level diagnostics to report interface loading actions
6361
}
6462

6563
data IdePreprocessedSource = IdePreprocessedSource
@@ -93,7 +91,6 @@ defaultIdeOptions session = IdeOptions
9391
,optKeywords = haskellKeywords
9492
,optDefer = IdeDefer True
9593
,optTesting = False
96-
,optInterfaceLoadingDiagnostics = False
9794
}
9895

9996

test/exe/Main.hs

+9-16
Original file line numberDiff line numberDiff line change
@@ -2033,8 +2033,8 @@ cradleTests = testGroup "cradle"
20332033

20342034
loadCradleOnlyonce :: TestTree
20352035
loadCradleOnlyonce = testGroup "load cradle only once"
2036-
[ testSessionTF "implicit" implicit
2037-
, testSessionTF "direct" direct
2036+
[ testSession' "implicit" implicit
2037+
, testSession' "direct" direct
20382038
]
20392039
where
20402040
direct dir = do
@@ -2143,10 +2143,7 @@ testSession :: String -> Session () -> TestTree
21432143
testSession name = testCase name . run
21442144

21452145
testSession' :: String -> (FilePath -> Session ()) -> TestTree
2146-
testSession' name = testCase name . run' NoTestFlag
2147-
2148-
testSessionTF :: String -> (FilePath -> Session ()) -> TestTree
2149-
testSessionTF name = testCase name . run' WithTestFlag
2146+
testSession' name = testCase name . run'
21502147

21512148
testSessionWait :: String -> Session () -> TestTree
21522149
testSessionWait name = testSession name .
@@ -2177,16 +2174,13 @@ mkRange :: Int -> Int -> Int -> Int -> Range
21772174
mkRange a b c d = Range (Position a b) (Position c d)
21782175

21792176
run :: Session a -> IO a
2180-
run s = withTempDir $ \dir -> runInDir NoTestFlag dir s
2181-
2182-
run' :: WithTestFlag -> (FilePath -> Session a) -> IO a
2183-
run' tf s = withTempDir $ \dir -> runInDir tf dir (s dir)
2177+
run s = withTempDir $ \dir -> runInDir dir s
21842178

2185-
-- Do we run the LSP executable with --test or not
2186-
data WithTestFlag = WithTestFlag | NoTestFlag deriving (Show, Eq)
2179+
run' :: (FilePath -> Session a) -> IO a
2180+
run' s = withTempDir $ \dir -> runInDir dir (s dir)
21872181

2188-
runInDir :: WithTestFlag -> FilePath -> Session a -> IO a
2189-
runInDir withTestFlag dir s = do
2182+
runInDir :: FilePath -> Session a -> IO a
2183+
runInDir dir s = do
21902184
ghcideExe <- locateGhcideExecutable
21912185

21922186
-- Temporarily hack around https://github.com/mpickering/hie-bios/pull/56
@@ -2199,8 +2193,7 @@ runInDir withTestFlag dir s = do
21992193
createDirectoryIfMissing True $ dir </> takeDirectory f
22002194
copyFile ("test/data" </> f) (dir </> f)
22012195

2202-
let cmd = unwords ([ghcideExe, "--lsp", "--cwd", dir]
2203-
++ [ "--test" | WithTestFlag == withTestFlag ])
2196+
let cmd = unwords [ghcideExe, "--lsp", "--test", "--cwd", dir]
22042197
-- HIE calls getXgdDirectory which assumes that HOME is set.
22052198
-- Only sets HOME if it wasn't already set.
22062199
setEnv "HOME" "/homeless-shelter" False

test/src/Development/IDE/Test.hs

+3-20
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Control.Applicative.Combinators
1616
import Control.Lens hiding (List)
1717
import Control.Monad
1818
import Control.Monad.IO.Class
19-
import Data.Foldable
2019
import qualified Data.Map.Strict as Map
2120
import qualified Data.Text as T
2221
import Language.Haskell.LSP.Test hiding (message)
@@ -74,17 +73,14 @@ expectNoMoreDiagnostics timeout = do
7473
ignoreOthers = void anyMessage >> handleMessages
7574

7675
expectDiagnostics :: [(FilePath, [(DiagnosticSeverity, Cursor, T.Text)])] -> Session ()
77-
expectDiagnostics = expectDiagnostics' diagnostic
78-
79-
expectDiagnostics' :: Session PublishDiagnosticsNotification -> [(FilePath, [(DiagnosticSeverity, Cursor, T.Text)])] -> Session ()
80-
expectDiagnostics' messageParser expected = do
76+
expectDiagnostics expected = do
8177
expected' <- Map.fromListWith (<>) <$> traverseOf (traverse . _1) (fmap toNormalizedUri . getDocUri) expected
8278
go expected'
8379
where
8480
go m
8581
| Map.null m = pure ()
8682
| otherwise = do
87-
diagsNot <- skipManyTill anyMessage messageParser
83+
diagsNot <- skipManyTill anyMessage diagnostic
8884
let fileUri = diagsNot ^. params . uri
8985
case Map.lookup (diagsNot ^. params . uri . to toNormalizedUri) m of
9086
Nothing -> do
@@ -103,21 +99,8 @@ expectDiagnostics' messageParser expected = do
10399
" but got " <> show actual
104100
go $ Map.delete (diagsNot ^. params . uri . to toNormalizedUri) m
105101

106-
-- | Matches all diagnostic messages except those from interface loading files
107102
diagnostic :: Session PublishDiagnosticsNotification
108-
diagnostic = do
109-
m <- LspTest.message
110-
let PublishDiagnosticsParams uri diags = _params (m :: PublishDiagnosticsNotification)
111-
let diags' = filter (\d -> _source (d:: Diagnostic) /= Just "interface file loading") (toList diags)
112-
-- interface loading warnings get sent on a first message,
113-
-- followed up by a second message including all other warnings.
114-
-- unless the debouncer merges them.
115-
-- This can lead to a test matching on the first message and missing
116-
-- the interesting warnings.
117-
-- Therefore we do not match messages containing only interface loading warnings,
118-
-- but, importantly, do match messages containing no warnings.
119-
guard (null diags || not (null diags'))
120-
return $ (m :: PublishDiagnosticsNotification){_params = PublishDiagnosticsParams uri (List diags')}
103+
diagnostic = LspTest.message
121104

122105
standardizeQuotes :: T.Text -> T.Text
123106
standardizeQuotes msg = let

0 commit comments

Comments
 (0)