@@ -41,6 +41,7 @@ import Data.Time
4141import Data.Time.Clock.POSIX
4242import Development.IDE.Core.FileUtils
4343import Development.IDE.Core.IdeConfiguration (isWorkspaceFile )
44+ import Development.IDE.Core.InputPath
4445import Development.IDE.Core.RuleTypes
4546import Development.IDE.Core.Shake hiding (Log )
4647import qualified Development.IDE.Core.Shake as Shake
@@ -96,7 +97,8 @@ instance Pretty Log where
9697 LogShake msg -> pretty msg
9798
9899addWatchedFileRule :: Recorder (WithPriority Log ) -> (NormalizedFilePath -> Action Bool ) -> Rules ()
99- addWatchedFileRule recorder isWatched = defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \ AddWatchedFile f -> do
100+ addWatchedFileRule recorder isWatched = defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \ AddWatchedFile input -> do
101+ let f = unInputPath input
100102 isAlreadyWatched <- isWatched f
101103 isWp <- isWorkspaceFile f
102104 if isAlreadyWatched then pure (Just True ) else
@@ -114,9 +116,10 @@ getModificationTimeRule recorder = defineEarlyCutoff (cmapWithPrio LogShake reco
114116
115117getModificationTimeImpl
116118 :: Bool
117- -> NormalizedFilePath
119+ -> InputPath AllHaskellFiles
118120 -> Action (Maybe BS. ByteString , ([FileDiagnostic ], Maybe FileVersion ))
119- getModificationTimeImpl missingFileDiags file = do
121+ getModificationTimeImpl missingFileDiags input = do
122+ let file = unInputPath input
120123 let file' = fromNormalizedFilePath file
121124 let wrap time = (Just $ LBS. toStrict $ B. encode $ toRational time, ([] , Just $ ModificationTime time))
122125 mbVf <- getVirtualFile file
@@ -125,12 +128,12 @@ getModificationTimeImpl missingFileDiags file = do
125128 alwaysRerun
126129 pure (Just $ LBS. toStrict $ B. encode ver, ([] , Just $ VFSVersion ver))
127130 Nothing -> do
128- isWF <- use_ AddWatchedFile file
131+ isWF <- use_ AddWatchedFile input
129132 if isWF
130133 then -- the file is watched so we can rely on FileWatched notifications,
131134 -- but also need a dependency on IsFileOfInterest to reinstall
132135 -- alwaysRerun when the file becomes VFS
133- void (use_ IsFileOfInterest file )
136+ void (use_ IsFileOfInterest input )
134137 else if isInterface file
135138 then -- interface files are tracked specially using the closed world assumption
136139 pure ()
@@ -152,9 +155,10 @@ getPhysicalModificationTimeRule recorder = defineEarlyCutoff (cmapWithPrio LogSh
152155 getPhysicalModificationTimeImpl file
153156
154157getPhysicalModificationTimeImpl
155- :: NormalizedFilePath
158+ :: InputPath AllHaskellFiles
156159 -> Action (Maybe BS. ByteString , ([FileDiagnostic ], Maybe FileVersion ))
157- getPhysicalModificationTimeImpl file = do
160+ getPhysicalModificationTimeImpl input = do
161+ let file = unInputPath input
158162 let file' = fromNormalizedFilePath file
159163 let wrap time = (Just $ LBS. toStrict $ B. encode $ toRational time, ([] , Just $ ModificationTime time))
160164
@@ -208,19 +212,20 @@ getFileContentsRule :: Recorder (WithPriority Log) -> Rules ()
208212getFileContentsRule recorder = define (cmapWithPrio LogShake recorder) $ \ GetFileContents file -> getFileContentsImpl file
209213
210214getFileContentsImpl
211- :: NormalizedFilePath
215+ :: InputPath AllHaskellFiles
212216 -> Action ([FileDiagnostic ], Maybe (FileVersion , Maybe Rope ))
213- getFileContentsImpl file = do
217+ getFileContentsImpl input = do
218+ let file = unInputPath input
214219 -- need to depend on modification time to introduce a dependency with Cutoff
215- time <- use_ GetModificationTime file
220+ time <- use_ GetModificationTime input
216221 res <- do
217222 mbVirtual <- getVirtualFile file
218223 pure $ _file_text <$> mbVirtual
219224 pure ([] , Just (time, res))
220225
221226-- | Returns the modification time and the contents.
222227-- For VFS paths, the modification time is the current time.
223- getFileModTimeContents :: NormalizedFilePath -> Action (UTCTime , Maybe Rope )
228+ getFileModTimeContents :: InputPath AllHaskellFiles -> Action (UTCTime , Maybe Rope )
224229getFileModTimeContents f = do
225230 (fv, contents) <- use_ GetFileContents f
226231 modTime <- case modificationTime fv of
@@ -230,16 +235,16 @@ getFileModTimeContents f = do
230235 liftIO $ case foi of
231236 IsFOI Modified {} -> getCurrentTime
232237 _ -> do
233- posix <- getModTime $ fromNormalizedFilePath f
238+ posix <- getModTime $ fromNormalizedFilePath $ unInputPath f
234239 pure $ posixSecondsToUTCTime posix
235240 return (modTime, contents)
236241
237- getFileContents :: NormalizedFilePath -> Action (Maybe Rope )
242+ getFileContents :: InputPath AllHaskellFiles -> Action (Maybe Rope )
238243getFileContents f = snd <$> use_ GetFileContents f
239244
240245getUriContents :: NormalizedUri -> Action (Maybe Rope )
241246getUriContents uri =
242- join <$> traverse getFileContents (uriToNormalizedFilePath uri)
247+ join <$> traverse ( getFileContents . toAllHaskellInput) (uriToNormalizedFilePath uri)
243248
244249-- | Given a text document identifier, annotate it with the latest version.
245250--
@@ -291,12 +296,15 @@ typecheckParents recorder state nfp = void $ shakeEnqueue (shakeExtras state) pa
291296
292297typecheckParentsAction :: Recorder (WithPriority Log ) -> NormalizedFilePath -> Action ()
293298typecheckParentsAction recorder nfp = do
294- revs <- transitiveReverseDependencies nfp <$> useWithSeparateFingerprintRule_ GetModuleGraphTransReverseDepsFingerprints GetModuleGraph nfp
295- case revs of
299+ case toProjectHaskellInput nfp of
296300 Nothing -> logWith recorder Info $ LogCouldNotIdentifyReverseDeps nfp
297- Just rs -> do
298- logWith recorder Info $ LogTypeCheckingReverseDeps nfp revs
299- void $ uses GetModIface rs
301+ Just input -> do
302+ revs <- transitiveReverseDependencies nfp <$> useWithSeparateFingerprintRule_ GetModuleGraphTransReverseDepsFingerprints GetModuleGraph input
303+ case revs of
304+ Nothing -> logWith recorder Info $ LogCouldNotIdentifyReverseDeps nfp
305+ Just rs -> do
306+ logWith recorder Info $ LogTypeCheckingReverseDeps nfp revs
307+ void $ uses GetModIface (classifyProjectHaskellInputs rs)
300308
301309-- | Note that some keys have been modified and restart the session
302310-- Only valid if the virtual file system was initialised by LSP, as that
0 commit comments