Commit Graph

373 Commits

Author SHA1 Message Date
Alejandro Serrano
c122ebdc4f Trigger completion after dot (#313)
* Trigger completion after dot

* Fix stupid mistake in test
2020-01-10 10:05:44 +01:00
Alejandro Serrano
a0aa013e33 Better docs for completions (#288)
* Remove JSON instances for completions, since we are not implementing "resolve"

* Remove completion resolve data from tests

* Better docs

* Fix tests

* Fix for 8.4

* Turn Haddock markup into Markdown

* Add types to completion items

* Make it work on 8.8 and 8.4

* Revert "Remove completion resolve data from tests"

This reverts commit 625d710f11.

* Revert "Remove JSON instances for completions, since we are not implementing "resolve""

This reverts commit 12ff27dce7.

* Fix tests

* Require higher version of regex-pcre-builtin

* Replace Pandoc with direct conversion from Haddock to Markdown

* Show kinds of type constructors too

* A few fixed to Markdown conversion

* Check optNewColonConvention

* Fix build on 8.4 and 8.8

* More fixes for 8.4 and 8.8

* Check only the common part of the completion text

* Make icons consistent with Outline

* Test docs for completions

* Make constructors return the corresponding CompletionItem + tests for that behavior

* Make test work on 8.4
2020-01-09 09:44:32 +01:00
Jacek Generowicz
5f4384e8ef Tests for issue 310 (misleading hover on inner signature) (#311)
* Tests for issue 310 (misleading hover on inner signature)

The most important pair of tests here is the "inner signature" pair. The others
serve mainly to document, compare and contrast what is happening in related
situations.

In summary, hover and gotoDef

+ on inner signatures: give type and location information for the outer
  definition; this is misleading,

+ on outer signatures: give no information at all,

+ on inner definitions: give correct information for the inner definition,

+ on outer definitions: give correct information for the outer definition.

Should hover and gotoDef do anything at all for signatures? or is the current
behaviour for outer signatures (doing nothing at all) what we want?

* Require signature hover/gotoDef to point to first clause of definition

* Remove perhaps superfluous tests for definitions
2020-01-08 14:27:31 +01:00
Pepe Iborra
b7208a333f Smarter logic to remove redundant import bindings (#308)
* Smarter logic to remove redundant import bindings

The new code finds the spans to remove using the GHC parse tree, then manually
extends them to include commas/spaces.

Fixes #299

* Compatibility with GHC 8.4

* Improve comment

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* Use breakOnEnd in unqualify

This will handle A.foo as well as A.B.foo

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2020-01-08 12:01:59 +01:00
Pepe Iborra
db456b0e51 Add a new flag --shake-profiling DIR (#307)
The flag provides a way to enable Shake profiling reports without recompiling.
Debug output prints links to the Shake reports for convenience
2020-01-06 19:56:40 +01:00
Pepe Iborra
fd163cd8e9 Insert imports code action (#295)
*  #46 Code action to add suggested imports

* code action to fix constructor imports

* #46 Add test for (broken) constructor import
2020-01-06 09:37:53 +01:00
Pepe Iborra
f8e6ab171f Fix #247 (#292) 2020-01-06 09:17:22 +01:00
Alejandro Serrano
821c7f6ffa Remove JSON instances for unused completion code (#305)
* Remove JSON instances for completions, since we are not implementing "resolve"

* Remove completion resolve data from tests
2020-01-06 09:16:00 +01:00
Jinwoo Lee
8f50699d24 Collect CPP error logs into diagnostics. (#296)
* Collect CPP error logs into diagnostics.

Fixes https://github.com/digital-asset/ghcide/issues/87
2020-01-06 09:14:55 +01:00
Pepe Iborra
b78efe36bb Extend version message to include path and git commit (#306) 2020-01-06 09:13:14 +01:00
Moritz Kiefer
64693eddd8
Fix check for empty file path (#304)
I accidentally broke this on Windows in #303 by letting the two
conversirons get out of sync.
2020-01-04 01:25:31 +01:00
Moritz Kiefer
7e80629188
Fix performance regression introduced by filepath normalisation (#303)
We already normalise filepaths in NormalizedFilePath. haskell-lsp
changed things such that the conversion from Uri to NormalizedUri
normalises the filepath again which caused a significant slowdown in
GetFileExists.

We already have a wrapper for converting from NormalizedFilePath to
NormalizedUri so this PR changes this wrapper to inline the definition
without the additional layer of normalisation.

fixes #298
2020-01-03 16:01:12 +01:00
Neil Mitchell
2c96c9b87f Require hie-bios 0.3.2 or above (#286)
* Require hie-bios 0.3.2 or above

* Update stack.yaml files

* Use newer parser-combinators on GHC 8.4

* Bump parser combinators on 8.6

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-01-03 11:14:09 +01:00
Pepe Iborra
6bb1e4e05a jjk (#300) 2020-01-02 17:31:51 +01:00
Pepe Iborra
5ca06a1d24 Document symbols provider (#293)
* Document symbols provider

* Compatibility with GHC 8.4

* Replace large number with more descriptive maxBound

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* Use SkFunction for all Val Declarations

* Improve outlining of PatBind and FunBind

No longer relying on gfindtype

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2019-12-31 10:31:55 +01:00
Pepe Iborra
0bcdc6a226 Fix for #45 - remove redundant symbols from imports (#290)
* Test for #45

* Remove redundant symbols from imports

Fixes #45

* Update src/Development/IDE/LSP/CodeAction.hs

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* Add regex-tdfa extra deps to ghc-lib build

* Fix for GHC 8.4 (error message prints qualified binding)

GHC ticket #14881 changed this to print identifiers unqualified

* dropBindingsFromImportLine: make total

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2019-12-30 10:40:13 +01:00
Gabriele Lana
359cdf5b24 Swapped argument names (#289) 2019-12-23 10:48:38 +01:00
Nikos Baxevanis
31edb5b010 Add Sublime Text section on the README (#287) 2019-12-20 09:47:00 +01:00
Alejandro Serrano
b52ee607f9 [WIP] Completion support (#227)
* Initial implementation of completion support

* Add fuzzy to set of additional dependencies in 8.8

* Fix test

* Work a bit more on completion

* Attempt at getting completions from last good tckd module

* Revert "Attempt at getting completions from last good tckd module"

This reverts commit 04ca13b9d8.

* "useWithStale" everywhere

* Some suggestions by @cocreature

* Adjust positions in the document

* Start working on tests

* Fix compilation problem

* Fix tests

* Better type tests
2019-12-19 15:00:39 +01:00
Neil Mitchell
70cb92cc01 #279, support preprocessors (#282)
* Support preprocessors

* Add a preprocessor for testing

* Add a preprocessor test
2019-12-19 12:06:03 +01:00
Jacek Generowicz
b1435e2aee Tests for issue #283 (#284) 2019-12-19 10:29:53 +01:00
Neil Mitchell
d06894fd79 Make hie.yaml hie-bios-0.3 compatible (#280) 2019-12-18 23:02:40 +01:00
Neil Mitchell
81f78a403b Add Atom plugin link (#278)
* Add Atom plugin link

* Fix typo
2019-12-18 23:00:43 +01:00
Jacek Generowicz
acc8c6b609 Add tests for #274: literals in hover info (#276)
Tests for issue #274.
2019-12-18 14:48:15 +01:00
Jacek Generowicz
b9374aa346 Add tests for #237: kinds in hover info (#275) 2019-12-18 13:50:00 +01:00
Jacek Generowicz
bbb75c2f95 Fix #248 and #250 (#267)
* Fix #248 and #250

This fixes hover for types, classes and type variables.

Information about spans includes a `Maybe Type` which is `Just` for data-level
expressions and `Nothing` for type-level expressions.

`AtPoint.atPoint` which is the oddly-named function responsible for constructing
hover information, runs in the `Maybe` monad, and aborted at the first sight of
a `Nothing`, thus producing no hover information for type-level spans.

In the process of fixing this, I have refactored the function to

+ separate the construction of data-level and type-level hover info

+ make the components that make up the hover info (and their construction) more
  clear

I can see plenty little improvements that could be made to the functionality of
the code (and lots that could be made to its organization), but the most
important fixes of the basic missing functionality are here.

Fix #248
Fix #250

* Revert behaviour of locationsAtPoint to match its name

The name suggests that it returns all locations, while the last commit changed
this to return at most one.

* Fix issue numbers in test titles

There was some confusion about which tests addressed issue 248 vs 249
2019-12-18 11:47:51 +01:00
Moritz Kiefer
b2ad2eb361
Fix build with Shake 0.18.4 (#272)
Shake 0.18.4 started exporting Info from this module which clashes
with the one from haskell-lsp. Fixes #271
2019-12-18 11:24:54 +01:00
Jacek Generowicz
7e18f84f81 Refactor hover and go-to-definition searching (#260)
The process of searching for definitions is similar to the process of searching
for hover information. In the original code (much of which was written out twice
with occasional stylistic differences) the signal to noise ratio seemed pretty
poor.

Here is a refactoring which aims to make it easier to see the similarities and
differences between these two related functionalities.
2019-12-18 09:50:30 +01:00
Jacek Generowicz
6cf1d60d8a Test for issue #7 (#270) 2019-12-17 16:27:55 +01:00
Alejandro Serrano
1b1c58518d Filter out completely warnings not enabled by user (#263)
* Filter out completely warnings not enabled by user

* Suggestions by @cocreature

* Add tests

* Work more on tests

* Fix tests
2019-12-17 15:13:12 +01:00
Moritz Kiefer
e863912449
Normalise filepaths to match haskell-lsp 0.19 (#266)
haskell-lsp 0.19 has started to normalise file paths completely so we
need to make sure that NormalizedFilePath agrees with that, otherwise,
we get a bunch of test failures on the daml repo (they are not
specific to DAML, but atm ghcide CI does not run windows).
2019-12-17 10:59:45 +01:00
Alejandro Serrano
a698a6f1d0 Define "__GHCIDE__" on CPP (#264) 2019-12-17 08:10:37 +01:00
Alejandro Serrano
4440a26380 Enhancements to top-level signatures (#232)
* Try adding a dependency on TypeCheck

* Show warning regardless of the status of -Wall

* Try diagnostics after type checking, again

* Use `useE` instead of `use_` to not get a `BadDependency` error

* Degrade information about signatures if not present in user options

* Fix tests

* Better suggested signatures for polymorphic bindings

* Remove old comment
2019-12-16 16:21:09 +01:00
Moritz Kiefer
8ea5d69e18
Upgrade to haskell-lsp 0.19 (#254)
* Upgrade to haskell-lsp 0.19

* Clarify version handling
2019-12-16 14:57:38 +01:00
Moritz Kiefer
0838dcbbd1
Rename hDuplicateTo to hDuplicateTo' (#259)
We have some issues in GHCi on the DAML codebase where it complains
about:

<interactive>:28:1: error:
    Ambiguous occurrence `hDuplicateTo'
    It could refer to either `Development.IDE.GHC.Util.hDuplicateTo',
                             imported from `Development.IDE.GHC.Util' at compiler/damlc/daml-opts/daml-opts/DA/Daml/Options.hs:36:1-31
                          or `GHC.IO.Handle.hDuplicateTo', imported from `GHC.IO.Handle'

Given that this is only internal to ghcide anyway, we can just rename it.
2019-12-16 14:53:41 +01:00
Moritz Kiefer
fc30f1476f
Upgrade to hie-bios (#257)
This does not yet take advantage of any new features but we should at
least be able to benefit from bugfixes.
2019-12-16 11:42:44 +01:00
Jacek Generowicz
2523c21b75 Fix #246 (#252)
* Fix #246

`getTypeLHsBind` returned a single span corresponding to the overall function
binding. The fix drills down into the individual matches and returns a span for
each of them.

Fixes #246.

* Make it work on GHC 8.8

* Cosmetics
2019-12-16 10:25:18 +01:00
Jacek Generowicz
26ddbbf06f Annotate tests with issue numbers (#251) 2019-12-15 12:03:35 +01:00
Jacek Generowicz
fb66f870fb Add tests for #246 (#245)
Hover and goto definition only work on the function name in the first clause of
a function being defined with multiple equation clauses.

Here are some tests that document this.
2019-12-15 11:43:10 +01:00
Jacek Generowicz
87f449d2c5 Fix #237 (#243)
The bug was caused by broken transitivity of the comparison function used to
sort spans. Nested spans were meant to be sorted in innermost-first order, with
the first (innermost) one being used to get type information about the symbol at
a given position.

Because the comparison function considered any two non-nested spans to be EQ,
the sort could incorrectly conclude (by transitivity) that two nested spans were
equal, and thus leave them in incorrect relative order. This resulted in the
innermost span sometimes not appearing at the front of the list of spans which
enclose a given point, and hover reporting the type of a bigger expression in
which the point appeared.

The solution imposes ordering on non-nested spans by comparing their starting
positions, thus fixing transitivity.

Fixes #237 (... probably along with a bunch of other little bugs caused by the
same mistake).
2019-12-14 21:08:03 +01:00
Jacek Generowicz
069e8ee8c7 Cleaner Show instance for SpanInfo (#244)
* Cleaner Show instance for SpanInfo

This helped with debugging #237, so maybe it's worth keeping.

* Stylistic fixes
2019-12-14 21:02:23 +01:00
Neil Mitchell
cef3097b7f Update Setup.md (#241) 2019-12-14 20:59:04 +01:00
Jacek Generowicz
4e8178dbcc Tests for issue #237 (#238)
* Add tests for issue #237

* Tell hlint to ignore test sample code

* Add test showing similar problem in listcomps

* Identify implementation necessary for test to pass
2019-12-13 14:07:51 +01:00
Moritz Kiefer
9feb7c75fe
Prepare for ghcide 0.0.5 release (#236) 2019-12-12 20:04:34 +01:00
Moritz Kiefer
b5b80d91f9
Workaround hDuplicateTo issues (#235)
We have seen a bunch of failures on CI where this failed with
EBUSY. I find the hDuplicateTo here to be quite useful for debugging
since you don’t have to worry about corrupting the JSON-RPC stream to
instead of getting rid of it, we add a somewhat ugly workaround.

There is an explanation in an inline comment on why this helps but
admittedly I am somewhat guessing since I don’t understand what is
actually allocating the file descriptor that turns out to be
stdout. That said, I am not guessing on the results: Without this PR I
am able to make this fail in roughly 50% of the cases on CI whereas
with this PR, I’ve now run it 60 times on CI without a single failure.
2019-12-12 16:44:45 +01:00
Jinwoo Lee
fa2c295f74 Indicate failures with exit code in command-line mode. (#233)
It'd be useful for scripting or integration tests.
2019-12-12 09:00:49 +01:00
Neil Mitchell
9d1f2baff8 Don't repeatedly update the progress (#230) 2019-12-12 09:00:16 +01:00
Alejandro Serrano
481ca019a3 Support TemplateHaskell (#222)
* First attempt at TH support

* Update TcModuleResult when generating core

* Be a bit more cautious when asking for bytecode

* Check need for bytecode not only in source file itself, also in global information

* Add a test (based on #212)

* Fix test (thanks, @jinwoo)

* Split GenerateCore and GenerateByteCode
2019-12-10 13:16:25 +01:00
Alejandro Serrano
7f3b0f6dba Code lens for missing signatures (#224)
* Code lens for missing signatures

* Fix tests

* Implement suggestions by @cocreature
2019-12-09 16:32:10 +01:00
Pepe Iborra
5091a1d202 Fix horrible path normalisation issue (#225) 2019-12-08 17:07:15 +01:00