Commit Graph

174 Commits

Author SHA1 Message Date
Martin Huschenbett
9f3fc619f0
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.
2020-10-20 11:37:24 +05:30
wz1000
71c88dc521
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
2020-10-19 11:48:54 +05:30
Potato Hatsue
cf143ea22d
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 <pepeiborra@me.com>

* Refactor removeAll

* Update the test of remove all redundant imports

Co-authored-by: Pepe Iborra <pepeiborra@me.com>
2020-10-18 13:20:03 +01:00
Pepe Iborra
6af874ddb6
Canonicalize import dirs (#870)
* Canonicalize import dirs

* Fix unrelated hlint
2020-10-15 16:44:52 +01:00
Alejandro Serrano
bfe2563517
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
2020-10-10 13:49:21 +01:00
wz1000
2f7487e6ca
Add test for th link failure (#853) 2020-10-09 21:03:28 +01:00
Javier Neira
b60a64f0d2
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
2020-10-09 21:00:21 +01:00
wz1000
03bdcaebfd
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
2020-10-04 21:34:43 +05:30
Jan Hrcek
d6fc31e16b
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
2020-10-04 16:06:51 +01:00
Javier Neira
df13c5ad84
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
2020-10-02 10:18:28 +02:00
Pepe Iborra
a52741838b
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
2020-09-29 07:47:09 +01:00
Vitalii
85f3738e82
Fix duplicated completions (#837)
Co-authored-by: Vitalii Ovechkin <ovechkinve@yandex-team.ru>
2020-09-28 09:23:12 +01:00
Michael Peyton Jones
b279afbce7
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
2020-09-27 21:13:40 +01:00
wz1000
1bb4c49fda
Remove 8.4 CPP (#834)
* Remove 8.4 CPP

* hlint

* remove stack84.yaml
2020-09-27 22:38:40 +05:30
wz1000
62f4d0644a
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
2020-09-27 09:07:25 +01:00
Pepe Iborra
1cda5edf0d
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
2020-09-26 18:53:38 +01:00
Alejandro Serrano
d64397b5d3
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 <ndmitchell@gmail.com>
2020-09-24 17:02:38 +01:00
Javier Neira
c361a26195
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
2020-09-23 20:54:27 +01:00
Guru Devanla
26cb575563
Add completion tests for records. (#804) 2020-09-20 09:27:57 +01:00
maralorn
b387bb2f35
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
2020-09-18 21:46:53 +05:30
Sridhar Ratnakumar
8d478394af
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 c392150421.

* apply pr 801

* move all the CPP to D.I.GHC.Compat

* fix hlint complaint

* unconditionally import MonadIO

* refactor, address PR comments

* isolate the two plugin tests

* minimize diff

* Fix test timeout

* Disable record pre processor test in 8.4

* Fix compiler warning on 8.4

* Fix yet another warning in 8.4

* Explicitly import for 8.4

* 8.4 again

* Don't apply this plugin in 8.4

The Plugins import is unavailable in 8.4

* CPP at it again
2020-09-16 08:57:44 +01:00
wz1000
ea25142419
Mark files as modified on open (#810)
* Mark files as modified on open
2020-09-15 21:39:45 +05:30
wz1000
b980c33cb9
Extend position mapping with fuzzy ranges (#785)
* Extend position mapping with fuzzy ranges

* fix tests

* add bangs

* make fields lazy again
2020-09-13 18:41:14 +01:00
Pepe Iborra
2225d7fe72
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
2020-09-13 13:27:59 +01:00
Pepe Iborra
7dacc236ea
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
2020-09-12 10:01:01 +01:00
wz1000
15ab2ff3ac
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
2020-09-11 20:58:23 +01:00
Domen Kožar
0b34b1ee6a
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
2020-09-07 17:07:56 +01:00
Pepe Iborra
684be6885d
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
2020-09-07 12:29:05 +01:00
Pepe Iborra
8f0a4f842c
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
2020-09-06 02:13:17 +05:30
Pepe Iborra
5dd52ec0ff
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
2020-09-05 13:52:17 +01:00
Pepe Iborra
09aa8e5f4b
Suggestions for missing imports from local modules (#739)
* Suggestions for missing imports from local modules

* Avoid unnecessary work on InitialLoad when checkProject is off
2020-09-03 09:32:40 +01:00
Ziyang Liu
599b27a32b
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
2020-09-03 05:34:14 +01:00
shaurya gupta
cb2fd665f2
Use InitializeParams.rootUri for initial session setup (#713)
* add rootUri tests

* use rootUri in session loader
2020-09-03 01:53:06 +01:00
wz1000
bfafe3b465
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
2020-09-02 21:33:28 +01:00
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
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
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
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
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
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
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