Skip to content

Commit 7140ff1

Browse files
committed
Track file versions accurately
1 parent 96ea854 commit 7140ff1

20 files changed

+246
-190
lines changed

cabal-ghc90.project

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ packages:
2828
./plugins/hls-alternate-number-format-plugin
2929
./plugins/hls-selection-range-plugin
3030

31+
source-repository-package
32+
type: git
33+
location: https://github.com/haskell/lsp
34+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
35+
subdir: lsp
36+
37+
source-repository-package
38+
type: git
39+
location: https://github.com/haskell/lsp
40+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
41+
subdir: lsp-types
42+
43+
source-repository-package
44+
type: git
45+
location: https://github.com/haskell/lsp
46+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
47+
subdir: lsp-test
48+
3149
tests: true
3250

3351
package *

cabal-ghc921.project

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ packages:
2828
./plugins/hls-alternate-number-format-plugin
2929
./plugins/hls-selection-range-plugin
3030

31+
source-repository-package
32+
type: git
33+
location: https://github.com/haskell/lsp
34+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
35+
subdir: lsp
36+
37+
source-repository-package
38+
type: git
39+
location: https://github.com/haskell/lsp
40+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
41+
subdir: lsp-types
42+
43+
source-repository-package
44+
type: git
45+
location: https://github.com/haskell/lsp
46+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
47+
subdir: lsp-test
48+
3149
with-compiler: ghc-9.2.1
3250

3351
tests: true

cabal.project

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ packages:
2828
./plugins/hls-qualify-imported-names-plugin
2929
./plugins/hls-selection-range-plugin
3030

31+
32+
source-repository-package
33+
type: git
34+
location: https://github.com/haskell/lsp
35+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
36+
subdir: lsp
37+
38+
source-repository-package
39+
type: git
40+
location: https://github.com/haskell/lsp
41+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
42+
subdir: lsp-types
43+
44+
source-repository-package
45+
type: git
46+
location: https://github.com/haskell/lsp
47+
tag: 63de2845c2dd6d33568696f8652b8fd65fae6b72
48+
subdir: lsp-test
49+
3150
-- Standard location for temporary packages needed for particular environments
3251
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
3352
-- See https://github.com/haskell/haskell-language-server/blob/master/.gitlab-ci.yml

ghcide/ghcide.cabal

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ library
5050
dlist,
5151
exceptions,
5252
extra >= 1.7.4,
53+
enummapset,
5354
fuzzy,
5455
filepath,
5556
fingertree,
@@ -64,8 +65,8 @@ library
6465
lens,
6566
list-t,
6667
hiedb == 0.4.1.*,
67-
lsp-types ^>= 1.4.0.1,
68-
lsp ^>= 1.4.0.0 ,
68+
lsp-types ^>= 1.5.0.0,
69+
lsp ^>= 1.5.0.0 ,
6970
monoid-subclasses,
7071
mtl,
7172
network-uri,
@@ -76,7 +77,7 @@ library
7677
random,
7778
regex-tdfa >= 1.3.1.0,
7879
retrie,
79-
rope-utf16-splay,
80+
text-rope,
8081
safe,
8182
safe-exceptions,
8283
hls-graph ^>= 1.6,
@@ -148,6 +149,7 @@ library
148149
Development.IDE.Main.HeapStats
149150
Development.IDE.Core.Debouncer
150151
Development.IDE.Core.FileStore
152+
Development.IDE.Core.FileUtils
151153
Development.IDE.Core.IdeConfiguration
152154
Development.IDE.Core.OfInterest
153155
Development.IDE.Core.PositionMapping
@@ -394,7 +396,7 @@ test-suite ghcide-tests
394396
QuickCheck,
395397
quickcheck-instances,
396398
random,
397-
rope-utf16-splay,
399+
text-rope,
398400
regex-tdfa ^>= 1.3.1,
399401
safe,
400402
safe-exceptions,

ghcide/src/Development/IDE/Core/FileExists.hs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ allExtensions opts = [extIncBoot | ext <- optExtensions opts, extIncBoot <- [ext
157157
-- | Installs the 'getFileExists' rules.
158158
-- Provides a fast implementation if client supports dynamic watched files.
159159
-- Creates a global state as a side effect in that case.
160-
fileExistsRules :: Maybe (LanguageContextEnv Config) -> VFSHandle -> Rules ()
161-
fileExistsRules lspEnv vfs = do
160+
fileExistsRules :: Maybe (LanguageContextEnv Config) -> Rules ()
161+
fileExistsRules lspEnv = do
162162
supportsWatchedFiles <- case lspEnv of
163163
Nothing -> pure False
164164
Just lspEnv' -> liftIO $ runLspT lspEnv' isWatchSupported
@@ -179,19 +179,19 @@ fileExistsRules lspEnv vfs = do
179179
else const $ pure False
180180

181181
if supportsWatchedFiles
182-
then fileExistsRulesFast isWatched vfs
183-
else fileExistsRulesSlow vfs
182+
then fileExistsRulesFast isWatched
183+
else fileExistsRulesSlow
184184

185-
fileStoreRules vfs isWatched
185+
fileStoreRules isWatched
186186

187187
-- Requires an lsp client that provides WatchedFiles notifications, but assumes that this has already been checked.
188-
fileExistsRulesFast :: (NormalizedFilePath -> Action Bool) -> VFSHandle -> Rules ()
189-
fileExistsRulesFast isWatched vfs =
188+
fileExistsRulesFast :: (NormalizedFilePath -> Action Bool) -> Rules ()
189+
fileExistsRulesFast isWatched =
190190
defineEarlyCutoff $ RuleNoDiagnostics $ \GetFileExists file -> do
191191
isWF <- isWatched file
192192
if isWF
193-
then fileExistsFast vfs file
194-
else fileExistsSlow vfs file
193+
then fileExistsFast file
194+
else fileExistsSlow file
195195

196196
{- Note [Invalidating file existence results]
197197
We have two mechanisms for getting file existence information:
@@ -209,8 +209,8 @@ For the VFS lookup, however, we won't get prompted to flush the result, so inste
209209
we use 'alwaysRerun'.
210210
-}
211211

212-
fileExistsFast :: VFSHandle -> NormalizedFilePath -> Action (Maybe BS.ByteString, Maybe Bool)
213-
fileExistsFast vfs file = do
212+
fileExistsFast :: NormalizedFilePath -> Action (Maybe BS.ByteString, Maybe Bool)
213+
fileExistsFast file = do
214214
-- Could in principle use 'alwaysRerun' here, but it's too slwo, See Note [Invalidating file existence results]
215215
mp <- getFileExistsMapUntracked
216216

@@ -219,28 +219,27 @@ fileExistsFast vfs file = do
219219
Just exist -> pure exist
220220
-- We don't know about it: use the slow route.
221221
-- Note that we do *not* call 'fileExistsSlow', as that would trigger 'alwaysRerun'.
222-
Nothing -> liftIO $ getFileExistsVFS vfs file
222+
Nothing -> getFileExistsVFS file
223223
pure (summarizeExists exist, Just exist)
224224

225225
summarizeExists :: Bool -> Maybe BS.ByteString
226226
summarizeExists x = Just $ if x then BS.singleton 1 else BS.empty
227227

228-
fileExistsRulesSlow :: VFSHandle -> Rules ()
229-
fileExistsRulesSlow vfs =
230-
defineEarlyCutoff $ RuleNoDiagnostics $ \GetFileExists file -> fileExistsSlow vfs file
228+
fileExistsRulesSlow :: Rules ()
229+
fileExistsRulesSlow =
230+
defineEarlyCutoff $ RuleNoDiagnostics $ \GetFileExists file -> fileExistsSlow file
231231

232-
fileExistsSlow :: VFSHandle -> NormalizedFilePath -> Action (Maybe BS.ByteString, Maybe Bool)
233-
fileExistsSlow vfs file = do
232+
fileExistsSlow :: NormalizedFilePath -> Action (Maybe BS.ByteString, Maybe Bool)
233+
fileExistsSlow file = do
234234
-- See Note [Invalidating file existence results]
235235
alwaysRerun
236-
exist <- liftIO $ getFileExistsVFS vfs file
236+
exist <- getFileExistsVFS file
237237
pure (summarizeExists exist, Just exist)
238238

239-
getFileExistsVFS :: VFSHandle -> NormalizedFilePath -> IO Bool
240-
getFileExistsVFS vfs file = do
241-
-- we deliberately and intentionally wrap the file as an FilePath WITHOUT mkAbsolute
242-
-- so that if the file doesn't exist, is on a shared drive that is unmounted etc we get a properly
243-
-- cached 'No' rather than an exception in the wrong place
244-
handle (\(_ :: IOException) -> return False) $
245-
(isJust <$> getVirtualFile vfs (filePathToUri' file)) ||^
246-
Dir.doesFileExist (fromNormalizedFilePath file)
239+
getFileExistsVFS :: NormalizedFilePath -> Action Bool
240+
getFileExistsVFS file = do
241+
vf <- getVirtualFile file
242+
if isJust vf
243+
then pure True
244+
else liftIO $ handle (\(_ :: IOException) -> return False) $
245+
Dir.doesFileExist (fromNormalizedFilePath file)

0 commit comments

Comments
 (0)