@@ -169,13 +169,13 @@ usesE :: IdeRule k v => k -> [NormalizedFilePath] -> MaybeT IdeAction [(v,Positi
169
169
usesE k = MaybeT . fmap sequence . mapM (useWithStaleFast k)
170
170
171
171
defineNoFile :: IdeRule k v => (k -> Action v ) -> Rules ()
172
- defineNoFile f = define $ \ k file -> do
173
- if file == emptyFilePath then do res <- f k; return ([] , Just res) else
172
+ defineNoFile f = defineNoDiagnostics $ \ k file -> do
173
+ if file == emptyFilePath then do res <- f k; return (Just res) else
174
174
fail $ " Rule " ++ show k ++ " should always be called with the empty string for a file"
175
175
176
176
defineEarlyCutOffNoFile :: IdeRule k v => (k -> Action (BS. ByteString , v )) -> Rules ()
177
- defineEarlyCutOffNoFile f = defineEarlyCutoff $ \ k file -> do
178
- if file == emptyFilePath then do (hash, res) <- f k; return (Just hash, ( [] , Just res) ) else
177
+ defineEarlyCutOffNoFile f = defineEarlyCutoff $ RuleNoDiagnostics $ \ k file -> do
178
+ if file == emptyFilePath then do (hash, res) <- f k; return (Just hash, Just res) else
179
179
fail $ " Rule " ++ show k ++ " should always be called with the empty string for a file"
180
180
181
181
------------------------------------------------------------
@@ -308,7 +308,7 @@ priorityFilesOfInterest = Priority (-2)
308
308
-- and https://github.com/mpickering/ghcide/pull/22#issuecomment-625070490
309
309
-- GHC wiki about: https://gitlab.haskell.org/ghc/ghc/-/wikis/api-annotations
310
310
getParsedModuleRule :: Rules ()
311
- getParsedModuleRule = defineEarlyCutoff $ \ GetParsedModule file -> do
311
+ getParsedModuleRule = defineEarlyCutoff $ Rule $ \ GetParsedModule file -> do
312
312
ModSummaryResult {msrModSummary = ms} <- use_ GetModSummary file
313
313
sess <- use_ GhcSession file
314
314
let hsc = hscEnv sess
@@ -372,8 +372,9 @@ mergeParseErrorsHaddock normal haddock = normal ++
372
372
-- | This rule provides a ParsedModule preserving all annotations,
373
373
-- including keywords, punctuation and comments.
374
374
-- So it is suitable for use cases where you need a perfect edit.
375
+ -- FIXME this rule should probably not produce diagnostics
375
376
getParsedModuleWithCommentsRule :: Rules ()
376
- getParsedModuleWithCommentsRule = defineEarlyCutoff $ \ GetParsedModuleWithComments file -> do
377
+ getParsedModuleWithCommentsRule = defineEarlyCutoff $ Rule $ \ GetParsedModuleWithComments file -> do
377
378
ModSummaryResult {msrModSummary = ms} <- use_ GetModSummary file
378
379
sess <- use_ GhcSession file
379
380
opt <- getIdeOptions
@@ -569,13 +570,13 @@ reportImportCyclesRule =
569
570
-- NOTE: result does not include the argument file.
570
571
getDependenciesRule :: Rules ()
571
572
getDependenciesRule =
572
- defineEarlyCutoff $ \ GetDependencies file -> do
573
+ defineEarlyCutoff $ RuleNoDiagnostics $ \ GetDependencies file -> do
573
574
depInfo <- use_ GetDependencyInformation file
574
575
let allFiles = reachableModules depInfo
575
576
_ <- uses_ ReportImportCycles allFiles
576
577
opts <- getIdeOptions
577
578
let mbFingerprints = map (fingerprintString . fromNormalizedFilePath) allFiles <$ optShakeFiles opts
578
- return (fingerprintToBS . fingerprintFingerprints <$> mbFingerprints, ( [] , transitiveDeps depInfo file) )
579
+ return (fingerprintToBS . fingerprintFingerprints <$> mbFingerprints, transitiveDeps depInfo file)
579
580
580
581
getHieAstsRule :: Rules ()
581
582
getHieAstsRule =
@@ -739,7 +740,7 @@ loadGhcSession = do
739
740
let fingerprint = hash (sessionVersion res)
740
741
return (BS. pack (show fingerprint), res)
741
742
742
- defineEarlyCutoff $ \ GhcSession file -> do
743
+ defineEarlyCutoff $ Rule $ \ GhcSession file -> do
743
744
IdeGhcSession {loadSessionFun} <- useNoFile_ GhcSessionIO
744
745
(val,deps) <- liftIO $ loadSessionFun $ fromNormalizedFilePath file
745
746
@@ -790,7 +791,7 @@ ghcSessionDepsDefinition file = do
790
791
-- | Load a iface from disk, or generate it if there isn't one or it is out of date
791
792
-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.
792
793
getModIfaceFromDiskRule :: Rules ()
793
- getModIfaceFromDiskRule = defineEarlyCutoff $ \ GetModIfaceFromDisk f -> do
794
+ getModIfaceFromDiskRule = defineEarlyCutoff $ Rule $ \ GetModIfaceFromDisk f -> do
794
795
ms <- msrModSummary <$> use_ GetModSummary f
795
796
(diags_session, mb_session) <- ghcSessionDepsDefinition f
796
797
case mb_session of
@@ -814,7 +815,7 @@ getModIfaceFromDiskRule = defineEarlyCutoff $ \GetModIfaceFromDisk f -> do
814
815
-- disk since we are careful to write out the `.hie` file before writing the
815
816
-- `.hi` file
816
817
getModIfaceFromDiskAndIndexRule :: Rules ()
817
- getModIfaceFromDiskAndIndexRule = defineEarlyCutoff $ \ GetModIfaceFromDiskAndIndex f -> do
818
+ getModIfaceFromDiskAndIndexRule = defineEarlyCutoff $ RuleNoDiagnostics $ \ GetModIfaceFromDiskAndIndex f -> do
818
819
x <- use_ GetModIfaceFromDisk f
819
820
se@ ShakeExtras {hiedb} <- getShakeExtras
820
821
@@ -844,10 +845,10 @@ getModIfaceFromDiskAndIndexRule = defineEarlyCutoff $ \GetModIfaceFromDiskAndInd
844
845
indexHieFile se ms f hash hf
845
846
846
847
let fp = hiFileFingerPrint x
847
- return (Just fp, ( [] , Just x) )
848
+ return (Just fp, Just x)
848
849
849
850
isHiFileStableRule :: Rules ()
850
- isHiFileStableRule = defineEarlyCutoff $ \ IsHiFileStable f -> do
851
+ isHiFileStableRule = defineEarlyCutoff $ RuleNoDiagnostics $ \ IsHiFileStable f -> do
851
852
ms <- msrModSummary <$> use_ GetModSummaryWithoutTimestamps f
852
853
let hiFile = toNormalizedFilePath'
853
854
$ ml_hi_file $ ms_location ms
@@ -865,11 +866,11 @@ isHiFileStableRule = defineEarlyCutoff $ \IsHiFileStable f -> do
865
866
pure $ if all (== SourceUnmodifiedAndStable ) deps
866
867
then SourceUnmodifiedAndStable
867
868
else SourceUnmodified
868
- return (Just (BS. pack $ show sourceModified), ( [] , Just sourceModified) )
869
+ return (Just (BS. pack $ show sourceModified), Just sourceModified)
869
870
870
871
getModSummaryRule :: Rules ()
871
872
getModSummaryRule = do
872
- defineEarlyCutoff $ \ GetModSummary f -> do
873
+ defineEarlyCutoff $ Rule $ \ GetModSummary f -> do
873
874
session <- hscEnv <$> use_ GhcSession f
874
875
(modTime, mFileContent) <- getFileContents f
875
876
let fp = fromNormalizedFilePath f
@@ -884,7 +885,7 @@ getModSummaryRule = do
884
885
return ( Just (fingerprintToBS fingerPrint) , ([] , Just res))
885
886
Left diags -> return (Nothing , (diags, Nothing ))
886
887
887
- defineEarlyCutoff $ \ GetModSummaryWithoutTimestamps f -> do
888
+ defineEarlyCutoff $ RuleNoDiagnostics $ \ GetModSummaryWithoutTimestamps f -> do
888
889
ms <- use GetModSummary f
889
890
case ms of
890
891
Just res@ ModSummaryResult {.. } -> do
@@ -893,8 +894,8 @@ getModSummaryRule = do
893
894
ms_hspp_buf = error " use GetModSummary instead of GetModSummaryWithoutTimestamps"
894
895
}
895
896
fp = fingerprintToBS msrFingerprint
896
- return (Just fp, ( [] , Just res{msrModSummary = ms}) )
897
- Nothing -> return (Nothing , ( [] , Nothing ) )
897
+ return (Just fp, Just res{msrModSummary = ms})
898
+ Nothing -> return (Nothing , Nothing )
898
899
899
900
generateCore :: RunSimplifier -> NormalizedFilePath -> Action (IdeResult ModGuts )
900
901
generateCore runSimplifier file = do
@@ -908,7 +909,7 @@ generateCoreRule =
908
909
define $ \ GenerateCore -> generateCore (RunSimplifier True )
909
910
910
911
getModIfaceRule :: Rules ()
911
- getModIfaceRule = defineEarlyCutoff $ \ GetModIface f -> do
912
+ getModIfaceRule = defineEarlyCutoff $ Rule $ \ GetModIface f -> do
912
913
fileOfInterest <- use_ IsFileOfInterest f
913
914
res@ (_,(_,mhmi)) <- case fileOfInterest of
914
915
IsFOI status -> do
@@ -937,11 +938,11 @@ getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
937
938
pure res
938
939
939
940
getModIfaceWithoutLinkableRule :: Rules ()
940
- getModIfaceWithoutLinkableRule = defineEarlyCutoff $ \ GetModIfaceWithoutLinkable f -> do
941
+ getModIfaceWithoutLinkableRule = defineEarlyCutoff $ RuleNoDiagnostics $ \ GetModIfaceWithoutLinkable f -> do
941
942
mhfr <- use GetModIface f
942
943
let mhfr' = fmap (\ x -> x{ hirHomeMod = (hirHomeMod x){ hm_linkable = Just (error msg) } }) mhfr
943
944
msg = " tried to look at linkable for GetModIfaceWithoutLinkable for " ++ show f
944
- pure (fingerprintToBS . getModuleHash . hirModIface <$> mhfr', ( [] , mhfr') )
945
+ pure (fingerprintToBS . getModuleHash . hirModIface <$> mhfr', mhfr')
945
946
946
947
-- | Also generates and indexes the `.hie` file, along with the `.o` file if needed
947
948
-- Invariant maintained is that if the `.hi` file was successfully written, then the
@@ -1037,7 +1038,7 @@ getLinkableType :: NormalizedFilePath -> Action (Maybe LinkableType)
1037
1038
getLinkableType f = use_ NeedsCompilation f
1038
1039
1039
1040
needsCompilationRule :: Rules ()
1040
- needsCompilationRule = defineEarlyCutoff $ \ NeedsCompilation file -> do
1041
+ needsCompilationRule = defineEarlyCutoff $ RuleNoDiagnostics $ \ NeedsCompilation file -> do
1041
1042
graph <- useNoFile GetModuleGraph
1042
1043
res <- case graph of
1043
1044
-- Treat as False if some reverse dependency header fails to parse
@@ -1061,7 +1062,7 @@ needsCompilationRule = defineEarlyCutoff $ \NeedsCompilation file -> do
1061
1062
(uses NeedsCompilation revdeps)
1062
1063
pure $ computeLinkableType ms modsums (map join needsComps)
1063
1064
1064
- pure (Just $ BS. pack $ show $ hash res, ( [] , Just res) )
1065
+ pure (Just $ BS. pack $ show $ hash res, Just res)
1065
1066
where
1066
1067
uses_th_qq (ms_hspp_opts -> dflags) =
1067
1068
xopt LangExt. TemplateHaskell dflags || xopt LangExt. QuasiQuotes dflags
0 commit comments