Commit Graph

508 Commits

Author SHA1 Message Date
Matthew Pickering
820aa24189 Always generate interface files and hie files 2020-06-01 19:51:52 +01:00
Moritz Kiefer
5419882dbf Set PATH in the right place (hopefully) 2020-05-30 13:52:41 +02:00
Matthew Pickering
b32e6c629c Modify path 2020-05-30 11:02:12 +01:00
Matthew Pickering
832eb69c22 Add cabal to CI images 2020-05-30 10:16:47 +01:00
Matthew Pickering
a7d0a056b9 Fix hlint 2020-05-30 10:08:36 +01:00
Matthew Pickering
f7e18a3eb7 Add multi-component test 2020-05-30 10:04:52 +01:00
Matthew Pickering
47d1ef0cb8 Fix 8.4 build 2020-05-30 10:04:02 +01:00
Matthew Pickering
5e4e87822e Final tweaks? 2020-05-23 10:59:02 +01:00
Matthew Pickering
9527499f45 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>
2020-05-23 10:56:58 +01: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
Neil Mitchell
e16e841fa7
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.
2020-05-22 16:11:56 +02:00
Matthew Pickering
3ec5edf3d0
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 <moritz.kiefer@purelyfunctional.org>
2020-05-22 12:04:32 +02:00
Matthew Pickering
126e39815b
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
2020-05-22 11:02:00 +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
Pepe Iborra
d54fd38b14
Log cache dir (#567) 2020-05-18 10:26:04 +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
Pepe Iborra
a2e091c5ac
Fix upper bounds for ghc-check (#565) 2020-05-17 16:01:19 +02:00
maralorn
5ac6e200c0
Extend nix explanations in README (#549)
* Extend nix explanations in README

* Correct ghcide-nix url

Co-authored-by: Domen Kožar <domen@enlambda.com>

Co-authored-by: Domen Kožar <domen@enlambda.com>
2020-05-13 19:46:45 +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
Pepe Iborra
15bb044269
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
2020-05-08 15:48:05 +02:00
Alan Zimmerman
6a650be7e3
Expose executeAddSignatureCommand (#543) 2020-05-04 10:18:32 +02:00
Carlo Hamalainen
f080f67d0e
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
2020-05-04 10:02:31 +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
Adam Sandberg Eriksson
cfcdf645b3
type alias for FilePathId maps and sets (#521) 2020-05-03 17:55:26 +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
Neil Mitchell
397323807b
#510, mention haskell-language-server in the README (#513) 2020-04-27 10:02:29 +02:00
Pepe Iborra
39605333c3
Expose an option to control the number of Shake threads (#504) 2020-03-27 10:54:15 +01:00
Alan Zimmerman
116a5baee1
Expose codeAction and codeLens providers for haskell-language-server (#499)
* Expose codeAction and codeLens providers for haskell-language-server

Also tweak the code action reply type to generate well-formed JSON

* Expose moduleOutline for symbolProvider in hls too

* Revert to using [CAResult] rather than List CAResult
2020-03-24 12:40:56 +01:00
Pepe Iborra
9ccd9eec08
Detect ghc mismatch (#462)
* Detect ghc version mismatches

* Add ghc-check to stack extra deps

* ghc-check: explicit libdir and delay version error
2020-03-24 12:40:21 +01: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
209be0b162
Treat alex the same way as happy to avoid CI issues (#497) 2020-03-20 15:32:15 +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
Moritz Kiefer
07a5d325d5
Allow disabling the simplifier in compileModule (#496)
It causes problems for our conversion to DAML-LF atm and isn’t
necessary (since we don’t have template Haskell) so let’s make it
configurable. I originally thought we could just copy paste all of
compileModule to DAML but it turns out that this pull in too much
stuff that I don’t want to see diverge from `ghcide` so I abandoned
that idea.
2020-03-20 14:41:53 +01:00
Moritz Kiefer
73ad8af648
Make keywords customizable (#493)
This is necessary for DAML where we have additional
keywords (e.g. `with`) and other keywords don’t
exist (e.g. `foreign`).

I considered using just a modify function `[T.Text] -> [T.Text]`
but decided against it in the end. The list is small enough and I
think it’s much easier to understand with an explicit enumeration (and
you can just show the field in the options which is often convenient
for debugging).
2020-03-20 10:05:58 +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
Javier Neira
8ba58ccdf1
Add azure job for windows and restructure azure config files (#475)
* Add azure job for windows and ghc-8.6

* Trigger build in branches starting with azure

* Add other valid stack.yaml to windows using matrix

* Using azure task Cache@2 instead CacheBeta@0

* Ignore tests in windows for now

* Install happy standalone to avoid spurious build error

* Add comment about installing happy

* Use matrix names more consistent with existing ones

* Enable build using ghc-8.8.2 for windows

* Ignore .vscode dir

* Use templates and matrix in linux job
2020-03-19 12:16:46 +01:00
Alan Zimmerman
bd53aced70
Expose underlying hover and gotoDefinition handlers (#490)
For use in haskell-language-server
2020-03-19 11:41:09 +01:00
Alan Zimmerman
8b328bb7c5
Working on Plugin support for haskell-language-server (#477)
* Working on Plugin support for hls

Fix PluginCommand reply type for executeCommand needs

* Remove PluginCommand

It will move to haskell-language-server instead

* Make azure CI hlint happy

By removing explicit OverloadedStrings pragma, in favour of the one already
enabled in the cabal file.

* Remove unneeded 'do'

* Fix more nits from review
2020-03-16 11:31:18 +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