Commit Graph

133 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
14e30e4136
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
2020-06-12 14:11:13 +02:00
Neil Mitchell
154e57fdda
#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
2020-06-09 10:35:40 +02:00
Matthew Pickering
08e87add92
Implement Goto Type Definition (#533)
* Implement Goto Type Definition
2020-06-09 10:32:11 +02:00
Pepe Iborra
0ff88c6ccc
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:

98c2a83585

* Log timings for code actions, hovers and completions

* Rename shakeRun to shakeRestart

The action returned by shakeRun now blocks until another call to shakeRun is made, which is a change in behaviour,. but all the current uses of shakeRun ignore this action.

Since the new behaviour is not useful, this change simplifies and updates the docs and name accordingly

* delete runActionSync as it's just runAction

* restart shake session on new component created

* requeue pending actions on session restart

* hlint

* Bumped the delay from 5 to 6

* Add a test for the non-lsp command line

* Update exe/Main.hs

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-06-08 11:36:36 +02:00
Matthew Pickering
373c4060df
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 <alan.zimm@gmail.com>
Co-authored-by: fendor <power.walross@gmail.com>

* Final tweaks?

* Fix 8.4 build

* Add multi-component test

* Fix hlint

* Add cabal to CI images

* Modify path

* Set PATH in the right place (hopefully)

* Always generate interface files and hie files

* Use correct DynFlags in mkImportDirs

You have to use the DynFlags for the file we are currently compiling to
get the right packages in the package db so that lookupPackage doesn't
always fail.

* Revert "Always generate interface files and hie files"

This reverts commit 820aa24189.

* remove traces

* Another test

* lint

* Unset env vars set my stack

* Fix extra-source-files

As usual, stack doesn’t understand Cabal properly and doesn’t seem to
like ** wildcards so I’ve enumerated it manually.

* Unset env locally

Co-authored-by: Alan Zimmerman <alan.zimm@gmail.com>
Co-authored-by: fendor <power.walross@gmail.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-06-02 14:44:16 +02:00
fendor
9129475b87
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 <moritz.kiefer@purelyfunctional.org>

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-05-23 09:54:25 +02:00
Pepe Iborra
ec0bbd1b1d
Remove interface loading diagnostics (#579)
* Drop interface loading diagnostics

* No reason to skip the --test flag anymore
2020-05-22 16:13:01 +02:00
Matthew Pickering
b478b82e29
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
2020-05-22 11:01:03 +02:00
Matthew Pickering
bc25ea79ab
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 <moritz.kiefer@purelyfunctional.org>

* Update test/exe/Main.hs

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-05-21 11:26:01 +02:00
Luke Lau
a1cb4eb8fa
Add record fields to doucment symbols outline (#564)
By collecting the fieldOcc names in the data con args
2020-05-18 16:04:16 +02:00
Luke Lau
cd6f62bbed
Use lsp-test-0.11 (#566)
Replace openDoc' with createDoc which sends out
workspace/didChangedWatchedFiles notifications
2020-05-17 16:37:08 +02:00
Luke Lau
5661348b5e
Upgrade to haskell-lsp-0.22 (#547) 2020-05-13 14:59:51 +02:00
Torsten Schmits
c7c39827d3
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
2020-05-11 16:57:41 +02:00
Dmitrii Kovanikov
07cf929ac6
[#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 <pepeiborra@gmail.com>

Co-authored-by: pepe iborra <pepeiborra@gmail.com>
2020-05-11 16:55:54 +02:00
J. S
d7c2bb6ff3
let suggest new imports work on symbol operators used infix (#540) 2020-05-08 15:48:33 +02:00
Neil Mitchell
3354a4f38c
Remove unnecessary HLint ignores now HLint 3.0.4 is out (#545) 2020-05-04 09:12:56 +02:00
Moritz Kiefer
9adb11125e
Fix HLint (#544)
Looks like the new version of hlint has a couple of new hints.

changelog_begin
changelog_end
2020-05-03 19:30:40 +02:00
Alan Zimmerman
78d4031f7c
Add a custom prefix to command IDs (#500)
* Add a custom prefix to command IDs

A client can run more than one instance of ghcide.  Some clients have a global
command registry, and all commands must be unique in that registry.

So to make the command ids unique, prefix them with the ghcide server process
id, as is done in haskell-ide-engine.

* Use same command naming scheme as in haskell-language-server

To ease interoperability

* Use makeLspCommandId for prefixing commands

This puts all the prefixing logic in one place.

* Add hlint exception for CPP in Development.IDE.Compat

* Bring in Win32 dependency for windows build
2020-04-27 12:59:13 +02:00
Pepe Iborra
4f9c7561ee
Parse module headers (#511)
* Create rule to get ModSummary without parsing entire source file

* Load file source from disk if not available in memory

* Fix build after cherry pick

* Couple of fixes

- extract getModSummaryFromImports and fix diagnostics
- replace GetParsedModule by GetModSummary where possible
  There is only one usage of GetParsedModule left, and that is in GetSpanInfos
  for documentation. This the wrong approach, docs should be loaded from
  interface files and not from sources. TODO

* Fix watched file tests

Progress notifications are not being sent anymore

* Compat with GHC 8.6

* Avoid parsing source files for completions and documentation

Instead, embed haddocks in interface files

* Allow CPP in module

* Force things after parsing in order to release buffers

* avoid holding on to stringbuffer unnecessarily

* Skip unnecessary file contents read

* Drop HscEnv requirement

* Add comments on forcing things

* Add comments on GHC_LIB restriction

* Parse files of interest twice to capture Haddock errors

If Opt_Haddock is not enabled we parse twice to capture Haddock parse errors

* Parallelize two-pass parsing

* Update src/Development/IDE/Core/Compile.hs

Co-authored-by: Marcelo Lazaroni <lazaronijunior@gmail.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-04-27 11:05:39 +02:00
Pepe Iborra
f804b138dc
Support for interface files (#457)
* Rules for loading interface files

* Typechecking with interface files

* Add a note in the README about the optimal project setup

* Improve support for hs-boot files

The branch was failing to load GHC because the module graph was missing
edges between a .hs file and its .hs-boot file. This means the .hs-boot
file was getting added into the HPT after the .hs file which led to
confusing errors about variables being out of scope.

The fix is to maintain a map from hs-boot to hs files and then add an
edge for this case when calling `transitiveDependencies`.

Also tidy up some code in setupEnv which I assume was attempting to fix
this but in an incorrect manner.

Add the -boot suffix when looking for hi-boot files.

For some reason, the `hi` path is not set to the right thing for
`hs-boot` files. I don't know why not perhaps it is ok to use an
existing `.hi` file in place of an `hs-boot` file. More investigation
needed. My experience is that GHC is quite bad a recompilation avoidance
for hs-boot files anyway.

For example: https://gitlab.haskell.org/ghc/ghc/issues/17434

Add the -boot suffix when writing interface files

* Generate .hi and .hie files during type checking

* Refactor GetModIface to not retain TypeChecked module in memory

This improves memory performance on a cold cache.

* Trailing whitespace

* Turn debug log messages into diagnostics

* Implement "hie" files for ghc-8.6.5

This means that the .hi files patch can also be used with 8.6.5

* Add tests for hover/definition on imported symbols

* hlints

* Generate .hie files when missing

* Fix subtle bug in setDefaultHieDir

* Simplify optimal project setup in README

* Move interface loading diagnostics behind --test flag

Reusing the --test flag for this seems harmless, I cannot justify introducing a
new flag

* Avoid expensive interface file generation for files of interest

* avoid redundant arguments (thanks Moritz K)

* qualify a DAML only comment

* Skip module source when generating hie file

thanks Moritz Kiefer for noting that we don't care for the generated .hie files
to embed module sources

* runGhcEnv <-> evalGhcEnv

* Apply suggestions from code review

Thanks Moritz Kiefer

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Add suggested Show instance

Co-Authored-By: Matthew Pickering <matthewtpickering@gmail.com>

* Use Control.Exception.Safe

This is to avoid accidentally capturing asynchronous exceptions

* Rename atomicFileUpdate

* Fix a flaky test

We have to be careful with module naming in tests to avoid interference of .hi
files across tests

* Undo formatting of D.IDE.GHC.Util

* follow changes in master

Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-03-24 12:39:53 +01:00
Moritz Kiefer
9b6e712251
Fix emptyPathUri (#502)
* Fix emptyPathUri

* Remove platform dependency
2020-03-23 12:21:23 +01:00
Javier Neira
9951f35b08
Use NormalizedFilePath and adapt types of haskell-lsp-0.21 (#479)
* Use custom version of h-l-t

* Use normalized path functions from h-l-t

* Restore empty path corner case

* Create a wrapper over NFP to override IsString

* Use maybe instead fromMaybe

* Use patched version of lsp-types in all yaml files

* Remove unused import

* Rename specific NormalizeFilePath to NormalizeFilePath'

* Remove specific newtype and IsString instance

* Use released haskell-lsp-0.21

* Adapt to type changes of haskell-lsp-0.21

* Add tags field to CompletionItem

* Fix test case about empty file path

* Correct stack.yaml used in azure ci cache

* Build ghcide including tests in windows azure ci

* Qualify haskell-lsp modules to avoid name clashes
2020-03-23 09:07:04 +01:00
Moritz Kiefer
45f9742461
Improve completion contexts (#495)
The completion context determines whether we show completions for
types or completions for values. This is done by looking at the parsed
module.

This PR fixes two things:

1. While we only use the parsed module for getting the context
   previously we got the parsed module out of the typechecked
   module. This means that if you have a module that parses but
   doesn’t typecheck, we will use the parsed module at the point where
   it last typechecked which is out of date and produces incorrect (or
   just no) contexts.
2. When we could not find a context, we defaulted to assuming we are
   in a value context. Especially in combination with 1 but also just
   in general, this is rather annoying. If we aren’t sure we should
   show the user everything we have and not filter out some
   completions. Filtering out completions interacts particularly badly
   with VSCode’s default behavior of accepting the first completion
   when you press return.
2020-03-20 14:42:10 +01:00
Matthew Pickering
7ecdd21874
Pass correct SafeHaskell information to mkIfaceTc (#489)
Seems like this was never implemented the first time, woops!

Fixes #424
2020-03-19 13:49:46 +01:00
Alan Zimmerman
111b6855e2
Use tasty-rerun to allow rerunning failed tests only (#484)
Use by

  stack --stack-yaml=stack84.yaml test --test-arguments "--rerun"
2020-03-16 09:07:50 +01:00
Pepe Iborra
c74e9b51f1
Fix two regressions since 0.1.0 (#471)
* Fix isWorkspaceFile for relative paths

This fixes a performance regression on GetFileExists

* Avoid interrupting hie-bios when it's doing its thing

I noticed that the GHC hie-bios direct cradle, which uses Hadrian, a Shake build
system, was failing to start due to the following problem:

1. ghcide starts evaluating the LoadCradle node
2. The evaluation gets cancelled
3. Immediately after, ghcide starts evaluating LoadCradle again
4. Hadrian fails, since there is still another Hadrian process alive taking its
Shake lock

* Improve watched files test suite
2020-03-10 18:06:39 +01:00
Pepe Iborra
da92de218a
Guess all imports (#459)
* Suggest missing imports via package exports map

At the expense of some space and initialization time, suggest imports now is
able to find suggestions in all the packages available to the project.

* BadDependency - include the key in the error message

* remove the assumption that the GhcSession is always available

* fix bad spacing

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Add type annotation to clarify rule being defined

* Remove file dependency from PackageExports rule

* Guess patterns

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-03-09 13:22:46 +01:00
Pepe Iborra
df63fd76c0
Tests for cradle loading (#460)
* Refactor: extract Rules to a separate module

* Add tests for cradle loading

* Fix default extensions in exe target

* Move cradle loaded messages behind a flag

* Use satisfy

Following a suggestion by Moritz Kiefer (@cocreature)
2020-03-04 17:31:24 +01:00
Pepe Iborra
acc4a0a77c
Guess more imports (#451)
Now guess missing imports also works for:

- Type names
- Data constructors
- Operators
- qualified things

Avoiding:

- internal modules
2020-02-25 18:19:25 +01:00
fendor
1e68cb0e05
Group Imports in Outline into a single node (#443)
* Group Imports in Outline into a single node

Makes it easier to see symbols in scope when you have lots of
import statements.

* Prefer explicit Maybe over List type
2020-02-21 11:21:00 +01:00
Pepe Iborra
5bea92f9d3
Code action to suggest adding missing imports from pkg db (#437)
* Code action to suggest adding missing imports from pkg db

The implementation looks in modules loaded from the package database. It should
only look in packages declared as dependencies of the project. The package
modules are loaded lazily and are global to the HscEnv, so the success rate will
depend on what has been loaded so far in the env.

* Avoid overlapping with extend import suggestions

> import Data.Text (Text)
> foo = pack "foo"

Teach ghcide to suggest only:

"Add pack to the import list of Data.Text"

and avoid suggesting also:

"Import Data.Text (pack)"
2020-02-18 09:36:38 +01:00
Pepe Iborra
f586955e8a
Fix redundant import code action corner cases (#433)
- Redundant "All" imports, e.g. Maybe(..)
 - Redundant datatype plus constructors, e.g. Maybe(Just)

Fixes #352
2020-02-18 09:22:17 +01:00
Pepe Iborra
286635bac8
Suggestions for missing pattern signatures (#436) 2020-02-17 11:22:51 +01:00
Jinwoo Lee
00d914efa7
Automatically pick up new dependencies (#408)
* Automatically pick up new dependencies

hie-bios's componentDependencies returns the dependencies of a cradle
that might change the cradle. Add those deps to the shake graph so that
the GHC session is newly created whenever they change.

For that, add a new rule type, GetHscEnvEq, to cache GHC sessions with
the key of GHC options and dependencies. And delete the optGhcSession
field from IdeOptions.

This is for https://github.com/digital-asset/ghcide/issues/50.

hie-bios's componentDependencies can return files that don't exist yet:
https://github.com/mpickering/hie-bios/blob/master/src/HIE/Bios/Types.hs#L90-L93.
This PR handles changes in the existing dependency files, but doesn't
handle newly created dependency files.

* address comments

* revert hie.yaml

* address more comments

* add test

* make direct cradles work; and use direct cradle in test
2020-02-17 10:33:33 +01:00