Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
58b8b68
Refactor session loading to manage pending files so we can batch load…
soulomoon Nov 2, 2024
ea002d7
distribute errors to all pending files are being loading
soulomoon Nov 3, 2024
c78b197
better filter loading files
soulomoon Nov 3, 2024
b879375
fallback to non-batch load
soulomoon Nov 4, 2024
8953aec
typo
soulomoon Nov 4, 2024
4bdc2c8
update inline doc
soulomoon Nov 4, 2024
c4bb53a
update inline doc
soulomoon Nov 4, 2024
112bc95
add LogSessionReloadOnError to log errors during file reloads; cleanu…
soulomoon Nov 4, 2024
9a2aaf1
Merge branch 'master' into batch-load
soulomoon Nov 4, 2024
6e04d28
refactor loadSessionWithOptions to improve error handling and clarify…
soulomoon Nov 4, 2024
67aebc4
refactor loadSessionWithOptions to improve pending file handling and …
soulomoon Nov 4, 2024
98ae446
add doc about limitation
soulomoon Nov 4, 2024
f3eb580
absolute file at the beginning
soulomoon Nov 5, 2024
e7bd3d4
run session loader and worker in sperate
soulomoon Nov 7, 2024
1f97c40
cleanup
soulomoon Nov 7, 2024
4c998bd
rename LogGetSessionRetry to LogLookupSessionCache for clarity in log…
soulomoon Nov 8, 2024
79a43a0
extract attempt to load files from errors
soulomoon Nov 9, 2024
beb1764
refactor session loading to wait for pending files before cache check
soulomoon Nov 12, 2024
6139522
add LogTime to logging for improved time tracking during session loading
soulomoon Nov 18, 2024
7314509
refactor session loading to handle dependency checks more clearly
soulomoon Nov 19, 2024
cddcc55
Refactors session loading logic
soulomoon Nov 19, 2024
4c99c47
Merge branch 'master' into batch-load-multi-read
soulomoon Dec 6, 2024
bb78a36
delay the restart
soulomoon Dec 6, 2024
33f788c
Merge branch 'master' into batch-load-multi-read
soulomoon Jan 8, 2025
0913d2e
Merge branch 'master' into batch-load-multi-read
soulomoon Feb 4, 2025
58ec7ea
re-inline the old file instead of loading it twice
soulomoon Feb 17, 2025
60e8427
Merge branch 'master' into batch-load-multi-read
soulomoon Feb 17, 2025
d943963
update upload artifact action version
soulomoon Feb 18, 2025
5d01500
update hie-bios tag
soulomoon Feb 25, 2025
10a6f7e
Update hie-bios tag to latest commit
soulomoon Feb 26, 2025
de6d5f3
Merge branch 'master' into batch-load-multi-read
soulomoon Mar 2, 2025
45b1241
update hie-bios
soulomoon Mar 2, 2025
219db46
update index-state to reflect the latest project state
soulomoon Mar 2, 2025
2f86db0
update index-state to reflect the new date
soulomoon Mar 3, 2025
de98232
update fourmolu dependency version constraints
soulomoon Mar 6, 2025
f0a881d
remove ListT from library dependencies
soulomoon Mar 6, 2025
14f6a3b
update hie-bios to a new tag
soulomoon Mar 6, 2025
8b0e246
update fourmolu dependency version constraints to allow 0.16
soulomoon Mar 6, 2025
2dd71c0
add allow-newer constraint for Cabal-syntax
soulomoon Mar 6, 2025
b8406d6
remove allow-newer constraint for Cabal-syntax
soulomoon Mar 6, 2025
5ea3d87
bump actions/checkout and actions/upload-artifact to v3
soulomoon Mar 6, 2025
3e0c27b
Revert "bump actions/checkout and actions/upload-artifact to v3"
soulomoon Mar 6, 2025
8c27e34
add allow-older constraint for optparse-applicative in cabal.project
soulomoon Mar 7, 2025
bb0a541
Merge branch 'master' into batch-load-multi-read
soulomoon Mar 13, 2025
e491f60
Merge branch 'master' into batch-load-multi-read
soulomoon Mar 20, 2025
d5c2326
Merge branch 'master' into batch-load-multi-read
soulomoon Mar 27, 2025
9efcb2e
Merge branch 'master' into batch-load-multi-read
soulomoon Apr 6, 2025
c883a09
Merge branch 'master' into batch-load-multi-read
soulomoon Apr 16, 2025
9f9b8f7
Merge branch 'master' into batch-load-multi-read
soulomoon Apr 24, 2025
b0af634
update hie-bios
soulomoon Apr 24, 2025
06fa5de
introduce SessionState
soulomoon Apr 27, 2025
78e01a8
Merge branch 'master' into batch-load-multi-read
soulomoon Apr 27, 2025
80d0160
update hiebois
soulomoon Apr 27, 2025
24269f6
revert
soulomoon Apr 28, 2025
98999f5
restart the shake if cabal file changed
soulomoon Apr 28, 2025
21dd233
better error handling in session loader
soulomoon Apr 28, 2025
f140a2a
refactor error handling in loadSessionWithOptions to improve clarity …
soulomoon Apr 28, 2025
e339c1d
refactor SessionState management for improved batch loading logic
soulomoon Apr 28, 2025
1425289
refactor session loading error handling for improved clarity and sepa…
soulomoon Apr 28, 2025
de6eb9c
cleanup
soulomoon May 8, 2025
db18100
Merge branch 'master' into batch-load-multi-read
soulomoon May 8, 2025
c9926d4
fix
soulomoon May 8, 2025
48a46d1
add sessionLoadingPreferenceConfig var to SessionState
soulomoon May 8, 2025
90e1df1
Merge branch 'master' into batch-load-multi-read
soulomoon May 12, 2025
702e367
refactor SessionState to use Var instead of IORef for loaded and fail…
soulomoon May 14, 2025
09213d3
simplified
soulomoon May 19, 2025
4a78e6e
Merge branch 'master' into batch-load-multi-read
soulomoon May 26, 2025
4cb5a70
Merge branch 'master' into batch-load-multi-read
soulomoon Jun 3, 2025
005f573
Merge branch 'master' into batch-load-multi-read
soulomoon Jun 4, 2025
db8b1ac
Merge branch 'master' into batch-load-multi-read
soulomoon Jun 13, 2025
f768db0
Extract top-level functions for session initialisation
fendor Jun 21, 2025
a92ffb1
Merge branch 'master' into batch-load-multi-read
soulomoon Jun 23, 2025
d4fbc2c
Remove unused _removeInplacePackages function
fendor Jul 4, 2025
ff807c3
Introduce SessionM for bundling read-only variables
fendor Jul 4, 2025
1aa1e2c
Extract ghc specific functions into separate module
fendor Jul 4, 2025
aff67c0
Merge remote-tracking branch 'upstream/master' into batch-load-multi-…
fendor Jul 4, 2025
8957a42
Merge branch 'master' into batch-load-multi-read
soulomoon Jul 17, 2025
7d106cf
fix duplication
soulomoon Jul 18, 2025
ddef7d4
Remove RTS options from multi-unit configuration files
soulomoon Aug 4, 2025
3a4ddda
merge master
soulomoon Aug 4, 2025
d5632d6
format
soulomoon Aug 4, 2025
4c5bc35
apply the patch from https://github.com/haskell/haskell-language-serv…
soulomoon Aug 4, 2025
d943452
add comments for orderedSet
soulomoon Aug 4, 2025
bd79156
update comments for orderedSet
soulomoon Aug 4, 2025
dc34df6
fix import
soulomoon Aug 4, 2025
71d6575
refactor OrderedSet to use a record for better clarity and structure
soulomoon Aug 5, 2025
ac1d36d
Merge branch 'master' into batch-load-multi-read
soulomoon Aug 9, 2025
504d71d
merge master in
soulomoon Aug 11, 2025
dd6b562
merge master in
soulomoon Aug 11, 2025
24738d6
session: move handleBatchLoadSuccess inside
soulomoon Aug 19, 2025
468b992
Merge branch 'master' into batch-load-multi-read
soulomoon Aug 20, 2025
b1237d0
debug
soulomoon Aug 21, 2025
a9f4406
Merge branch 'batch-load-multi-read', remote-tracking branch 'origin'…
soulomoon Aug 22, 2025
92e70e8
remove cradle for test (#4706)
soulomoon Aug 24, 2025
be30f3e
Use structured diagnostics in pragmas plugin (#4620)
dyniec Aug 25, 2025
5550ca5
Replace writeFile with atomicFileWrite in ghcide-tests (#4710)
soulomoon Aug 27, 2025
bd58606
Document how to set formattingProvider in emacs, modern syntax (#4713)
unhammer Aug 27, 2025
60a6c48
Replace neat-interpolation with string-interpolate (#4717)
jian-lin Aug 31, 2025
1263b9f
Refactor garbage collection logic and improve logging in Shake module
soulomoon Sep 1, 2025
26aa9be
hls-graph: simplify AIO; scoped cancellation; fewer threads; safe cle…
soulomoon Sep 1, 2025
a219810
update hls-graph runtime
soulomoon Sep 5, 2025
df47889
Merge remote-tracking branch 'upstream/master' into improve-hls-runtime
soulomoon Sep 5, 2025
86fff58
exit
soulomoon Sep 6, 2025
9b952c8
Implement signature help (#4626)
jian-lin Sep 6, 2025
558f861
debounce empty diags
soulomoon Sep 6, 2025
51c1ceb
refactor progress reporting: remove unused parameters and simplify fu…
soulomoon Sep 6, 2025
1ed5fcb
fix old actions runs because we did not increment the step
soulomoon Sep 6, 2025
df6a8f4
fix build
soulomoon Sep 6, 2025
80733e7
remove unused imports from various modules
soulomoon Sep 6, 2025
26045a1
upgrade lsp version
soulomoon Sep 6, 2025
f1fb7fe
Merge remote-tracking branch 'upstream/master' into improve-hls-runtime
soulomoon Sep 7, 2025
74e1909
fix build in older verions
soulomoon Sep 7, 2025
c443837
change to list
soulomoon Sep 7, 2025
8f37379
prefer shakeRestart if there are others in queue
soulomoon Sep 7, 2025
57f89ec
Merge branch 'improve-hls-runtime' into improve-hls-runtime-list
soulomoon Sep 7, 2025
1ec7d63
do not spawn if just one element
soulomoon Sep 7, 2025
df2631c
guard with mask so it must run
soulomoon Sep 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
- if: needs.pre_job.outputs.should_skip_ghcide != 'true' && matrix.test
name: Test ghcide
# run the tests without parallelism to avoid running out of memory
run: cabal test ghcide-tests || cabal test ghcide-tests
run: cabal test ghcide-tests

- if: matrix.test
name: Test hls-plugin-api
Expand Down Expand Up @@ -261,6 +261,10 @@ jobs:
name: Compile the plugin-tutorial
run: cabal build plugin-tutorial

- if: matrix.test
name: Test hls-signature-help-plugin test suite
run: cabal test hls-signature-help-plugin-tests || cabal test hls-signature-help-plugin-tests

test_post_job:
if: always()
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
/plugins/hls-rename-plugin
/plugins/hls-retrie-plugin @wz1000
/plugins/hls-semantic-tokens-plugin @soulomoon
/plugins/hls-signature-help-plugin @jian-lin
/plugins/hls-splice-plugin @konn
/plugins/hls-stan-plugin @0rphee
/plugins/hls-stylish-haskell-plugin @michaelpj
Expand Down
6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ if impl(ghc >= 9.11)
allow-newer:
cabal-install-parsers:base,
cabal-install-parsers:time,

source-repository-package
type: git
location: https://github.com/soulomoon/lsp.git
tag: 640c7c755bf16128e3cb19c257688aa3305ff9f5
subdir: lsp lsp-types lsp-test
16 changes: 7 additions & 9 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Here is a list of the additional settings currently supported by `haskell-langua
Plugins have a generic config to control their behaviour. The schema of such config is:

- `haskell.plugin.${pluginName}.globalOn`: usually with default true. Whether the plugin is enabled at runtime or it is not. That is the option you might use if you want to disable completely a plugin.
- Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `importLens`, `class`, `hlint`, `retrie`, `rename`, `splice`, `stan`.
- Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `importLens`, `class`, `hlint`, `retrie`, `rename`, `splice`, `stan`, `signatureHelp`.
- So to disable the import lens with an explicit list of module definitions you could set `haskell.plugin.importLens.globalOn: false`
- `haskell.plugin.${pluginName}.${lspCapability}On`: usually with default true. Whether a concrete plugin capability is enabled.
- Capabilities are the different ways a lsp server can interact with the editor. The current available capabilities of the server are: `callHierarchy`, `codeActions`, `codeLens`, `diagnostics`, `hover`, `symbols`, `completion`, `rename`.
Expand Down Expand Up @@ -443,22 +443,20 @@ This will install `eglot` and enable it by default in `haskell-mode`.
To configure `haskell-language-server` we use the `eglot-workspace-configuration` variable.
With `M-x eglot-show-workspace-configuration` you can see the JSON that `eglot` will send to `haskell-language-server`.
See <https://joaotavora.github.io/eglot/#Customizing-Eglot> for more information.
As an example, the setting below will disable the `stan` plugin.
As an example, the setting below will disable the `stan` plugin and use `fourmolu` for formatting:

```emacs-lisp
(use-package eglot
:ensure t
:config
(add-hook 'haskell-mode-hook 'eglot-ensure)
(add-hook 'haskell-mode-hook 'eglot-ensure) ; start eglot automatically in haskell projects
:config
(setq-default eglot-workspace-configuration
'((haskell
(plugin
(stan
(globalOn . :json-false)))))) ;; disable stan
'(:haskell (:plugin (:stan (:globalOn :json-false)) ; disable stan
:formattingProvider "fourmolu"))) ; use fourmolu instead of ormolu
:custom
(eglot-autoshutdown t) ;; shutdown language server after closing last file
(eglot-confirm-server-initiated-edits nil) ;; allow edits without confirmation
(eglot-autoshutdown t) ; shutdown language server after closing last file
(eglot-confirm-server-initiated-edits nil) ; allow edits without confirmation
)
```

Expand Down
8 changes: 7 additions & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Many of these are standard LSP features, but a lot of special features are provi
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [Diagnostics](#diagnostics) | `textDocument/publishDiagnostics` |
| [Hovers](#hovers) | `textDocument/hover` |
| [Signature help](#signature-help) | `textDocument/signatureHelp` |
| [Jump to definition](#jump-to-definition) | `textDocument/definition` |
| [Jump to type definition](#jump-to-type-definition) | `textDocument/typeDefinition` |
| [Find references](#find-references) | `textDocument/references` |
Expand Down Expand Up @@ -63,6 +64,12 @@ Provided by: `hls-explicit-fixity-plugin`

Provides fixity information.

## Signature help

Provided by: `hls-signature-help-plugin`

Shows and highlights the function signature, the function documentation and the arguments documentation when the cursor is at a function argument.

## Jump to definition

Provided by: `ghcide`
Expand Down Expand Up @@ -445,7 +452,6 @@ Contributions welcome!

| Feature | Status | [LSP method](./what-is-hls.md#lsp-terminology) |
| ---------------------- | ----------------- | ---------------------------------------------- |
| Signature help | Unimplemented | `textDocument/signatureHelp` |
| Jump to declaration | Unclear if useful | `textDocument/declaration` |
| Jump to implementation | Unclear if useful | `textDocument/implementation` |
| Linked editing | Unimplemented | `textDocument/linkedEditingRange` |
Expand Down
1 change: 1 addition & 0 deletions docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-class-plugin` | 2 | |
| `hls-change-type-signature-plugin` | 2 | |
| `hls-eval-plugin` | 2 | |
| `hls-signature-help-plugin` | 2 | |
| `hls-explicit-fixity-plugin` | 2 | |
| `hls-explicit-record-fields-plugin` | 2 | |
| `hls-fourmolu-plugin` | 2 | |
Expand Down
11 changes: 6 additions & 5 deletions ghcide-test/exe/CradleTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Language.LSP.Protocol.Types hiding
import Language.LSP.Test
import System.FilePath
import System.IO.Extra hiding (withTempDir)
import Test.Hls.FileSystem
import Test.Hls.Util (EnvSpec (..), OS (..),
ignoreInEnv)
import Test.Tasty
Expand All @@ -53,7 +54,7 @@ loadCradleOnlyonce = testGroup "load cradle only once"
]
where
direct dir = do
liftIO $ writeFileUTF8 (dir </> "hie.yaml")
liftIO $ atomicFileWriteStringUTF8 (dir </> "hie.yaml")
"cradle: {direct: {arguments: []}}"
test dir
implicit dir = test dir
Expand All @@ -73,15 +74,15 @@ retryFailedCradle = testWithDummyPluginEmpty' "retry failed" $ \dir -> do
-- The false cradle always fails
let hieContents = "cradle: {bios: {shell: \"false\"}}"
hiePath = dir </> "hie.yaml"
liftIO $ writeFile hiePath hieContents
liftIO $ atomicFileWriteString hiePath hieContents
let aPath = dir </> "A.hs"
doc <- createDoc aPath "haskell" "main = return ()"
WaitForIdeRuleResult {..} <- waitForAction "TypeCheck" doc
liftIO $ "Test assumption failed: cradle should error out" `assertBool` not ideResultSuccess

-- Fix the cradle and typecheck again
let validCradle = "cradle: {bios: {shell: \"echo A.hs\"}}"
liftIO $ writeFileUTF8 hiePath $ T.unpack validCradle
liftIO $ atomicFileWriteStringUTF8 hiePath $ T.unpack validCradle
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
[FileEvent (filePathToUri $ dir </> "hie.yaml") FileChangeType_Changed ]

Expand Down Expand Up @@ -214,7 +215,7 @@ sessionDepsArePickedUp = testWithDummyPluginEmpty'
"session-deps-are-picked-up"
$ \dir -> do
liftIO $
writeFileUTF8
atomicFileWriteStringUTF8
(dir </> "hie.yaml")
"cradle: {direct: {arguments: []}}"
-- Open without OverloadedStrings and expect an error.
Expand All @@ -223,7 +224,7 @@ sessionDepsArePickedUp = testWithDummyPluginEmpty'

-- Update hie.yaml to enable OverloadedStrings.
liftIO $
writeFileUTF8
atomicFileWriteStringUTF8
(dir </> "hie.yaml")
"cradle: {direct: {arguments: [-XOverloadedStrings]}}"
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
Expand Down
5 changes: 3 additions & 2 deletions ghcide-test/exe/DependentFileTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Language.LSP.Protocol.Types hiding
mkRange)
import Language.LSP.Test
import Test.Hls
import Test.Hls.FileSystem


tests :: TestTree
Expand All @@ -31,7 +32,7 @@ tests = testGroup "addDependentFile"
-- If the file contains B then no type error
-- otherwise type error
let depFilePath = "dep-file.txt"
liftIO $ writeFile depFilePath "A"
liftIO $ atomicFileWriteString depFilePath "A"
let fooContent = T.unlines
[ "{-# LANGUAGE TemplateHaskell #-}"
, "module Foo where"
Expand All @@ -48,7 +49,7 @@ tests = testGroup "addDependentFile"
expectDiagnostics
[("Foo.hs", [(DiagnosticSeverity_Error, (4,11), "Couldn't match type", Just "GHC-83865")])]
-- Now modify the dependent file
liftIO $ writeFile depFilePath "B"
liftIO $ atomicFileWriteString depFilePath "B"
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
[FileEvent (filePathToUri depFilePath) FileChangeType_Changed ]

Expand Down
8 changes: 3 additions & 5 deletions ghcide-test/exe/DiagnosticTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import System.Time.Extra
import Test.Hls (TestConfig (testConfigCaps, testDirLocation, testDisableKick, testPluginDescriptor),
runSessionWithTestConfig,
waitForProgressBegin)
import Test.Hls.FileSystem (directCradle, file, text)
import Test.Hls.FileSystem
import Test.Tasty
import Test.Tasty.HUnit

Expand Down Expand Up @@ -244,9 +244,7 @@ tests = testGroup "diagnostics"
_ <- createDoc "ModuleB.hs" "haskell" contentB
_ <- createDoc "ModuleB.hs-boot" "haskell" contentBboot
expectDiagnostics [("ModuleB.hs", [(DiagnosticSeverity_Warning, (3,0), "Top-level binding", Just "GHC-38417")])]
, testWithDummyPlugin "bidirectional module dependency with hs-boot"
(mkIdeTestFs [directCradle ["ModuleA", "ModuleB"]])
$ do
, testWithDummyPluginEmpty "bidirectional module dependency with hs-boot" $ do
let contentA = T.unlines
[ "module ModuleA where"
, "import {-# SOURCE #-} ModuleB"
Expand Down Expand Up @@ -383,7 +381,7 @@ tests = testGroup "diagnostics"
let (drive, suffix) = splitDrive pathB
in filePathToUri (joinDrive (lower drive) suffix)
liftIO $ createDirectoryIfMissing True (takeDirectory pathB)
liftIO $ writeFileUTF8 pathB $ T.unpack bContent
liftIO $ atomicFileWriteStringUTF8 pathB $ T.unpack bContent
uriA <- getDocUri "A/A.hs"
Just pathA <- pure $ uriToFilePath uriA
uriA <- pure $
Expand Down
11 changes: 6 additions & 5 deletions ghcide-test/exe/GarbageCollectionTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Language.LSP.Protocol.Types hiding (SemanticTokenAbsolute (..),
SemanticTokensEdit (..), mkRange)
import Language.LSP.Test
import System.FilePath
import Test.Hls.FileSystem
import Test.Tasty
import Test.Tasty.HUnit
import Text.Printf (printf)
Expand All @@ -20,14 +21,14 @@ tests :: TestTree
tests = testGroup "garbage collection"
[ testGroup "dirty keys"
[ testWithDummyPluginEmpty' "are collected" $ \dir -> do
liftIO $ writeFile (dir </> "hie.yaml") "cradle: {direct: {arguments: [A]}}"
liftIO $ atomicFileWriteString (dir </> "hie.yaml") "cradle: {direct: {arguments: [A]}}"
doc <- generateGarbage "A" dir
closeDoc doc
garbage <- waitForGC
liftIO $ assertBool "no garbage was found" $ not $ null garbage

, testWithDummyPluginEmpty' "are deleted from the state" $ \dir -> do
liftIO $ writeFile (dir </> "hie.yaml") "cradle: {direct: {arguments: [A]}}"
liftIO $ atomicFileWriteString (dir </> "hie.yaml") "cradle: {direct: {arguments: [A]}}"
docA <- generateGarbage "A" dir
keys0 <- getStoredKeys
closeDoc docA
Expand All @@ -37,7 +38,7 @@ tests = testGroup "garbage collection"
liftIO $ assertBool "keys were not deleted from the state" (length keys1 < length keys0)

, testWithDummyPluginEmpty' "are not regenerated unless needed" $ \dir -> do
liftIO $ writeFile (dir </> "hie.yaml") "cradle: {direct: {arguments: [A.hs, B.hs]}}"
liftIO $ atomicFileWriteString (dir </> "hie.yaml") "cradle: {direct: {arguments: [A.hs, B.hs]}}"
docA <- generateGarbage "A" dir
_docB <- generateGarbage "B" dir

Expand All @@ -58,7 +59,7 @@ tests = testGroup "garbage collection"
liftIO $ regeneratedKeys @?= mempty

, testWithDummyPluginEmpty' "regenerate successfully" $ \dir -> do
liftIO $ writeFile (dir </> "hie.yaml") "cradle: {direct: {arguments: [A]}}"
liftIO $ atomicFileWriteString (dir </> "hie.yaml") "cradle: {direct: {arguments: [A]}}"
docA <- generateGarbage "A" dir
closeDoc docA
garbage <- waitForGC
Expand All @@ -83,7 +84,7 @@ tests = testGroup "garbage collection"
let fp = modName <> ".hs"
body = printf "module %s where" modName
doc <- createDoc fp "haskell" (T.pack body)
liftIO $ writeFile (dir </> fp) body
liftIO $ atomicFileWriteString (dir </> fp) body
builds <- waitForTypecheck doc
liftIO $ assertBool "something is wrong with this test" builds
return doc
3 changes: 2 additions & 1 deletion ghcide-test/exe/IfaceTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Language.LSP.Test
import System.Directory
import System.FilePath
import System.IO.Extra hiding (withTempDir)
import Test.Hls.FileSystem
import Test.Tasty
import Test.Tasty.HUnit

Expand Down Expand Up @@ -45,7 +46,7 @@ ifaceTHTest = testWithExtraFiles "iface-th-test" "TH" $ \dir -> do
cdoc <- createDoc cPath "haskell" cSource

-- Change [TH]a from () to Bool
liftIO $ writeFileUTF8 aPath (unlines $ init (lines $ T.unpack aSource) ++ ["th_a = [d| a = False|]"])
liftIO $ atomicFileWriteStringUTF8 aPath (unlines $ init (lines $ T.unpack aSource) ++ ["th_a = [d| a = False|]"])

-- Check that the change propagates to C
changeDoc cdoc [TextDocumentContentChangeEvent . InR $ TextDocumentContentChangeWholeDocument cSource]
Expand Down
3 changes: 2 additions & 1 deletion ghcide-test/exe/PluginSimpleTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Language.LSP.Protocol.Types hiding (SemanticTokenAbsolute (..),
SemanticTokensEdit (..), mkRange)
import Language.LSP.Test
import System.FilePath
import Test.Hls.FileSystem
import Test.Tasty

tests :: TestTree
Expand Down Expand Up @@ -36,7 +37,7 @@ tests =
-- required by plugin-1.0.0). See the build log above for details.
testWithExtraFiles "simple plugin" "plugin-knownnat" $ \dir -> do
_ <- openDoc (dir </> "KnownNat.hs") "haskell"
liftIO $ writeFile (dir</>"hie.yaml")
liftIO $ atomicFileWriteString (dir</>"hie.yaml")
"cradle: {cabal: [{path: '.', component: 'lib:plugin'}]}"

expectDiagnostics
Expand Down
5 changes: 3 additions & 2 deletions ghcide-test/exe/UnitTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import System.Mem (performGC)
import Test.Hls (IdeState, def,
runSessionWithServerInTmpDir,
waitForProgressDone)
import Test.Hls.FileSystem
import Test.Tasty
import Test.Tasty.ExpectedFailure
import Test.Tasty.HUnit
Expand Down Expand Up @@ -104,9 +105,9 @@ findResolution_us :: Int -> IO Int
findResolution_us delay_us | delay_us >= 1000000 = error "Unable to compute timestamp resolution"
findResolution_us delay_us = withTempFile $ \f -> withTempFile $ \f' -> do
performGC
writeFile f ""
atomicFileWriteString f ""
threadDelay delay_us
writeFile f' ""
atomicFileWriteString f' ""
t <- getModTime f
t' <- getModTime f'
if t /= t' then return delay_us else findResolution_us (delay_us * 10)
Loading
Loading