@@ -69,6 +69,7 @@ import Language.LSP.VFS
69
69
import System.FilePath
70
70
import System.IO.Error
71
71
import System.IO.Unsafe
72
+ import Development.IDE.Core.InputPath (InputPath (InputPath , unInputPath ))
72
73
73
74
74
75
data Log
@@ -88,16 +89,16 @@ instance Pretty Log where
88
89
<+> pretty (fmap (fmap show ) reverseDepPaths)
89
90
LogShake msg -> pretty msg
90
91
91
- addWatchedFileRule :: Recorder (WithPriority Log ) -> (NormalizedFilePath -> Action Bool ) -> Rules ()
92
+ addWatchedFileRule :: Recorder (WithPriority Log ) -> (InputPath i -> Action Bool ) -> Rules ()
92
93
addWatchedFileRule recorder isWatched = defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \ AddWatchedFile f -> do
93
94
isAlreadyWatched <- isWatched f
94
- isWp <- isWorkspaceFile f
95
+ isWp <- isWorkspaceFile $ unInputPath f
95
96
if isAlreadyWatched then pure (Just True ) else
96
97
if not isWp then pure (Just False ) else do
97
98
ShakeExtras {lspEnv} <- getShakeExtras
98
99
case lspEnv of
99
100
Just env -> fmap Just $ liftIO $ LSP. runLspT env $
100
- registerFileWatches [fromNormalizedFilePath f ]
101
+ registerFileWatches [fromNormalizedFilePath (unInputPath f) ]
101
102
Nothing -> pure $ Just False
102
103
103
104
@@ -107,12 +108,12 @@ getModificationTimeRule recorder = defineEarlyCutoff (cmapWithPrio LogShake reco
107
108
108
109
getModificationTimeImpl
109
110
:: Bool
110
- -> NormalizedFilePath
111
+ -> InputPath i
111
112
-> Action (Maybe BS. ByteString , ([FileDiagnostic ], Maybe FileVersion ))
112
113
getModificationTimeImpl missingFileDiags file = do
113
- let file' = fromNormalizedFilePath file
114
+ let file' = fromNormalizedFilePath $ unInputPath file
114
115
let wrap time = (Just $ LBS. toStrict $ B. encode $ toRational time, ([] , Just $ ModificationTime time))
115
- mbVf <- getVirtualFile file
116
+ mbVf <- getVirtualFile $ unInputPath file
116
117
case mbVf of
117
118
Just (virtualFileVersion -> ver) -> do
118
119
alwaysRerun
@@ -124,7 +125,7 @@ getModificationTimeImpl missingFileDiags file = do
124
125
-- but also need a dependency on IsFileOfInterest to reinstall
125
126
-- alwaysRerun when the file becomes VFS
126
127
void (use_ IsFileOfInterest file)
127
- else if isInterface file
128
+ else if isInterface (unInputPath file)
128
129
then -- interface files are tracked specially using the closed world assumption
129
130
pure ()
130
131
else -- in all other cases we will need to freshly check the file system
@@ -134,7 +135,7 @@ getModificationTimeImpl missingFileDiags file = do
134
135
`catch` \ (e :: IOException ) -> do
135
136
let err | isDoesNotExistError e = " File does not exist: " ++ file'
136
137
| otherwise = " IO error while reading " ++ file' ++ " , " ++ displayException e
137
- diag = ideErrorText file (T. pack err)
138
+ diag = ideErrorText (unInputPath file) (T. pack err)
138
139
if isDoesNotExistError e && not missingFileDiags
139
140
then return (Nothing , ([] , Nothing ))
140
141
else return (Nothing , ([diag], Nothing ))
@@ -174,19 +175,19 @@ getFileContentsRule :: Recorder (WithPriority Log) -> Rules ()
174
175
getFileContentsRule recorder = define (cmapWithPrio LogShake recorder) $ \ GetFileContents file -> getFileContentsImpl file
175
176
176
177
getFileContentsImpl
177
- :: NormalizedFilePath
178
+ :: InputPath i
178
179
-> Action ([FileDiagnostic ], Maybe (FileVersion , Maybe T. Text ))
179
180
getFileContentsImpl file = do
180
181
-- need to depend on modification time to introduce a dependency with Cutoff
181
182
time <- use_ GetModificationTime file
182
183
res <- do
183
- mbVirtual <- getVirtualFile file
184
+ mbVirtual <- getVirtualFile $ unInputPath file
184
185
pure $ virtualFileText <$> mbVirtual
185
186
pure ([] , Just (time, res))
186
187
187
188
-- | Returns the modification time and the contents.
188
189
-- For VFS paths, the modification time is the current time.
189
- getFileContents :: NormalizedFilePath -> Action (UTCTime , Maybe T. Text )
190
+ getFileContents :: InputPath i -> Action (UTCTime , Maybe T. Text )
190
191
getFileContents f = do
191
192
(fv, txt) <- use_ GetFileContents f
192
193
modTime <- case modificationTime fv of
@@ -196,11 +197,11 @@ getFileContents f = do
196
197
liftIO $ case foi of
197
198
IsFOI Modified {} -> getCurrentTime
198
199
_ -> do
199
- posix <- getModTime $ fromNormalizedFilePath f
200
+ posix <- getModTime $ fromNormalizedFilePath $ unInputPath f
200
201
pure $ posixSecondsToUTCTime posix
201
202
return (modTime, txt)
202
203
203
- fileStoreRules :: Recorder (WithPriority Log ) -> (NormalizedFilePath -> Action Bool ) -> Rules ()
204
+ fileStoreRules :: Recorder (WithPriority Log ) -> (InputPath i -> Action Bool ) -> Rules ()
204
205
fileStoreRules recorder isWatched = do
205
206
getModificationTimeRule recorder
206
207
getFileContentsRule recorder
@@ -239,7 +240,7 @@ typecheckParentsAction recorder nfp = do
239
240
Nothing -> logWith recorder Info $ LogCouldNotIdentifyReverseDeps nfp
240
241
Just rs -> do
241
242
logWith recorder Info $ LogTypeCheckingReverseDeps nfp revs
242
- void $ uses GetModIface rs
243
+ void $ uses GetModIface ( map InputPath rs)
243
244
244
245
-- | Note that some keys have been modified and restart the session
245
246
-- Only valid if the virtual file system was initialised by LSP, as that
0 commit comments