* Fix source spans for multi-clause definitions
Currently, we use the source span of the match which corresponds to
the whole clause instead of just the function identifier. This
resulted in us pointing every goto definition request within a clause
to the function if there is no other information (either because it
failed because it came from an external package or simply because you
are not on an identifier).
This PR fixes this by getting the proper source spans frmo the
HsMatchContext. Somewhat annoyingly, we have to get it from the parsed
module since GHC messes this up during typechecking but it’s
reasonably simple.
* 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
* 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
* 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>
* 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>
* 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>
* 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
* 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#248Fix#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
* 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
* 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
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.
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).
* 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
* 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
* 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
+ 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 | ❌ | ❌ |
* 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
* 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
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.
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.
+ 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.
* 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
* 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
* 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
* 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
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'.