Commit Graph

574 Commits

Author SHA1 Message Date
Pepe Iborra
2fece7f7e2
Suggest open imports (#740)
Also fixes two bugs with qualified imports

Fixes #480
2020-09-02 19:41:41 +01:00
Pepe Iborra
7b1de958eb
Include module path in progress message (#746) 2020-09-02 19:31:56 +01:00
Pepe Iborra
2a71723395
module Development.IDE (#724)
A single module to reexport all the commonly used names to simplify the use of
ghcide as a library
2020-09-02 23:58:07 +05:30
maralorn
3e1b362094
Bump hie-bios bounds (#744) 2020-09-02 19:18:57 +01:00
Pepe Iborra
b76ef4261c
Ignore -Werror (#738)
* Ignore -Werror

Fixes #735

* Compat with GHC < 8.8
2020-09-02 19:16:57 +01:00
Ray Shih
535e9bdc10
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
2020-09-02 19:12:46 +01:00
Nick Dunets
cf5df3c467
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
2020-09-02 19:06:28 +01:00
wz1000
0350c7f97e
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
2020-09-02 18:53:09 +01:00
Ziyang Liu
271c6e0ea7
Use argsVerbose to determine log level in test mode (#717) 2020-09-02 18:44:25 +01:00
Adam Sandberg Eriksson
9f1f55410b
output which cradle files were found (#716) 2020-09-02 18:43:35 +01:00
wz1000
b4589aebe6
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 <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>
2020-09-02 18:06:04 +01:00
Pepe Iborra
6128c74ba2
Prepare release of ghcide 0.3.0 (#753)
* Prepare release of ghcide 0.3.0

* Add ghcide contributors to copyright
2020-09-02 17:34:28 +01:00
Gary Verhaegen
d4f6b91646
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.
2020-09-01 16:36:35 +02:00
Luke Lau
765967d19b
Add session-loader to hie.yaml (#714) 2020-07-28 13:39:39 +02:00
shaurya gupta
826e886ada
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
2020-07-27 14:38:22 +02:00
Luke Lau
3eecfd07f1
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.
2020-07-27 09:30:04 +02:00
Pepe Iborra
bcc13b020c
Expose GHC.Compat module (#709)
For use in haskell-language-server plugins
2020-07-27 09:11:23 +02:00
Luke Lau
412193716d
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.
2020-07-27 09:10:25 +02:00
Denis Frezzato
4890bafaac
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.
2020-07-27 08:56:54 +02:00
Moritz Kiefer
6a72d99bfb
Fix Binary instance of Q to handle empty file paths (#707) 2020-07-24 16:47:20 +02:00
Pepe Iborra
02177b1873
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
2020-07-22 14:42:35 +02:00
Alfredo Di Napoli
4b6e691136
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.
2020-07-20 11:09:32 +02:00
Pepe Iborra
0f06d30611
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 <moritz.kiefer@purelyfunctional.org>
2020-07-20 11:07:49 +02:00
Luke Lau
ce39ec43c4
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 <power.walross@gmail.com>
2020-07-20 11:07:23 +02:00
Pepe Iborra
251ee08da3
Expect bench experiments to fail with Cabal (#704) 2020-07-20 09:43:22 +02:00
dependabot[bot]
8a96da605b
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] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-20 09:42:36 +02:00
fendor
1ca896980d
Update to hie-bios 0.6.1 (#693) 2020-07-16 11:30:45 +02:00
wz1000
993cfddc79
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.
2020-07-16 11:26:58 +02:00
Pepe Iborra
cbafcf29f4
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
2020-07-13 16:50:58 +02:00
Serhii
9272bfe030
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
2020-07-10 08:55:36 +02:00
wz1000
f32f666d2e
Use a global namecache to read .hie files (#677)
* 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>
2020-07-09 14:16:50 +02:00
Pepe Iborra
7dc6e2678a
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
2020-07-06 15:06:10 +02:00
Pepe Iborra
035019d5f5
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
2020-07-01 09:20:51 +02:00
Pepe Iborra
cdfc4b6e06
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 <moritz.kiefer@purelyfunctional.org>

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-07-01 09:19:38 +02:00
Matthew Pickering
d999084820
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 <zubin@cmi.ac.in>
2020-06-30 11:22:20 +02:00
Denis Frezzato
a873c28b67
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
2020-06-29 11:48:56 +02:00
Denis Frezzato
7cc91dc33d
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
2020-06-29 11:35:19 +02:00
Pepe Iborra
bd51ad0a63
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
2020-06-29 11:00:53 +02:00
Serhii
849aef854d
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
2020-06-29 08:58:28 +02:00
Domen Kožar
2116138984
stack810.yaml: bump (#651) 2020-06-23 14:50:01 +02:00
Pepe Iborra
8a9b8148c2
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
2020-06-23 14:49:44 +02:00
Pepe Iborra
d4fd99edb3
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 <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>
2020-06-23 11:01:52 +02:00
Moritz Kiefer
ac8d7cd6c1
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.
2020-06-22 20:57:47 +02:00
Pepe Iborra
7080db99e3
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
2020-06-22 18:06:50 +02:00
Pepe Iborra
ba4bdb2def
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
2020-06-22 12:47:45 +02:00
Pepe Iborra
5b8d7fa661
Add a note on differential benchmarks (#647) 2020-06-22 10:22:07 +02:00
Pepe Iborra
8de10e9474
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
2020-06-17 12:35:21 +02:00
Torsten Schmits
0d806c3b21
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.
2020-06-17 09:10:07 +02:00
Luke Lau
71631d8e8f
Report progress when setting up cradle (#644)
To do this we pass in the withProgress and withIndefiniteProgress
functions from LspFuncs into ShakeExtras
2020-06-17 07:52:49 +02:00
Pepe Iborra
0ddc62fb96
Fix crash when writing to a Barrier more than once (#637)
* Fix crash when writing to a Barrier more than once

* Less confusing now
2020-06-15 16:38:00 +02:00