Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haddock comments plugin #673

Merged
merged 17 commits into from
Jan 7, 2021
Merged

Haddock comments plugin #673

merged 17 commits into from
Jan 7, 2021

Conversation

berberman
Copy link
Collaborator

@berberman berberman commented Dec 15, 2020

Screenshot:

Peek

I'm not familiar with ghc-exactprint, so I don't know if I use it correctly in this PR.
Should I define rules to store ASTs or Annotations?

  • Add tests
  • Support records
  • Compatible with multi version GHC

Closes #403

@jneira
Copy link
Member

jneira commented Dec 15, 2020

Taking a quick look it looks good, great job.
I am not an expert in ghc-exactprint cause i didn't have to use it directly yet, maybe @alanz or @pepeiborra could help.

@berberman
Copy link
Collaborator Author

Peek

@michaelpj
Copy link
Collaborator

It's a little unclear which haddock comments will be generated. It looks like it's mostly arguments? But not e.g. a comment for the binding itself. I guess what people want will differ, maybe we just need actions with more specific names? "Generate haddock comments (arguments)", "Generate haddock comment (binding)", "Generate haddock comments (all)"?

@berberman
Copy link
Collaborator Author

berberman commented Dec 16, 2020

Agree, code actions should have different titles. Now top-level type signatures and record fields are supported, so I think they can be "Generate signature haddock comments for [identifier]" and "Generate fields haddock comments for [identifier]".

What do you think? This might be a little bit verbose XD

@jneira
Copy link
Member

jneira commented Dec 16, 2020

There are mostly haddock comments, no? and the code action is for the identifier you are hovering, right?
"Generate signature comments" or "Generate fields comments" could be informative enough?

@berberman berberman marked this pull request as ready for review December 19, 2020 12:43
pepeiborra added a commit that referenced this pull request Dec 27, 2020
* 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 <[email protected]>

Co-authored-by: Moritz Kiefer <[email protected]>
pepeiborra added a commit that referenced this pull request Dec 29, 2020
* Update README with link to Docker build for Neovim and ghcide (#541)

* Add some troubleshooting notes.

* Update README with link to docker-ghcide-neovim instructions.

* Update README

* Expose executeAddSignatureCommand (#543)

* Improve ghc version check (#535)

- retrieve runtime version from ghc executable, not from pkg db (ghc-check 0.3.0.0)
- Do not error when unable to retrieve runtime version

* let suggest new imports work on symbol operators used infix (#540)

* [#518] Build ghcide with GHC 8.10.1 (#519)

* [#518] Build ghcide with GHC 8.10.1

Resolves #518

* Move CPP logic to the Compat module

* Revert changes to mkHieFile

* Add local fork of HieAst for 8.10.1

The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed

* Ignore hlint in src-ghc810/HieAst.hs

* Whitelist CPP for Development.IDE.GHC.Orphans

* [#518] Build ghcide with GHC 8.10.1

Resolves #518

* Move CPP logic to the Compat module

* Revert changes to mkHieFile

* Add local fork of HieAst for 8.10.1

The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed

* Ignore hlint in src-ghc810/HieAst.hs

* Whitelist CPP for Development.IDE.GHC.Orphans

* Plugin tests known broken in 8.10.1 (#556)

* Bump up ghc-check version

Co-authored-by: Pepe Iborra <[email protected]>

Co-authored-by: pepe iborra <[email protected]>

* Strip path information from diagnostic messages (#158) (#546)

* Strip path information from diagnostic messages (#158)

* remove a distinction between 8.6 and 8.4 from an error message test

* Upgrade to haskell-lsp-0.22 (#547)

* Extend nix explanations in README (#549)

* Extend nix explanations in README

* Correct ghcide-nix url

Co-authored-by: Domen Kožar <[email protected]>

Co-authored-by: Domen Kožar <[email protected]>

* Fix upper bounds for ghc-check (#565)

* Use lsp-test-0.11 (#566)

Replace openDoc' with createDoc which sends out
workspace/didChangedWatchedFiles notifications

* Log cache dir (#567)

* Add record fields to doucment symbols outline (#564)

By collecting the fieldOcc names in the data con args

* Track dependencies when using qAddDependentFile (#516)

* Track dependencies when using qAddDependentFile

Closes #492

* Add test for qAddDependentFile

* Update test/exe/Main.hs

Co-authored-by: Moritz Kiefer <[email protected]>

* Update test/exe/Main.hs

Co-authored-by: Moritz Kiefer <[email protected]>

Co-authored-by: Moritz Kiefer <[email protected]>

* Test that GotoHover.hs file compiles in the tests (#572)

* Testsuite: Only run with --test if necessary

* Add (failing) test to check GotoHover.hs file compiles

* Fix compilation of GotoHover.hs

* Fix 3 space leaks and refactoring of PositionMapping (#557)

* Rats: Fix space leak in withProgress

Eta-expanding the function means GHC no longer allocates a function
closure every time `withProgress` is called (which is a lot).

See: https://www.joachim-breitner.de/blog/763-Faster_Winter_5__Eta-Expanding_ReaderT

* Rats: Share computation of position mapping

Ensure that PositionMappings are shared between versions

There was a quadratic space leak as the tails of the position maps were
not shared with each other. Now the space usage is linear which is
produces more acceptable levels of residency after 3000 modifications.

* Rats: Eta-expand modification function

See: https://www.joachim-breitner.de/blog/763-Faster_Winter_5__Eta-Expanding_ReaderT

* Add a comment warning about eta-reducing

* Distinguish between a Delta and a Mapping in PositionMapping

A Delta is a change between two versions

A Mapping is a change from the current version to a specific older
version.

Fix hlint

Fix hlint

* Refactor rawDependencyInformation (#558)

* Refactor rawDependencyInformation

There are two reasons why this patch is good:

1. We remove the special case of the initial module from the dependency
search. It is now treated uniformly like the rest of the modules.

2. rawDependencyInformation can now take a list of files and create
dependency information for all of them. This isn't currently used but on
my fork we have a rule which gets the dependency information for the
whole project in order to create a module graph.

It seemed simplest to upstream this part first, which is already a
strict improvement to make the overal patch easier to review.

* Make indentation not depend on identifier length

Co-authored-by: Moritz Kiefer <[email protected]>

* Remove space leaks in a more robust way (#578)

Follow up from #557. We definitely want the progress state to be fully evaluated, so demand that with evaluating functions like evaluate and $!, rather than relying on the compiler to get it right. My guess is the `$!` is unnecessary now we have `evaluate`, but it's also not harmful, so belt and braces approach.

* Remove interface loading diagnostics (#579)

* Drop interface loading diagnostics

* No reason to skip the --test flag anymore

* Update to hie-bios 0.5.0 (#552)

* 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 <[email protected]>

Co-authored-by: Moritz Kiefer <[email protected]>

* Avoid deprecated Shake functions (#584)

In 0.18.4 deprioritise was renamed reschedule, so follow the new name.

* Make VFSVersion strict (#585)

* Remove the ShakeValue on A (#587)

* Fix the Hashable instance of Key (#588)

* Add Kakoune section to the README (#592)

* Add kakoune installation instructions

* Add additional files to roots field

* Improve the error messages around IdeGlobal's (#598)

* #599. register FileExistsMapVar global unconditionally (#600)

* Multi Component (#522)

* 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 <[email protected]>
Co-authored-by: fendor <[email protected]>

* 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 820aa241890c4498c566e29b0823a803fb2fd297.

* 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 <[email protected]>
Co-authored-by: fendor <[email protected]>
Co-authored-by: Moritz Kiefer <[email protected]>

* Prepare release of ghcide 0.2.0 (#601)

* Prepare release of ghcide 0.2.0

* Fix year in copyright notices

* Credit chshersh for the 8.10 support

* Benchmark suite (#590)

* Initial benchmark suite, reusing ideas from Neil's post

https://neilmitchell.blogspot.com/2020/05/fixing-space-leaks-in-ghcide.html

* Add an experiment for code actions without edit

* formatting

* fix code actions bench script

* error handling + options + how to run

* extract Positions and clean up imports

(Neil's review feedback)

* replace with Extra.duration

* allow ImplicitParams

* add bench to the cradle

* applied @mpickering review feedback

* clean up after benchmark

* remove TODO

* ShakeSession and shakeEnqueue (#554)

* 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:

https://github.com/ndmitchell/extra/commit/98c2a83585d2ca0a9d961dd241c4a967ef87866a

* 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 <[email protected]>

* remove unnecessary FileExists dependency in GetHiFile (#589)

* remove unnecessary FileExists dependency

It is subsumed by the GetModificationTime dependency.

One less dependency per .hi file,
one less redundant file system access,
five fewer lines of code.

* Clarify modification time comparisons for .hi and .hie filesAddresses #591

* Fix staleness checking for .hie files (thanks @cocreature)

* Implement Goto Type Definition (#533)

* Implement Goto Type Definition

* #573, make haddock errors warnings with the word Haddock in front (#608)

* #573, make haddock errors warnings with the word Haddock in front

* Update Rules.hs

* Deal with Haddock failures in getModIfaceRule

* Add back a .ghci file (#607)

* Use a better noRange (#612)

* Restore Shake profiling (#621)

* restore a comment

* Fix Shake profiling

A Shake profile is generated as part of the Shake session restart

* simplify message

* Fix regression in getSpanInfoRule (#622)

This rule used withstale dependencies prior to #457 and was changed to plain use
for no good reason, which makes hovers unavailable when a dependency doesn't
typecheck

* ghc initialization error handling (#609)

There are a couple of cases to handle as seen below.
Thanks @jneira for help discovering them all.
There used to be linking errors but I no longer see those after the multi-cradle patch

Non Nix
=========

The table below shows a couple of combinations of cradles and ghcide versions in a
non-Nix environment. All the version mismatches are now handled as follows:

- "Cannot satisfy package" -  `-package-id` flags referencing
  package versions not available (generally base)
- "bad interface" - tried to load an interface file created by a different version of ghc

cradle/ghcide | 8.6 | 8.8 | 8.10
--------------|-----|----|---
Cabal 8.6   | success | cannot satisfy package | cannot satisfy package
Cabal 8.8   | cannot satisfy package | success | cannot satisfy package
Cabal 8.10  | cannot satisfy package | cannot satisfy package | success
Stack 8.6   | success | bad-interface | bad-interfac-
Stack 8.8   | bad-interface | success | bad-interface
Stack 8.10  | bad-interface | bad-interface | success

Nix
=========

Because Nix redefines the libdir to point at the run-time ghc installation,
it's actually much easier to detect a version mismatch:
just compare the compile-time and run-time libdirs

* Fix a bug in getHiFileRule (#623)

* Fix bug in getHiFileRule

* Renamed GetHiFile to GetModIfaceFromDisk for clarity

* Add hie.yaml.stack and use none cradle for test data (#626)

* Add a none cradle for test data in cabal cradle

* Add a stack explicit hie-bios config

* Canonicalize the locations in the cradle tests (#628)

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

* More benchmarks (#625)

* Add a benchmark to track startup times

* Benchmark automation

disable benchmarks easily

save GC stats to file

cradle, rts, filter and samples options

path to ghcide

configurable example

--help

more detailed CSV output

hover after edit

pause for GC

configurable timeout

upgrade extra (required to build bench)

Include max residency in BenchRun

Include all details on output

* reduce threadDelay to avoid upsetting lsp-test

* Fix startup time measurement

* Added new edit experiment

* fix doc comment

* hlints

* Upgrade to lsp-test 0.11.0.2

* Flag failed experiments

* Update ghcide.cabal

* Performance analysis over time (#629)

* benchmark history script

* if HEAD no need to rebuild worktree

* add bench/README.md

* Enable all experiments

* Fix dependency tracking for git branches

* hlints

* Add stack84 extra-deps

* Identify failed experiments in graphs

* Filter our failed benchmarks from aggregate graphs

Otherwise they tend to distort the axis

* Improve graphs (more and easier to see colors)

* update cradles

* customizable output folder

* Cache the config for the duration of the script

Otherwise the script is vulnerable to config edits

* Allow omitting the git: field

* Ignore bench-hist intermediate artifacts

Handy for including bench-hist results in a branch while avoiding the
intermediate artifacts

* Write a cabal.project file in the benchmark example (#640)

* Write a cabal.project file

As suggested in #617. Taken fron #624

* Write a cabal.project.local

Otherwise Cabal still errors out

* Override default hie dir

Otherwise .hi and .hie files end up in different locations, which causes the getDefinition experiment to fail the second time it's run.

This is because we assume in ghcide that .hi and .hie files have the same lifetimes, which is not true when the ..hie files are wiped but the .hi files aren't.

* Fix crash when writing to a Barrier more than once (#637)

* Fix crash when writing to a Barrier more than once

* Less confusing now

* Report progress when setting up cradle (#644)

To do this we pass in the withProgress and withIndefiniteProgress
functions from LspFuncs into ShakeExtras

* Remove `Strict` from the language extensions used for code actions (#638)

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.

* Cache a ghc session per file of interest (#630)

* 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

* Add a note on differential benchmarks (#647)

* Send WorkDoneProgressEnd only when work is done (#649)

* 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

* Finer dependencies for GhcSessionFun (#643)

* 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

* Retry GHC 8.10 on Windows (#661)

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.

* Interface file fixes (#645)

* 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 <[email protected]>

* Code review feedback

* Address review feedback

https://github.com/digital-asset/ghcide/pull/645/files/49b0d9ac65399edf82a7a9cbbb8d8b5420458d8d#r443383239

* Change recomp to direct cradle

Co-authored-by: Zubin Duggal <[email protected]>
Co-authored-by: Moritz Kiefer <[email protected]>

* Fix debouncer for 0 delay (#662)

* 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

* stack810.yaml: bump (#651)

* Delete unused top level binding code action (#657)

* 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

* Make BenchHist non buildable by default and save logs (#666)

* [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

* Code action: add constraint (#653)

* 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

* Code action: add constraint (#653)

* 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

* Use stale information if it's available to answer requests quickly (#624)

* 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 <[email protected]>

* Avoid excessive retypechecking of TH codebases (#673)

* 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 <[email protected]>

Co-authored-by: Moritz Kiefer <[email protected]>

* Fix spaninfo Haddocks for local modules (#678)

* 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

* Completions need not depend on typecheck of the current file (#670)

* 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

* Use a global namecache to read `.hie` files (#677)

* Use global NameCache for reading HIE files

Co-authored-by: Matthew Pickering <[email protected]>

* 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 <[email protected]>

* Code action add default type annotation to remove `-Wtype-defaults` warning (#680)

* 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

* Performance improvements for GetSpanInfo (#681)

* 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

* Backport HIE files to GHC 8.6 (#689)

* 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.

* Update to hie-bios 0.6.1 (#693)

* Bump lodash from 4.17.15 to 4.17.19 in /extension (#702)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Expect bench experiments to fail with Cabal (#704)

* Obtain the GHC libdir at runtime (#696)

* 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 <[email protected]>

* Relax upper bounds for GHC 8.10.1 (#705)

* Relax upper bounds for GHC 8.10.1

* Update cabal.project

Co-authored-by: Moritz Kiefer <[email protected]>

* Allow GHC plugins to be called with an updated StringBuffer (#698)

* 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.

* Populate ms_hs_date in GetModSummary rule (#694)

* Populate ms_hs_date in GetModSummary rule

* More faithful ModSummary timestamps

* More ModSummary timestamps

* Address duplication

* Remove a displaced comment

* Fix Binary instance of Q to handle empty file paths (#707)

* Code action: remove redundant constraints for type signature (#692)

* 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.

* Move session loading logic into ghcide library (#697)

* 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.

* Expose GHC.Compat module (#709)

For use in haskell-language-server plugins

* Add links to haddock and hscolour pages in documentation (#699)

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.

* Codeaction for exporting unused top-level bindings (#711)

* 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

* Add session-loader to hie.yaml (#714)

* CI: remove (internal) DA Slack notifications (#750)

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.

* Prepare release of ghcide 0.3.0 (#753)

* Prepare release of ghcide 0.3.0

* Add ghcide contributors to copyright

* Typecheck entire project on Initial Load and typecheck reverse dependencies of a file on saving (#688)

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: Pepe Iborra <[email protected]>
Co-authored-by: Luke Lau <[email protected]>

* output which cradle files were found (#716)

* Use argsVerbose to determine log level in test mode (#717)

* Fix `.hie` file location for `.hs-boot` files (#690)

* Find source for boot files

* fix modlocs for boot files

* Add test

* Fix build on 8.6

* Generate doc file URL via LSP (to fix it for Windows) (#721)

* use three slashes in doc file URLs to fix it for Windows

* generate normalized doc file URL using LSP

* Fix issue #710: fix suggest delete binding  (#728)

* [CodeAction] reimplement suggestDeleteBinding

* [CodeAction] handle whole line removal for suggestDeleteUnusedBinding

* [CodeAction] add test for bug #710

* [CodeAction] add more tests for suggesting unused binding

* fix hlint warnings

* fix hlint warnings

* remove unused imports

* fix compilation problem for 8.4

* remove redundant pattern matching

* reconcile the disagreement of a pattern matching is redundant

* Ignore -Werror (#738)

* Ignore -Werror

Fixes #735

* Compat with GHC < 8.8

* Bump hie-bios bounds (#744)

* module Development.IDE (#724)

A single module to reexport all the commonly used names to simplify the use of
ghcide as a library

* Include module path in progress message (#746)

* Suggest open imports (#740)

Also fixes two bugs with qualified imports

Fixes #480

* Show documentation on hover for symbols defined in the same module (#691)

* 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

* Use InitializeParams.rootUri for initial session setup (#713)

* add rootUri tests

* use rootUri in session loader

* Don't report nonsense file names (#718)

* Don't report nonsense file names

* add and fix -Wincomplete-uni-patterns

* Add a test case involving -fno-warn-missing-signatures (#720)

* Only enable non-fatal warnings

* Revert the change since it has been taken care of in #738

* Dynamically load libm on Linux for each new session (#723)

This fixes the issue on Linux where the binary was statically linked and
Template Haskell (or the eval plugin on haskell-language-server) tried
to evaluate some code. It would previously fail to load ghc-prim because
it couldn't lookup symbols from libm which are usually dynamically
linked in.

* Suggestions for missing imports from local modules (#739)

* Suggestions for missing imports from local modules

* Avoid unnecessary work on InitialLoad when checkProject is off

* Expose `getCompletionsLSP` to allow completions in hls (#756)

Co-authored-by: Koray Al <[email protected]>

* Remove duplicate line from changelog (#754)

* Remove duplicate line from changelog

* Bump release date

* Fix haddock to markdown conversion (#757)

* Minimal nix-shell script (#749)

* Add ghc-check >=0.5.0.1 version bound (#761)

* Increase timeout of azure windows job (#762)

* Handle multiple user actions concurrently (#727)

* 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

* Don't typecheck parents when there are no known files (#758)

* Refinement holes (#748)

* 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

* Fix bug in exports map (#772)

It was appending lists of identifiers without pruning duplicates

* Improve hist benchmarks driver and add to CI (#770)

* Remove hardcoded --stack-yaml and upstream/master assumption

* support Cabal in bench suite

* add benchmark run to CI

Even if the time measurements are unreliable in a shared CI environment, the
memory usage will be an accurate indicator of space leaks

* Update bench/README

* use origin/master

* default to stack in benchmarks (for CI)

* ignore ghcide-bench and ghcide-preprocessor binaries too

* Review feedbacks

* Add the v0.3.0 tag in bench/hist.yaml

commented out to keep the CI time as tight as possible

* Add .artifactignore file to avoid publishing binaries in azure bench pipeline

* use default stack.yaml

* Fully asynchronous request handling (#767)

* 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

* GHC 8.8.4 & 8.10.2 (#751)

* GHC 8.8.4 & 8.10.2

* plugins test fixed on 8.10.2

* use GHC 8.10.1 on windows to workaround a bug

* Preserve import paths for implicit cradles (#768)

* Preserve import paths for implicit cradles

Implicit cradles do not list targets, see discussion in

https://github.com/haskell/ghcide/issues/765

* Really preserve import paths

* Use hie-bios-0.7.1 (#763)

* Save source files with HIE files (#701)

* Write ifaces on save (#760)

* 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

* Import paths are relative to cradle (#781)

* 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

* Add Haddocks and exports for use* combinators (#783)

* Add Haddocks for use combinators

* Add useWithStale to Development.IDE

* Add defineEarlyCutoff to Dev.IDE

* Dispatch notifications synchronously (#791)

* Disable optimisation in tests (#790)

Ideally we would do this with a Cabal flag, but I don't think it is possible
to disable optimisation only for the tests stanza

* Sort import suggestions (#793)

* Fix setFileModified and restore test (#789)

* Restore kick and reenable iface-error-test-2

This test failure did hide a real bug

* Use --rerun in CI

* Extend position mapping with fuzzy ranges (#785)

* Extend position mapping with fuzzy ranges

* fix tests

* add bangs

* make fields lazy again

* Use implicit-hie when no explicit hie.yaml (#782)

* Use implicit-hie when no explicit hie.yaml

* Use implicit-hie-cradle master in all build config files

* Set correct hie-bios version for ghc-8.10.1

* Fix windows ci build

* Fix stack 8.6 build (#801)

* Fix stack 8.6 build

* Avoid sharing the cache between test and bench stack builds

* Add hie-bios revision to stack.yaml

https://github.com/haskell/ghcide/pull/801#issuecomment-691833344

Skipping other stack descriptors as not strictly needed

* Disable benchmark job until master is fixed

* Skip unnecessary packing of cache artifacts (#794)

* Skip unnecessary packing (takes 2m) when we had a successful cache hit

* Pack before testing

* Reenable benchmark CI

* Disable Windows CI

Caching is broken and stackage builds fail all the time with timeouts to
casa.fpcomplete.com

* Send a warning when using the implicit cradle (#799)

* Send a warning when using the implicit cradle

* Implicit cradle

Co-authored-by: Neil Mitchell <[email protected]>

Co-authored-by: Neil Mitchell <[email protected]>

* Use implicit-hie-cradle-0.2.0.0 (#806)

* Include test dependencies in cache (#807)

* Fix obsolete hie.yaml.cbl and hie.yaml.stack (#778)

* Fix obsolete hie.yaml.cbl and hie.yaml.stack

* delete and ignore hie.yaml

* Revert "delete and ignore hie.yaml"

* Restore -threaded (#809)

Without -threaded lsp-test no longer times out, and tests get stuck
instead of failing with a helpful error message

* Enable windows ci (#808)

* Enable windows ci

* Rewrite comments and retry for all ghc versions

* Cache stack dirs directly

* Increase timeout for bench ci build

Co-authored-by: Pepe Iborra <[email protected]>

* Mark files as modified on open (#810)

* Mark files as modified on open

* Remove pack/unpack cache from linux jobs (#812)

* Support parsedResultAction of GHC plugins (#795)

* 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 c3921504210f9ebadb8d9c1b04a39c2371a8a71a.

* 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

* Prepare for release 0.4.0 (#811)

* Fix import suggestions when dot is typed (#800)

* Fix module suggestions

* Document PositionMapping

* Remove maybe

* Use optExtensions in Session loader (#816)

* Use optExtensions in Session loader

* Add boot suffix to target possible extensions

* Preserve more information about targets (#820)

* Preserve more information about targets

* Correctly model the special target

This should prevent infinite looping on cradles that do not provide targets,
such as the hie-bios implicit cradle (no longer used)

* Restore identifiers missing from hi file (#741)

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 completion tests for records. (#804)

* Fix documentation (or source) link when html file is less specific than module (#766)

* show doc/source link when html file name is less specific than module name

* try most qualified file names first, both dash and dot delimited

* small cleanup

* make hlint happy

* hlint again

* Enhance benchmarks & bug fixes (#823)

* parse allocations

* WaitForShakeQueue

* Measure user time and shake time in experiments

* clean ups

* Prevent a potential crash of the shake enqueue thread

* Fix a bug that was preventing reenqueud actions from getting flushed

* Avoid running the check-project action per file

What we really want is to check the project once per cradle

* Backwards compat.

* Review feedback

* Fix typo

Co-authored-by: Neil Mitchell <[email protected]>

Co-authored-by: Neil Mitchell <[email protected]>

* Fix docs tooltip for base libraries on Windows (#814)

* Prepare for release 0.4.0

* lookup haddock dir via haddockInterfaces

* Fix broken base libraries documentation on Windows

* use findM to get just first existing file

Co-authored-by: Pepe Iborra <[email protected]>

* Update instructions for stty error in windows (#825)

* Closes #68

* Use hie-implicit-cradle-0.2.0.1 (#827)

To fix https://github.com/haskell/haskell-language-server/issues/417

* Store the lsp client settings in shakeExtras and create a Rule to get them (#731)

* Store client settings in ide state

* Log ide config registered in initHandler

* Use a Maybe aware updater function

* Create a Rule to get client settings

* Create a specific getter for client settings

* Trim trailing whitespace

* Use modifyVar to avoid race conditions

* Add comment to GetClientSettings

* Use defineEarlyCutOffNoFile for GetClientSettings

* Restart shake on config changed

* Use Hashed for clientSettings

* Send log notifications to client about session

* Show test output directly

* Add tests over client settings

* Apply hlint hints

* Simplify iface test to make it more robust

Following @pepeiborra advise

* Send session notifications only in test mode

* Retry bench execution

* Tag unused warning as such (#815)

* Tag unused warning as such

* Fix compilation for 8.4

* Always enable warning for unneeded elements + fix tests for them

* Apply suggestions by @ndmitchell

* Fix a diagnostics test after merge

Co-authored-by: Neil Mitchell <[email protected]>

* Enable test suite to run in parallel (#833)

* Enable test suite to run in parallel

To run the test suite in parallel with Cabal:

> cabal test --test-options="+RTS -N"

Locally, this runs the test suite in 58s in a Xeon with 56 logical cores

Importantly, this change does not change CI
(unless stack passes +RTS -N secretly)

* Revert runInDir

* Add GetHieAsts rule, Replace SpanInfo, add support for DocumentHighlight and scope-aware completions for local variables (#784)

* Add GetHieAsts rule

* hlint

* fix build for 8.4

* Reimplement Hover/GotoDefn in terms of HIE Files.
Implement Document Hightlight LSP request
Add GetDocMap, GetHieFile rules.

* Fix gotodef for record fields

* Completion for locals

* Don't need to hack cursor position because of fuzzy ranges

* hlint

* fix bench and warning on 8.10

* disable 8.4 CI jobs

* Don't collect module level bindings

* tweaks

* Show kinds

* docs

* Defs for ModuleNames

* Fix some tests

* hlint

* Mark remaining tests as broken

* Add completion tests

* add highlight tests

* Fix HieAst for 8.6

* CPP away the unexpected success

* More CPP hacks for 8.10 tests

* Remove 8.4 CPP (#834)

* Remove 8.4 CPP

* hlint

* remove stack84.yaml

* FileExists: set one watcher instead of thousands (#831)

* FileExists: set one watcher instead of thousands

This prevents us from sending thousands of notifications to the client
on startup, which can lock up some clients like emacs. Instead we send
precisely one.

This has some consequences for the behaviour of the fast file existence
lookup, which I've noted in the code, alongside a description of how it
works (I spent a while figuring it out, I thought I might as well write
it down).

Fixes #776.

* Use fast rules only if it matches our watcher spec

* Fix duplicated completions (#837)

Co-authored-by: Vitalii Ovechkin <[email protected]>

* Allow to easily customise the example used for benchmarks (#838)

* [ghcide-bench] allow custom example

* [bench] allow custom example

* Add v0.4.0 entry for completeness

* Rename benchmark artifacts

bench/hist.yaml --> bench/config.yaml

bench-hist --> bench-results

* Fix Cabal file

* Fix tests

* No need for hardcoded experiment positions

* Fix the CI bench artifact (#841)

* Enable test suite in Windows, marking unreliable tests as ignored (#821)

* Enable tests in windows ci

* Use lsp-test-0.11.0.6

* Fix tests in windows

* Use chocolatey to install cabal in ci

* Fix test: type constructor external

* Fix test: non workspace file

* Mark cpp-error as ignored for windows

* Ignore plugin tests for windows

* Added Show instances for a few GHC API types (useful for debugging) (#844)

* Added Show instances for a few GHC API types

* FIxed import warning/error

* Rerun Windows tests just like linux tests (#846)

* Fix code action for adding missing constraints to type signatures (#839)

* Add failing tests

* Ugly fix, make tests pass

* Clean it up

* Make the tests more readable

* Use splitLHsQualTy

* Use object code for Template Haskell, emit desugarer warnings (#836)

* Use object code for TH

* Set target location for TargetFiles

* Fix tests

* hlint

* fix build on 8.10

* fix ghc-lib

* address review comments

* hlint

* better error handling if module headers don't parse

* Always desugar, don't call interactive API functions

* deprioritize desugar when not TH, fix iface handling

* write hie file on save

* more tweaks

* fix tests

* disable desugarer warnings

* use ModGuts for exports map

* don't desugar

* use bytecode

* make HiFileStable early-cutoff

* restore object code

* re-enable desugar

* review comments

* Don't use ModIface for DocMap

* fix docs for the current module

* mark test as broken on windows

* Disable the 8.8 Windows tests, too unreliable (#850)

* Disable the 8.8 Windows tests, too unreliable

* Disable the 8.10 Windows tests, idem

* Pull in local bindings (#845)

* Pull in local bindings

* Use the same traversal

* Cleanup LambdaCase

* Enable test suite for windows, ghc-8.8 and ghc-8.10 (#855)

* Remove -f-external-interpreter for 8.10

* Rerun tests in the first step

* Rerun tests in the first step for linux

* Wait for register caps

* Remove -f-external-interpreter for 8.10

* Rerun tests in the first step

* Rerun tests in the first step for linux

* Wait for register caps

* Refactor ignoreInWindows* functions

* Ignore test for win and ghc-8.8

* Enable all win jobs (again)

* Ignore in win the known broken in nix

* Ignore addDependentFile for ghc-8.8

* Ignore findsTHnewNameConstructor for ghc-8.8

* Use --rerun-update in first test execution

To make sure it creates/overwrites .tasty-rerun-log

* Add test for th link failure (#853)

* Downgrade file watch debug log to logDebug from logInfo (#848)

This gets quite noisy when cabal is building dependencies which makes it
hard to see what's going on.

* Do not show internal hole names (#852)

* Do not show internal hole names

* Better way to print holes as _

* Use suggestion by @alanz

* Remove unneeded import

* Give more time to suggestion tests

* Do not import GotoHover for testing suggestions

* Preserve envImportPaths in GhcSessionDeps (#862)

* Run benchmarks on a list of examples (#864)

- Cabal 3.0.0.0
- haskell-lsp-types 0.22.0.0

* Interleave and pretty print benchmark results (#866)

* Interleave benchmark results

* Pretty print benchmark results

* Canonicalize import dirs (#870)

* Canonicalize import dirs

* Fix unrelated hlint

* Fix pretty printer for diagnostic ranges (#871)

With the current implementation, VS Code will show "1:1" for the top
left corner, but the pretty printer renders this poisition to "1:0".
This is particularly interesting for people building command line tools
using `ghcide`, like the our DAML compiler at Digital Asset.
tools with command line drivers, like us at Digital Asset.

I would argue that VS Code has the ultimate authority on this since we
can't change what it displays without also moving the squiggly lines.

This PR fixes the discrepance by simply adding one to the column number
in the prtty printer, like we do for the line number.

* Add code action for remove all redundant imports (#867)

* Add code action for remove all redundant imports

* Call suggestRemoveRedundantImport only once

* Adjust tests for code action removing all redundant imports

* Update src/Development/IDE/Plugin/CodeAction.hs

Co-authored-by: Pepe Iborra <[email protected]>

* Refactor removeAll

* Update the test of remove all redundant imports

Co-authored-by: Pepe Iborra <[email protected]>

* Switch back to bytecode (#873)

* Switch back to bytecode

* return a HomeModInfo even if we can't generate a linkable

* set target to HscNothing

* add rule for GetModIfaceWithoutLinkable

* use IdeGlobal for compiled linkables

* Fix the guard target (#876)

* Add a test to check diagnistic ranges are printed 1-based (#878)

Recently, we fixed a bug in `prettyRange` where lines where rendered
1-based but columns 0-based. Let's make sure we don't get into such
weird situations again by adding a test.

* Move HIE files stuff to a new hie-compat package (#877)

* Move HIE files stuff to a new hie-compat package

* add ghc-lib flag for hie-compat

* ghc-lib :(

* ghc-lib :(((

* ghc-lib :((((

* ghc-lib :(((((

* Fix cabal check for hie-compat (#879)

* Fix cabal check for hie-compat

* ghc-lib :((((((

* simplify things unnecessarily running in GhcM (#875)

* simplify things unnecessarily running in GhcM

* untick catchSrcErrors

* set useUnicode

* Clarify and downgrade implicit-hie message (#883)

* Don't need to invoke full typechecking logic for completions (#882)

* Don't need to invoke full typechecking logic for completions

tcRnImportDecls is sufficient

* return imports along with ModSummary

* Use implicit-hie-0.1.2.0 (#880)

* Simplify and deduplicate ModSummary logic (#884)

* Simplify and dedup parsing logic

* delete removePackageImports

* add dependencies on included files

* hlint

* Expose Development.IDE.Core.Preprocessor (#887)

* Disable CI benchmark suite (#893)

* Test the stack version in the benchmark CI script

* [bench script] specify cwd in findGhc

* Disable CI bench script

* Expose Development.IDE.GHC.Orphans (#894)

* Compatibility with fbghc (#892)

* Compatibility with fbghc

Rather than forking ghcide, we use conditional compilation to build with https://github.com/facebook/fbghc hopefully only until certain changes have been upstreamed.

* Reexport DynFlags from Compat.GHC

* Add a link to the fbghc repo

* GitHub actions (#895)

* Add Github action for benchmarks

* Change action name to benchmark

* Fix - remove empty env section

* Rename step

* Add steps to print and upload results

* Shrink the matrix of versions for benchmarking

* Enable benchmarks

* rename job

* Fix fetch

* bump actions/setup-haskell

* disable windows - bench script requires Cairo

* Delete Azure bench script

* add comment on git fetch call

* clean up cache key

* Update archive step

* Prepare for 0.5.0 release (#896)

The changelog is a trimmed down summary of the git log.
I have removed several non-user visible changes while making sure that
everyone who contributed is listed at least once.

* Test fixes (#899)

* Fix plugin tests for 'cabal test'

* Check for Haddocks on Int instead of Text

The text package may have been installed without documentation, in which case
the test will fail. base is always installed with documentation

* Fix test in Mac OS

* Ignore plugin tests in GHC 8.10.1

* Update implicit-hie to 0.3.0 (#905)

* Avoid calling kick explicitly (#904)

* Avoid calling kick explicitly

Leverages that rules are rerun by shakeRunDatabase.
Allows users of ghcide as a library to use their own kick

* Tweak doc comment

* Parenthesize operators when exporting (#906)

* Parenthesize operators when exporting

* Add tests

* Only consider if the head is an operator letter

* GitHub test action (#903)

* Add github test action

* Disable unreliable test

Does not work reliably on all platforms.

Reenable when #861 lands

* Add hlint and -Werror

* Explicit timeout

6h is the default and also the maximum:

https://docs.github.com/en/free-pro-team@latest/actions/reference/usage-limits-billing-and-administration

* Experiment tests to use Cabal instead of Stack

* Fix an unreliable test

* Trim down matrix

* Add ghc-lib to the test matrix

* Address broken hie-compat ghc-lib build

* Drop stack descriptor family

We keep two stack descriptors:

- One for Nightly
- One for Windows (stuck in GHC 8.10.1)

To ensure that `stack test` doesn't break, we keep running the stack tests in CI

* Update README to point end users to HLS

* Drop support for `stack test`

* Remove allow-newer (#908)

* Do not enable every "unnecessary" warning by default (#907)

* Do not enable every "unnecessary" warning by default

* Fix tests that wait for diagnostics

* Bump up implicit-hie-cradle lower bound (#912)

* Bump up implicit-hie-cradle lower bound

* Allow insecure commands temporary

* Switch to sliding tags in Github actions (#915)

* Switch to sliding tags in Github actions

* Allow insecure actions should no longer be needed

https://github.com/actions/setup-haskell/issues/44

* Make Filetargets absolute before continue using them (#914)

* Add testcase for proving relative filetargets

* Normalise file targets after loading

* Extend import suggestions for more than one option (#913)

* Add support for extending import list when multiple options are available

* Add function to module export list to make it available for testing

* Fix typo

* Add doc strings

* Add tests for testing regex used to parse multiple choices for import suggestions.

* Add test group

* Remove trailing spaces

* Hlint suggestions

* Remove not used variable

* Remove temporary code

* Reuse matchRegExUnifySpaces

* Fix test input.

* Use testCase instead of testSession

* Update extend import tests to assert on multiple actions.

* Extend extendImports to use multiple modules for setup

* Hlint changes

* Add a GitHub action for the Nix build (#918)

* Add an action to build and cache the nix-shell

* [nix] ghc-paths must always be in the package set

Otherwise ghc-check will not get the Nix libdir and fail at compile time

* [nix] extract the nixpkgs instantiation to nix/default.nix

* [nix] niv init

* [nix] switch to haskell-updates

* Mention the Cachix binary cache in the README

* [nix] pin the version used to set up Cachix

* [nix] disable tests and jailbreak 8.10.x packages

* [nix] rely on cabal2nix to enumerate…
@jneira
Copy link
Member

jneira commented Jan 4, 2021

the pr needs a rebase and a final review
//cc @Ailrun

Copy link
Member

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some test cases (after rebase)?

keyFromTyVar dep (L _ (HsQualTy _ _ x)) = keyFromTyVar dep x
keyFromTyVar dep (L _ (HsParTy _ x)) = keyFromTyVar (succ dep) x
keyFromTyVar dep (L _ (HsBangTy _ _ x)) = keyFromTyVar dep x
keyFromTyVar _ _ = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function should also do some work for other cases like, for example, HsKindSig.
It might be better to cover cases explicitly (so that we can notice the change when GHC introduce a new constructor.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently HsType has 23 constructors, but we only use five of them, so I think enumerating all cases would be a little bit distracting...

:

Update project config files

Add CPP

Add missing include-dirs

Refactor

Support records

Only suggest when no error

Don't suggest if nothing to change

Update code action title and comment template

Remove toCurrentRange

Add haddock comments plugin

Update project config files

Add CPP

Remove temp files

Remove temp files

Remove spaces
Copy link
Member

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the tests!

test/functional/HaddockComments.hs Show resolved Hide resolved
test/functional/HaddockComments.hs Outdated Show resolved Hide resolved
@Ailrun
Copy link
Member

Ailrun commented Jan 6, 2021

It looks like testdata paths are duplicated.

Copy link
Member

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than these, LGTM.

test/testdata/haddockComments/Record.expected.hs Outdated Show resolved Hide resolved
@berberman
Copy link
Collaborator Author

Hmm, the record test looks unstable...

@berberman
Copy link
Collaborator Author

Hmm, the record test looks unstable...

Windows tests would fail. goldenVsString seems to be problematic, since it doesn't consider the line ends difference between Windows and *nix, as the documentation said. So I replaced it with goldenVsStringDiff, copying the git diff command from class plugin. It works well now 👍

@Ailrun
Copy link
Member

Ailrun commented Jan 7, 2021

Awesome, thanks!

@Ailrun Ailrun merged commit 57f28ff into haskell:master Jan 7, 2021
@berberman berberman deleted the haddock-plugin branch January 7, 2021 12:08
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Jan 9, 2021
* Add haddock comments plugin
:

Update project config files

Add CPP

Add missing include-dirs

Refactor

Support records

Only suggest when no error

Don't suggest if nothing to change

Update code action title and comment template

Remove toCurrentRange

Add haddock comments plugin

Update project config files

Add CPP

Remove temp files

Remove temp files

Remove spaces

* Minor refactor, remove CPP

* Fix stack-8.10.3.yaml

* Add test cases (unverified)

* Rename test data files, use golden test

* Fix paths of hs files in testing

* Add missing ConstFunction

* Fix paths

Fix paths

* Update annDeltaPos

* Steal goldenGitDiff from class plugin

Co-authored-by: Javier Neira <[email protected]>
Co-authored-by: Junyoung Clare Jang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeAction to create Haddock comments
5 participants