This
* fixes a part of https://github.com/digital-asset/ghcide/issues/614
by introducing a workaround for ghc droping some bindings that we still
need.
* Adds a regression test for this fix
* Adds a known broken test for the remaining part of the issue
* add failing test
* add fix (disable hasrecord due to linker error on my local machine)
* re-enable record-hasfield
* Allow CPP in Preprocessor module
* Revert "Allow CPP in Preprocessor module"
This reverts commit c392150421.
* apply pr 801
* move all the CPP to D.I.GHC.Compat
* fix hlint complaint
* unconditionally import MonadIO
* refactor, address PR comments
* isolate the two plugin tests
* minimize diff
* Fix test timeout
* Disable record pre processor test in 8.4
* Fix compiler warning on 8.4
* Fix yet another warning in 8.4
* Explicitly import for 8.4
* 8.4 again
* Don't apply this plugin in 8.4
The Plugins import is unavailable in 8.4
* CPP at it again
* Import paths are relative to cradle
I noticed ghcide HEAD was broken on the ghcide submodule of the hls repo.
* remove unused
* Fix comment placement
* Special case the implicit cradle
The implicit cradle comes without import paths, so we need to preserve the old
logic that synthetised them from the current module
* Hlint
* Fix timing issue: update known files before restarting the session
Also, DO NOT filter out missing targets
* Use --verbose when running tests
* Log test outputs on 3rd attempt
* Fall back to filtering known files
* hlint
* Upgrade KnownFiles to KnownTargets
* Use KnownTargets to filter modules, not module paths
* Fix test cradle
* Increase pauses in flaky test
* remove no longer needed check
* Disable ansi color codes in CI
* Disable flaky test
* Write ifaces on save
* Move isFileOfInterestRule to FileStore.hs and use real mtime for saved files
* hlint
* Add test
* fix flaky tests
* Only check for hie file in >= 8.6
* Cancellation of user actions
* Dispatch event handlers asynchronously
* add tests for asynchronous features
This adds a new Test plugin for custom requests
and a new blocking Command
* hlint
* Link the Testing plugin only when --testing
* Fix expectNoMoreDiagnostics
Needs also https://github.com/bubba/lsp-test/pull/74
* Upgrade lsp-test to a version that understands CustomClientMethod
* Refinement holes
* Set more GHC options and use indentation for parsing
* Add an option to customize the typed holes settings
Refinement hole fits are very cool, but currently too slow to enable at deeper
levels. It should eventually be user configurable.
* GHC Compatibility
* Compat. with 8.4
* tighten some return types
* Extract ShakeQueue from shakeSession
Instead of creating a new TQueue on every restart, we reuse the same TQueue
over and over.
The trickiest bit is to ensure that enqueued actions are always retried when
a Shake session is cancelled. The ActionQueue datatype is intended to manage
this complexity.
* Handle multiple user actions concurrently
* Fixes for .ghci
Unfortunately these are dependent on the ghc version
* redundant parens
* Formatting
* Attempt fix for completion tests
These tests are failing because ghcide is sending diagnostics interleaved with
completions now (which is good) and the tests cannot handle it
* remove debugging printout
* simplify
* Fix a test
* Fix flaky tests
* Show documentation on hover for symbols defined in the same module
When parsing a module, if parsing haddocks succeeds, then use them
Previously, even though we were parsing modules twice, with and without
haddocks, we were just returning the result of parsing without haddocks.
The reason for this was that Opt_KeepRawTokenStream and Opt_Haddock do
not interact nicely. We decided that for now it was better to fix an
actual issue and then solve the problem when hlint requires a module
with Opt_KeepRawTokenStream.
* Add option to decide which ParsedModule to return
* Add new command to GetModuleGraph for a session and propate changes to
modules
Only propagate changes to parent modules when saving
Typecheck files when they are opened, don't TC FOI
Add known files rule
Don't save ifaces for files with defered errors
Co-authored-by: Zubin Duggal <zubin@cmi.ac.in>
* Add configuration for parent typechecking
* hlint ignore
* Use targets to filter located imports (#10)
* Use targets to filter located imports
* Remove import paths from the GHC session
Otherwise GHC will prioritize source files found in the import path
* Update session-loader/Development/IDE/Session.hs
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* Add session-loader to hie.yaml (#714)
* move known files rule to RuleTypes
* Disable checkParents on open and close document (#12)
* Really disable expensive checkParents
* Add an option to check parents on close
Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
Co-authored-by: Luke Lau <luke_lau@icloud.com>
* Add PatSynBind to GHC.Compat
* Tests for "export unused top level binding" codeaction
* Add "export unused top-level binding" codeaction
* exportUnusedTests refactored
* Fix export unused codeaction
* NFC: remove unused import
* hlint
* add exports to the end of list instead
* handle the case where last export end with comma
Currently this only searches local documentation (generated with
`cabal haddock --haddock-hyperlink-source` or equivalent) but could be
extended to support searching via Hoogle in the future. And it works for
any of the core libraries since they come installed with documentation.
Will show up in hover and (non-local) completions.
Also fixes extra markdown horizontal rules being inserted with no
content in between them.
* Code action: remove redundant constraints for type signature
* Handle peculiar formatting
Make the content parsing safe for type signature formatted with an
arbitrary and unexpected number of spaces and/or line feeds.
* Update to hie-bios 0.6.1
* Obtain the GHC libdir at runtime using hie-bios
This replaces hardcoding the GHC libdir path with ghc-paths and instead
gets it at runtime through the hie-bios cradle. This means that the
ghcide binary should be a bit more distributable now, since it won't
rely on paths baked at compile time that are local to the machine it was
compiled on. And we also no longer need the ghcLibCheck since we are
comparing the coompiled and runtime versions with the installationCheck
(ghcVersionChecker)
Co-authored-by: Fendor <power.walross@gmail.com>
* Code action to add default type annotation to satisfy the contraints
this is useful when using `traceShow` with with OverloadedStrings
and type-defaults warning enabled
Handle the following cases:
- there is one literal and one contraint to be satisfied
- there are mulitple literals and/or multiple constraints
Adding type annotations to expressions that trigger type-defaults
warning is not part of this changes
* Simplify older test
* Fix hlint issue
* Use global NameCache for reading HIE files
Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
* ignore hlint
* redundant imports
* Use hie files as source of truth for name source spans.
Since we started reusing `.hi` files, this exposes a bug where definitions
aren't available since a bad source span from the `.hi` file gets put into
the NameCache. We rectify by ensuring the span in the NameCache always matches
the one from the `.hie` file.
This has surfaced because an interaction between the commit which uses `.hi`
instead of retypechecking and the change to use the shared global NameCache
to read `.hie` files.
* Add test for missing definitions
Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
* Faster completions
* optimize withProgressVar
We never remove elements from the map so alter is unnecesary
* [ghcide-bench] accept ghcide options
* Expand completion tests suite
* hlints
* completions for local foreign decls
* Minor improvements for local completions
* Restore completion docs in legacy code path
* Compatibility with GHC < 8.8
* fix merge issue
* address review feedback
* Fix regression in SpanInfo haddocks for local modules
The regression was introduced in #630.
I added `GhcSessionDeps` with the idea of reusing the typecheck GHC session
for computing the SpanInfo, instead of rebuilding it from scratch.
But I forgot to actually reuse it, or maybe the change got lost during the merge.
* Add test
* Hi file stability
* fix missing early cutoff in GetModIface
* tests for TH reloading
* Do not run hlint on test/data
* hlints
* Fix legacy code path
* Update test/exe/Main.hs
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Add missing instance constraint
* Add missing instance constraint with existing constraints
* Add missing function constraint
* Add missing function consraint with existing constraints
* Add some comments
* Improve type signature regex
* Remove redundant bracket
* Improve missing constraint searching.
Create entrypoint for missing constraint code action, in order to have a more
efficient parsing by routing to the relevant implementation.
Fix type signature name parsing.
Minor refactor.
* Minor refactor
* Delete unused top level binding code action
* Remove redundant brackets according to hlint
* Attempt to fix build issue on ghc-8.4
* Fix delete unused binding code action
- handle case of top level bindings defined in infix form
- when deleting some unused binding expand text deletion range to
beginning of next top level binding (if any was found)
* Modify delete unused binding code action
Sort all inspected bindings by location before processing
* Avoid sending top level binding delete action with no TextEdit
Happens when there is unused local binding
* Add test for inconsistent diagnostics
* Refactoring ModIfaceFromDisk
This started as a pure refactoring to clarify the responsibilities between
ModIface and ModIfaceFromDisk, but ended up having some behaviour changes:
1. Regenerate interface when checkOldIface returns something other than
UpToDate. This was a bug.
2. Do not generate a diagnostic when regenerating an interface.
2. Previously we conflated stale interface with other errors,
and would regenerate in both cases. Now we only regenerate in the first case.
Tentative fix for #597
* Split interface tests
* Always recompile modules with TH splices
Tentative fix for #614
TODO support stability
* Fix expectDiagnostics in MacOs
* Avoid File does not exist diagnostics for interface files
Fixes#642
* Clarify interface tests
* hlints
* Performance fixes
The previous changes were 10X slower, this is 20X faster than those, so 2X
faster than upstream, for some benchmarks
* formatting
* Fix GetModificationTime identity
The answer for a GetModification query is independent of the missingFileDiagnostics field
(as the diagnostics are not part of the answer)
* remove stale comment
* Avoid calling ghcSessionDepsDefinition twice
* Apply suggestions from code review
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Code review feedback
* Address review feedback
49b0d9ac65 (r443383239)
* Change recomp to direct cradle
Co-authored-by: Zubin Duggal <zubin@cmi.ac.in>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Cache the results of loadSession until the components change
* Track the cradle dependencies
* hlint
* Add cradle to watched files test
* Add comment on sessionVersion field
* send WorkDoneProgressEnd only when work done
* Progress reporting now spans over multiple overlapping kicks
* Repurpose benchmark experiments as tests
Fixes#650
* use stack to fetch from Hackage
* benchmark tests run with the same lsp-test config as other tests
* Fix stack cradle in benchmark
* Make stack unpack --silent
* Fix issues in "code actions after edit" experiment
- Repeated breaking edits make ghc run out of suggestions
- Diagnostics seem to come and go in-between edits, which leads to a timing
issue when asking for code actions. The fix is to wait for diagnostics to be
present before asking for code actions
* Fix stack.yaml generation in example project
* Fix getDefinition in GHC 8.4
Did it break before 0.2.0 or after?
* better naming for the progress event TVar
* stop progress reporting in shakeShut
https://github.com/digital-asset/ghcide/pull/649#discussion_r443408884
* hlint
Since the code action for language extension suggestions uses substring
matching, the presence of the literal name of an extension can trigger
a false positive.
`Strict` is an identifier that occurs frequently in imports, causing
the extension to be suggested rather than the removal of a redundant
import.
On macOS, the $TMPDIR folder leads to /var/blahblahblah, but this is
canonicalized to /private/var/blahblahblah for reasons beyond my
understanding. Either way, there were some test failures because of a
mismatch between the two, so canonicalize the Uris inside the locations
to fix this
* ShakeSession and shakeRunGently
Currently we start a new Shake session for every interaction with the Shake
database, including type checking, hovers, code actions, completions, etc.
Since only one Shake session can ever exist, we abort the active session if any
in order to execute the new command in a responsive manner.
This is suboptimal in many, many ways:
- A hover in module M aborts the typechecking of module M, only to start over!
- Read-only commands (hover, code action, completion) need to typecheck all the
modules! (or rather, ask Shake to check that the typechecks are current)
- There is no way to run non-interfering commands concurrently
This is an experiment inspired by the 'ShakeQueue' of @mpickering, and
the follow-up discussion in https://github.com/mpickering/ghcide/issues/7
We introduce the concept of the 'ShakeSession' as part of the IDE state.
The 'ShakeSession' is initialized by a call to 'shakeRun', and survives until
the next call to 'shakeRun'. It is important that the session is restarted as
soon as the filesystem changes, to ensure that the database is current.
The 'ShakeSession' enables a new command 'shakeRunGently', which appends work to
the existing 'ShakeSession'. This command can be called in parallel without any
restriction.
* Simplify by assuming there is always a ShakeSession
* Improved naming and docs
* Define runActionSync on top of shakeEnqueue
shakeRun is not correct as it never returns anymore
* Drive progress reporting from newSession
The previous approach reused the shakeProgress thread, which doesn't work anymore as ShakeSession keeps the ShakeDatabase open until the next edit
* Deterministic progress messages in tests
Dropping the 0.1s sleep to ensure that progress messages during tests are
deterministic
* Make kick explicit
This is required for progress reporting to work, see notes in shakeRun
As to whether this is the right thing to do:
1. Less magic, more explicit
2. There's only 2 places where kick is actually used
* apply Neil's feedback
* avoid a deadlock when the enqueued action throws
* Simplify runAction + comments
* use a Barrier for clarity
A Barrier is a smaller abstraction than an MVar, and the next version of the extra package will come with a suitably small implementation:
98c2a83585
* Log timings for code actions, hovers and completions
* Rename shakeRun to shakeRestart
The action returned by shakeRun now blocks until another call to shakeRun is made, which is a change in behaviour,. but all the current uses of shakeRun ignore this action.
Since the new behaviour is not useful, this change simplifies and updates the docs and name accordingly
* delete runActionSync as it's just runAction
* restart shake session on new component created
* requeue pending actions on session restart
* hlint
* Bumped the delay from 5 to 6
* Add a test for the non-lsp command line
* Update exe/Main.hs
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Multi component support
In this commit we add support for loading multiple components into one
ghcide session.
The current behaviour is that each component is loaded lazily into the
session. When a file from an unrecognised component is loaded, the
cradle is consulted again to get a new set of options for the new
component. This will cause all the currently loaded files to be
reloaded into a new HscEnv which is shared by all the currently known
components. The result of this is that functions such as go-to
definition work between components if they have been loaded into the
same session but you have to open at least one file from each component
before it will work.
Only minimal changes are needed to the internals to ghcide to make the
file searching logic look in include directories for all currently
loaded components. The main changes are in exe/Main.hs which has been
heavily rewritten to avoid shake indirections. A global map is created
which maps a filepath to the HscEnv which should be used to compile it.
When a new component is created this map is completely refreshed so each
path maps to a new
Which paths belong to a componenent is determined by the targets listed
by the cradle. Therefore it is important that each cradle also lists all
the targets for the cradle. There are some other choices here as well
which are less accurate such as mapping via include directories which
is the aproach that I implemented in haskell-ide-engine.
The commit has been tested so far with cabal and hadrian.
Also deleted the .ghci file which was causing errors during testing and
seemed broken anyway.
Co-authored-by: Alan Zimmerman <alan.zimm@gmail.com>
Co-authored-by: fendor <power.walross@gmail.com>
* Final tweaks?
* Fix 8.4 build
* Add multi-component test
* Fix hlint
* Add cabal to CI images
* Modify path
* Set PATH in the right place (hopefully)
* Always generate interface files and hie files
* Use correct DynFlags in mkImportDirs
You have to use the DynFlags for the file we are currently compiling to
get the right packages in the package db so that lookupPackage doesn't
always fail.
* Revert "Always generate interface files and hie files"
This reverts commit 820aa24189.
* remove traces
* Another test
* lint
* Unset env vars set my stack
* Fix extra-source-files
As usual, stack doesn’t understand Cabal properly and doesn’t seem to
like ** wildcards so I’ve enumerated it manually.
* Unset env locally
Co-authored-by: Alan Zimmerman <alan.zimm@gmail.com>
Co-authored-by: fendor <power.walross@gmail.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Update to hie-bios 0.5.0
* Fix test-cases due to changes in the direct cradle
* Update test/exe/Main.hs comment
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Track dependencies when using qAddDependentFile
Closes#492
* Add test for qAddDependentFile
* Update test/exe/Main.hs
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
* Update test/exe/Main.hs
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>