* 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>
With the repo now officially transferred from Digital Asset's control to
the open-source Haskell organization, there is no good reason for master
builds to ping DA anymore. This (the corresponding Slack token "secret")
is also the only piece of non-open-source configuration in the existing
build process, so it needs to be removed before the CI can be
transferred.
* 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.
* Split out the session loading logic into a sublibrary
This way haskell-language-server can also reuse this logic.
Note that this sublibrary is public so it requires cabal-version: 3.0
Part of the work towards #478
* Move Development.IDE.Session into ghcide itself
Sublibraries do not seem to play well. Hide this behind the ghc-lib flag
so that the Haskell specific hie-bios stuff can be disabled
Note that we need to put the template-haskell part of this module into a
separate module because of an access exception when compiling with
Stack, GHC 8.10.1 and Windows.
* 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.
* Ignore tags file
* Pass an updated StringBuffer in ModSummary construction
The `getModSummaryFromBuffer` function constructs a `ModSummary` that
will be included in the `ParsedModule` data structure ghcide will later
on typecheck, calling any registred plugin in the process.
There was a problem, though: such `ModSummary` didn't include the
updated `StringBuffer` representing the in-memory content of a file
being edited (inclusive of all its unsaved changes). This was causing
plugins to not react in real time and emitting diagnostics only upon
save.
This commit fixes it.
* 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>
* Backport HIE files support to 8.6
* 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.
* Performance improvements
getSpanInfo was naively calling getDocumentations multiple times on the same
name. Fixed by deduplicating these calls.
getDocumentations is implemented on top of InteractiveEval.getDocs, which does
a lot of Ghc setup internally and is very inefficient. Fixed by introducing a
batch version of getDocs and batching all the calls in getSpanInfo
name | success | samples | startup | setup | experiment | maxResidency
------------- | ------- | ------- | ------- | ----- | ---------- | ------------
edit (before) | True | 10 | 6.94s | 0.00s | 6.57s | 177MB
edit (after) | True | 10 | 6.44s | 0.00s | 4.38s | 174MB
* More performance improvements
Played the deduplication trick on lookupName, which is slow for the same reasons
as getDocs. Batching made a smaller difference in my measurements, so did
not implement it
* Fix redundant constraints
* Skip the GHCi code paths for documentation
We don't use the interactive module, so there's no reason to go through the GHCi
code paths. Moreover, they apparently cause problems with ghc-lib.
* Skip the GHCi paths for lookupName
* Correctly load the module interface
* Compatibility with GHC 8.4 and 8.6
* Fix ghc-lib build
* 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>
* Use stale information for hover and completions
This introduces a new function `useWithStaleFast` which returns with
stale information WITHOUT checking freshness like `use` and
`useWithStale`.
Greatly improve debug logging
All actions triggered by shakeRun now also pass an identifier which
means that the debug logging shows which actions are starting/finishing
We also distinguish between internal and external events. By default
external events are ones triggered by runAction and the debug output
is displayed to the user in command line and --lsp mode.
In order to see internal logging statements, there is a new flag called
--verbose which also prints out internal events such as file
modification flushes.
Cleaner variant using runAfter
Step 1: Do not run actions with shakeRun
Queue implementation, living, breathing
Use a priority queue to schedule shake actions.
Most user actions are answered immediately with a cache but also
spawn a shake action to check the cached value we consulted was up to
date.
* Remove DelayedActionExtra
* hlint
* Fix progress
* Always block instead of fail on initial computation
* Can block for code lens
* Update docs
Co-authored-by: Zubin Duggal <zubin@cmi.ac.in>
* 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
* 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
* [bench-hist] save messages to log file
And fix the commitid rule to always rerun the git query
* Do not build benchHist by default
Hopefully avoiding the additional dependencies for charts
* Simplify with FileStdout
* Add a flag for bench-hist
Could benchHist be a benchmark instead of an executable, removing the need
for this flag?
Almost. `stack bench` fails because `benchHist` cannot find `ghcide-bench`
in the path. It seems like a bad idea to have a benchmark that fails out of
the box
* Turn benchHist into a benchmark and ghcide-bench into an exe
This works out nicely because:
1. benchHist already runs ghcide-bench,
2. benchHist has additional deps, but ghcide-bench does not.
(benchmark deps don't get built by default)
3. This is the only way I've found to get ghcide-bench in the PATH for benchHist
* Remove redundant dep on applicative-combinators
* Bump versions in stack-ghc-lib.yaml
* update lower bounds for extra in benchHist executable
* Update README guideline on benchmarks
* [benchHist] Fix the commitid rule to always rerun the git query
* fix caps
* 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
* fix debouncer for 0 delay
The indirection caused by `async (sleep 0 >> fire)` was causing the progress done messages to be sent before diagnostics, causing the code actions benchmark experiment to fail randomly.
* fix exception masking
* 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>
It keeps crashing and annoying everyone. The issue is in GHC not in
our code and I believe it’s fixed in HEAD already but that doesn’t
help us so let’s add some retries for now.
* 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
* Cache a GHC session per module
We set up a GHC session (load deps, setup finder cache) every time we want to:
- typecheck a module
- get the span infos
This is very expensive, and can be cached.
* cache the Ghc session for files of interest only
* hlint
* fix 8.4 build
* Early cut-off for ModSummary rule
This allows to bypass work when a module imports & pragmas haven't changed,
e.g. GetDependencies, GetDependencyInformation, GetLocatedImports, etc.
* remove extraneous reverse
Not sure where that came from
* review feedback
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.