Commit Graph

61 Commits

Author SHA1 Message Date
Jinwoo Lee
3bec234ddb Support plugins (#192)
* Support plugins

Call initializePlugins before running typecheck.

* call initializePlugins only for GHC >= 8.6

initializePlugins doesn't exist in older GHC versions.

* A separate function for initializing plugins

* Add a test for plugins
2019-11-15 09:27:28 +01:00
Jacek Generowicz
440fc1f049 Add goto def / hover tests for classes (#177)
+ internal class in instance declaration
+ internal class in type signature
+ external class in type signature

Hover seems not to work for classes at all.

Goto def works for internal classes, but not external ones.

This leaves the table looking like this:

| | find definition | hover |
|-------------|-----------|---------|
| field in record definition | ✔️  | ✔️ |
| field in record construction |   |  |
| field name as accessor | ✔️ | ✔️ |
| top level name | ✔️ | ✔️ |
| record data constructor |  |  |
| plain data constructor | ✔️ | ✔️  |
| type constructor | ✔️ |  |
| external type constructor |  |  |
| external value |  | ✔️ |
| plain parameter | ✔️ | ✔️ |
| pattern match name | ✔️ | ✔️ |
| top level operator | ✔️ | ✔️ |
| parameter operator | ✔️  | ✔️  |
| name in backticks | ✔️ | ✔️ |
| class in instance declaration | ✔️ |  |
| class in signature | ✔️ |  |
| external class in signature |  |  |
2019-10-23 09:27:48 +02:00
Jacek Generowicz
5645a8030c Move test sample code out to external file (#175)
* Move sample code out into into separate source file

* Add test/data/GotoHover.hs to cabal extra-source-files

* hlint: explicit module export list

* hlint: implement and use readFileUtf8

* hlint: remove -Wmissing-signatures
2019-10-22 16:41:13 +02:00
Jacek Generowicz
38c29030d1 Add gotoDef/hover tests for values from other package (#168)
* Add gotoDef/hover tests for values from other package

* Make Expect constructor names more explicit

* Clean up assertions

* Replace funky function composition operator

* Add signature to checkHoverRange

* Clean up assertion
2019-10-21 10:23:03 -04:00
Moritz Kiefer
5febbcbc48
Fix progress reporting (#153)
* Fix progress reporting

* Bump haskell-lsp and lsp-test revisions

* Change client name

* Fix typo

* Bump revisions
2019-10-17 11:11:52 +02:00
Jacek Generowicz
23ff24978f Add goto/hover tests for type constructors from other package (#167) 2019-10-15 12:20:35 +02:00
Moritz Kiefer
2a67821e60
Avoid file path normalization in moduleImportPath (#152)
This fixes some issues where we used an uppercase drive letter in the
import path even though the LSP client uses lowercase drive letters
2019-10-04 09:37:47 +02:00
Jacek Generowicz
726af7fb3f Signal code actions in initialize response (#150) 2019-10-04 08:57:23 +02:00
Jacek Generowicz
986bc04014 Stop waiting in tests which don't need to (#145)
A while ago, `testSession` was modified to include a 0.5s wait, for
the sake of tests which were looking for a specific and complete set
of diagnostics, in order to ensure that all the incoming diagnostics
had been received before the comparison was made. This made sense at a
time when the vast majority of tests fit this pattern. Today we have
plenty of tests which have no need for this. Hence:

+ `testSession` has been renamed to `testSessionWait`

+ a new `testSession` has been added, which does not wait at all

+ all tests which use `expectDiagnostics` have been modified to use
  `testSessionWait`, all other tests use the new delayless
  `testSession`.

Locally this knocks almost 25% off the runtime of the full test
suite.
2019-10-01 14:52:07 +02:00
Jacek Generowicz
3284878b7b Add tests for initialize response (#147)
These tests document and monitor the evolution of the capabilities
announced by the server in the initialize response.

Currently the server advertises almost no capabilities. Out of 23
top-level categories, the only 3 which are announced are

+ text document sync
+ hover
+ goto definition

At the very least code actions are known to be provided, but are not
announced in the initialize response.
2019-10-01 13:03:06 +02:00
Jacek Generowicz
5257eb7d9d Refactor goto-definition and hover tests (#146)
+ Reduce manual duplication of information shared between hover and
  goto-def tests

+ Make sure that all the information in the test specifications that
  relates to fiddly line and column numbers, fits together on one
  screen, and is generally easier to match and understand by eye.
2019-10-01 09:24:33 +02:00
Jacek Generowicz
2779dbb2e1 Add tests for find-definition and hover (#139)
* Add find definition tests

* Add tests for hovers
2019-09-29 12:03:16 +02:00
Neil Mitchell
60ed687de9 Support multiple hie.yaml files (#127)
* Hack around https://github.com/mpickering/hie-bios/pull/56 - hie-bios expects files to really exist on disk

* Fix getLocatedImportsRule to pass the file to the session

* Add support for multiple simultaneous hie.yaml files.
Also rewrites the user experience on setup to be less verbose.
Also adds masking for GHC session construction.

* HLint

* Code review comments

* Switch to the Strict map
2019-09-25 13:01:41 +02:00
Jacek Generowicz
2879735a97 Fix deferred messages (#120)
* Test deferred error report message

The text of the deferred {type errors, typed holes, out of scope
variables} should call them 'error', instead it reports 'warning'.

* Change warning to error in deferred messages
2019-09-24 20:41:38 +02:00
Jacek Generowicz
bf9ee2a62b Add code actions for missing type signatures (#81)
* Add code actions for missing top-level type signatures

* Turn signature tester into operator
2019-09-19 19:40:52 +02:00
Jacek Generowicz
a162e81aa3 Defer type errors (#47)
* TEST: Degrade type error to warning

It will be upgraded again later, but for the time being we want to see
whether the proposed mechanism for deferring type errors works at
all. As it turns out the first, most obvious approach, does not
work: this is documented in the next commit.

A second approach was found that does work, and appears in the commit
after the next.

This test is failing until the second approach is implemented.

* Defer type errors (first approach: FAILED)

The idea is to set the `-fdefer-type-errors` and
`-fwarn-deferred-type-errors` flags, by setting options
programatically inside the `Ghc` monad.

Deferral of type errors was not observed with this approach. The
(less obvious) approach used in the next commit seems to be more
successful.

* Defer type errors (second approach: SUCCESS)

This approach modifies the `ParsedModule` which is passed to
`GHC.typecheckedModule` by hie-core's `typecheckModule`.

Type warning deferral is now observed at run time, and the tests pass.

* TEST: Reinstate severity of type errors

So far, type errors have been deferred and reported as warnings.

The next step is to ensure that the deferred type errors are reported
as errors rather than warnings, once again. This test fails until the
implementation arrives in the next commit.

* Upgrade severity of deferred Type Errors after typecheck

... and make the test pass again.

* Hide helper functions in local scopes

* Stop setting Opt_WarnDeferredTypeErrors

... and the tests still pass, thereby confirming @hsenag's hypothesis
that this flag is not needed.

* TEST: Check that typed holes are reported as errors

* TEST: Downgrade severity of typed holes Error -> Warning

This test fails, thereby falsifying the hypothesis that
`Opt_DeferTypeErrors` implies `Opt_DeferTypedHoles`.

* Defer typed holes

... and pass the failing test.

* TEST: Reinstate severity of typed holes

... failing the test until the implementation catches up in the next
commit.

* Upgrade severity of deferred Typed Holes after typecheck

... and pass the test once again.

* TEST: Degrade variable out of scope from Error to Warning

... test fails until next commit.

* Defer out of scope variables

... passing the test which was changed in the last commit.

* TEST: Reinstate severity of out of scope variables

... failing the test, and forcing the implementation to catch up.

* Upgrade severity of deferred out of scope vars after typecheck

... passing the test once again.

* Add explicit tests for deferrals

* Add IdeOption for deferral switching

* Improve documentation of optDefer

* Add IdeDefer newtype
2019-09-17 14:28:20 +02:00
Moritz Kiefer
29d84e835b
Enable more warnings for the ghcide codebase (#75) 2019-09-17 08:50:20 +02:00
jacg
4fc09fafa2 Code actions for filling typed holes (#69)
* Add code action for filling type holes

* Incorporate hole name into action title

Useful if more than one hole appears on the same line. Not so useful
if both of these holes are just `_` rather than `_name` (or more than
one hole on the same line has the same `_name`): In which case perhaps
some numbers could be attached to the action titles, to distinguish
the holes. But I suspect that this would not be worth the effort.

* Add tests for fill-type-hole actions

* Disable two tests on GHC 8.4

These test hints about local bindings, whic GHC 8.4 does not provide.

* Replace compilerVersion with new MIN_GHC_API_VERSION macro
2019-09-16 16:43:50 +02:00
Moritz Kiefer
de7295a89f
Merge pull request #52 from jacg/module-not-found-action
Code action for 'module not found'
2019-09-14 13:02:58 +02:00
Ganesh Sittampalam
316d78a471 Make sure warnings use unqualified names where appropriate
Because we are constructing the message objects ourselves, as
opposed to error messages which are constructed by GHC, we need
to take care to respect the passed-in 'PprStyle'.
2019-09-13 13:43:57 +01:00
Jacek Generowicz
f53faf8734 Add code action for GHC's suggestions for not-found module 2019-09-13 08:43:16 +02:00
Olle Fredriksson
8d0e4a2ca0 Add support for removing redundant qualified imports 2019-09-12 22:51:46 +02:00
Olle Fredriksson
fdefb6bc6d Add a test for removing an unused module 2019-09-12 22:51:10 +02:00
Moritz Kiefer
14b0b16aec
Merge pull request #27 from hsenag/type-wildcards
Code action for type wildcards
2019-09-12 15:58:51 +02:00
Ganesh Sittampalam
de35c8fe99 Code action to fill in GHC's suggested type signature for _ 2019-09-12 10:08:01 +01:00
Moritz Kiefer
f4553757dd
Merge pull request #39 from ollef/master
Handle PackageImporting "this"
2019-09-12 10:03:26 +02:00
Olle Fredriksson
2312cba385 Add PackageImport test 2019-09-12 09:39:13 +02:00
Tim J. Baumann
eb818353fc Add code action for fixing misspelled variable names
The suggestions are extracted from GHC's error messages.

To make parsing these error messages easier, we set the flag
useUnicode=True, which makes GHC always use “smart quotes”.
2019-09-11 22:48:09 +02:00
Alexander Diemand
67b4d40af4
added unlit stage for literate Haskell source files
Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
2019-09-11 11:56:26 +02:00
Moritz Kiefer
de8148b994 Remove Bazel config 2019-09-10 17:05:25 +02:00
Ganesh Sittampalam
87c68e1029 ghcide: support hs-boot files (#2827) 2019-09-10 15:01:33 +02:00
Ganesh Sittampalam
61760936f9 ghcide: make tests fail on unexpected diagnostic messages (#2813) (#2823)
This has the downside of relying on a timeout, experimentally tuned
to be 0.5s, as we have no other way of knowing when the server has
finished sending us messages.
2019-09-10 15:01:33 +02:00
Moritz Kiefer
5da86c3e44 Rename hie-core to ghcide (#2820)
* Rename hie-core to ghcide

The name `hie-core` has caused a lot of confusion as to how we relate
to haskell-ide-engine so changing it should hopefully help with that.
I also think that ghcide is still a good name once we hopefully
integrate with haskell-ide-engine more closely.

The name ghcide seems to have a reasonable amount of support on
Twitter https://twitter.com/ndm_haskell/status/1170681262987710464
which is of course the only good way to come up with names.

* Add a readme that points people to the new directory.

* Fix bogus replacements

* Use a proper link

* links are hard
2019-09-10 15:01:29 +02:00
Andreas Herrmann
20b4945681 Rename hazel_deps to hackage_deps (#2789)
* hazel_deps --> hackage_deps

Mechanical change:

```
sed -i 's/hazel_deps/hackage_deps/g' $(ag -l hazel_deps)
```

* Hazel dependencies --> Hackage dependencies
2019-09-10 14:52:17 +02:00
Andreas Herrmann
f8985134db Add more hie-core diagnostics tests (#2535)
* hie-core test: missing modules

* hie-core test: variable not in scope

* hie-core test: cyclic module dependency

* hie-core test: redundant import

* hie-core test: type error

* hie-core test: reorganise test

* hie-core test: factor out diagnostic tests

* Display unexpected diagnostics
2019-09-10 14:52:17 +02:00
Moritz Kiefer
0f0e6740c1 Only report progress when client supports it (#2517)
* Only report progress when client supports it

This fixes an issue that some people encountered when running hie-core
in Emacs with a version of haskell-lsp that does not understand
progress events.

* Fix tests

* More test fixes
2019-09-10 14:52:17 +02:00
Gary Verhaegen
10c59a01c2 update copyright notices (#2499) 2019-09-10 14:52:17 +02:00
Andreas Herrmann
ae37b4b21c stack/cabal for hie-core-tests (#2287)
* stack/cabal for hie-core-tests

* ./fmt.sh
2019-09-10 14:52:17 +02:00
nickchapman-da
26986fed0e {-# LANGUAGE OverloadedStrings #-} is now on by default (#2270) 2019-09-10 14:52:17 +02:00
Andreas Herrmann
8bce2ddee2 hie-core/test: Dedicated test suite for hie-core (#2243)
* hie-core/test: Dedicated test suite for hie-core

* Apply hlint suggestion

Use System.Environment.Blank's setEnv which has a non-overwrite mode
that implements precisely what we were doing with more code before.

* buildifier fixes

* hie-core-exe works on Windows now - ghc-paths was fixed
2019-09-10 14:52:17 +02:00
Neil Mitchell
72593a285d Make hie-core outside an IDE work better (#1895)
* Move the hie-core demo files around (they aren't really a demo anymore)

* Split the command line parsing into a separate module

* Give messages about how long starting something takes

* Make the interactive mode say what it is doing a bit more

* Add a --cwd flag to hie-core

* Take a list of files and directories for hie-core

* Update the readme to say how to test using hie-core

* Fix up the bazel file

* Add HLint exception
2019-09-10 14:52:17 +02:00
Neil Mitchell
124a4d47da Make the hie-core server retargetable (#1873)
* Move mergeHandlers into Server

* Make partial handlers a proper newtype

* Pass the options in to runLanguageServer

* Take in user handlers

* Remove the code lens handler since we don't advertise it

* Add setSomethingModified, rather than faking it for the LSP VFS

* Rewrite the LSP notifications

* Improve the display of info messages around openning and modifying text documents

* Make sure stdout and stderr don't have buffering, so we see their output immediately

* Handle exit properly

* Make notifications forward on to their previous values

* Remove the exit handler, HIE already has a good default for it

* Add comments on FileStore
2019-09-10 14:52:17 +02:00
Neil Mitchell
7870ee8043 Significantly alter the hie-core LanguageServer (#1862)
* Inline chunks of LSP.Server into LanguageServer

* Inline runServer

* Start figuring out a better API for gotoDefinition

* Remove old JIRA ticket numbers

* Add a hover handler in the new form

* Change the new handlers slightly

* Add a new module to handle notifications updating the virtual file system

* Rewrite the language server in hie-core to use the Handler more directly

* Add a cancel handler

* Ignore a few more handlers

* HLint

* REname functions that set handlers

* Rename a few more set handlers

* Delete the unused makeResponse

* Move mergeHandlers over to LanguageServer

* Rename RunHandler to WithMessage

* Switch from STM to IO

* Avoid the Protocol module

* Rename AddItem to Message

* Document why we use clientMsgChan

* Add comments around Message
2019-09-10 14:52:17 +02:00
Neil Mitchell
6f79fd1392 Delete unused deps (#1856)
* Delete unused package dependencies

* Eliminate the use of pretty

* Don't export some things that weren't necessary

* Add a missing dependency

* Avoid reexporting files of interest methods

* Put toIdeResult back
2019-09-10 14:52:17 +02:00
Neil Mitchell
f746db9dc4 Clean up the logging in hie-core (#1839)
* Move prettyPosition over to a more sensible place

* Avoid some pretty printing

* Remove duplicate methods and switch to having a function to get the logger handle

* Remove unncessary bits of the logger

* Remove reportSeriousErrorDie - was unused

* Rename the Logger methods to Logger rather than Handle

* Delete the unique supply

* Decrease the use of getServiceEnv

* Move getIdeOptions inside Service

* Add getFilesOfInterest rule

* Hide the existence of Env

* Inline some redundant forwarding methods

* Add a FIXME for a dodgy function

* Delete some redundant imports

* Rename Map to HMap, since I need to use Data.Map too

* Make the Shake-specific Diagnostics functions into that module

* Delete errorDiag which was unused

* Inline the diagnostic function, since it had one user

* Add ofInterest rule as a separate module

* Sort the exposed modules

* Fix up the demo

* Make sure you add the OfInterestVar global

* HLint

* Get rid of some of interest stuff in other places

* Remove the OfInterest stuff from Service
2019-09-10 14:52:17 +02:00
Neil Mitchell
f46fff9b0a Further cleanups to hie-core (#1819)
* Move the span related functionality to one place

* Fuse docHeaders away

* Decouple AtPoint from the rest of the rule database, simplifying the dependencies

* Move the import related functionality to one place

* Move all the closely tied to GHC modules together

* Rename the Logger module

* Push the other module renames through the code base

* Rename Development.IDE.State to Development.IDE.Core

* Rename Functions.Compile to Core.Compile

* Fix up some module names

* Cut down on non-sensicle exports

* Don't worry about setting source - no one uses it

* Reorder the module header

* Give more sensible names to the diagnostic creating functions

* Use more appropriate diagnostic functions

* Simplify the internal diagnostic creations

* Rewrite the diagnostics to go direct, not via GHC error types

* Remove redundant dflags from some functions

* Make sure the warning vs error distinction remains

* Remove unnecessary extensions
2019-09-10 14:52:17 +02:00
Neil Mitchell
6270442743 Clean up hie-core (#1815)
* Make atPoint generate either haskell or daml syntax, depending on options

* Get rid of data HoverText

* Move VirtualResource out from hie-core

* Rename hie-core to the right name

* Drop Types.LSP, merge it into LSP.Protocol

* Remove orphans that aren't actually used in our code

* Delete redundant newlines

* Add a defaultIdeOptions function

* Move ideTryIOException over to its one user

* Delete unused exports

* Delete the ProjectDiagnostic newtype - the type index was always Key

* Don't reexport position information from Diagnostic

* Delete the unused bits from Location

* Delete unused stuff from getSrcSpan

* Move URL stuff into Location from Diagnostic

* Remove unnecessary CPP

* Remove unnecessary extension

* Change from stage being polymorphic to being a Text

* Fix up the test suite too

* Push the cleanup to the edges

* More dependencies

* Patch up the tests now they need to find the type signature inside a ```daml block
2019-09-10 14:52:17 +02:00
Neil Mitchell
036e3d0002 Rename haskell-ide-core to hie-core (#1809)
* Rename haskell-ide-core as hie-core, after discussions with Alan Zimmerman and others

* Update the readme to just say how to install
2019-09-10 14:52:17 +02:00
DavidM-D
79d712397b Hic elisp (#1714)
* Added elisp to the readme

* Changed the flags for compatibility with HIE

* Change the default arguments to reflect hie compat
2019-06-18 14:10:52 +02:00
Neil Mitchell
210de4e46c Don't error on goto definition for another package (#1687) 2019-06-15 16:11:20 +02:00