Commit Graph

712 Commits

Author SHA1 Message Date
Pepe Iborra
3ef4ef99c4
Prepare for archiving the Github project (#965) 2020-12-30 18:07:58 +00:00
Guru Devanla
36c182cbc4
Strip prefixes from labels (#960)
* Strip prefixes from labels

* Remove redundant parens
2020-12-27 10:03:42 +00:00
Pepe Iborra
c617c9bd73
Prepare release 0.6.0.2 (#958)
* Disable auto-extend of module imports

* Prepare for v0.6.0.2 release
2020-12-26 19:40:33 +00:00
Pepe Iborra
0d4e3b9499
Fix diagnostics update bug (#959)
* Preventively switch to uninterruptible mask in withMVar'

withMVar' is used to update the shakeSession var and it's crucial that the
third argument is not interrupted.

'mask' can still be interrupted for I/O actions and, while we were careful to
ensure none was used, if it ever breaks it will lead to very hard to debug
problems.

* refactor: move to RuleTypes

* Add a TestRequest to wait for arbitrary ide actions

Closes #955

* expectCurrentDiagnostics

* Add a test suite for cancellation

* Introduce --test-no-kick to fix cancellation tests reliability

* delete unsafeClearDiagnostics (unused)

* GetModSummaryWithoutTimestamps - remove StringBuffer

Since the contents of the buffer are not tracked by the fingerprint.

* Fix diagnostics bug

Given a FOI F with non null typechecking diagnostics D, imagine the following scenario:

1. An edit notification for F is received, creating a new version
2. GetModTime is executed, producing 0 diagnostics.
  2.1 updateFileDiagnostics is called
  2.2 setStageDiagnostics is called
  2.3 LSP.updateDiagnostics is called with a new version, resetting all the
  diagnostics for F
  2.4 newDiags=[] in updateFileDiagnostics, which is different from D (the last
  published diagnostics), which enqueues a new publishDiagnostics [] in the
  Debouncer
3. An edit notification for F is received before typechecking has a chance to
run which undoes the previous edit
4. The debouncer publishes the empty set of diagnostics after waiting 0.1s
5. GetFileContents runs and since the contents of the file haven't changed since
the last time it ran, early cutoff skips everything donwstream

Since TypeCheck is skipped, the empty set of diagnostics stays published until
another edit comes.

The goal of this change is to prevent setStageDiagnostics from losing
diagnostics from other stages. To achieve this, we recover the old diagnostics
for all stages and merge them with the new stage.

* Fix hlint

* Use Map.insert for clarity

* Fix redundant imports

* Fix "code actions after edit" experiment"
2020-12-21 06:06:51 +00:00
Potato Hatsue
22d9fde844
Use qualified module name from diagnostics in suggestNewImport (#945)
* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Remove unused renderImport

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2020-12-15 17:10:21 +00:00
Pepe Iborra
d8244b7917
Rescue stack windows build (#954)
* Revert "Drop stack Windows CI"

This reverts commit 919d3bce57.

* Fix stack Windows build

I finally figured this puzzle out
2020-12-15 17:09:59 +00:00
Guru Devanla
d702ca9404
Expose Documentation module (#956)
In an effort to move Completions into its own hls-plugin package we have a dependency to access the getDocumentation function exposed in this module. Therefore, can we expose this module so that we will be able to access that function.
2020-12-15 17:09:33 +00:00
Potato Hatsue
9e976f1426
Rename hie.yaml.* to hie-*.yaml (#953) 2020-12-15 07:22:26 +01:00
Pepe Iborra
6365d3cc61
Deduplicate module not found diagnostics (#952)
* Trace rule errors

* Disable check parents in command line script

* Fix expectDiagnostics []

* Add a test

* remove uses of stale info within rules

The use of stale information should be limited to the leaves of the processing
tree, otherwise it becomes impossible to reason about the semantics of diagnostics

* Use stale info in the NeedsCompilation rule

* Use stale data in GetDocMap

* Fix tests that relied on unsupported behaviour of expectDiagnostics
2020-12-14 13:37:19 +00:00
Guru Devanla
cd0878bd6f
Remove language extension completions. (#948)
* Remove language extension completions.

* Remove code actions for language pragma extensions.

* Remove unused defintions and imports

* Remove test defintion use

* Update comment describing why we return an empty list
2020-12-13 16:51:57 +00:00
Pepe Iborra
3ae1b20962
Prepare for v0.6.0.1 release (#951) 2020-12-13 11:25:11 +00:00
Jan Hrcek
9d0fc445a4
Update URLs after move to haskell github org (#950) 2020-12-13 07:56:38 +00:00
Javier Neira
27b4250bb2
Extend CI with all GHC minor versions supported by hls and fix ghc-8.8.3 and ghc-8.8.2 builds (#947)
* Extend CI matrix with all the GHC minor versions supported by HLS
  * Adding a new job for windows: ghc-8.10.2.2

* Use GADTs for all ghc versions in Development.IDE.Plugin.Completions.Logic 
  * Fix ghc-8.8.2 and ghc-8.8.3 builds

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2020-12-11 12:23:16 +01:00
Pepe Iborra
baafe2cb82
Prepare for v0.6.0 release (#940)
* Prepare for v0.6.0 release

* Credit @mpardalos for the opentelemetry work
2020-12-09 08:35:09 +00:00
Pepe Iborra
92db8207e2
Deprecate ghcide tool and delete the VSCode extension (#939)
* Delete the extension and deprecate ghcide as an end user tool

* Link to this PR
2020-12-08 21:33:07 +00:00
Pepe Iborra
65c95801c9
Add support for customizing the hidir location (#944) 2020-12-08 19:18:22 +00:00
Potato Hatsue
6ec0b991e8
Cleanup addBindingToImportList (#942)
* Cleanup addBindingToImportList

* Remove redundant $

* Fix missing leading identifiers

* Simplify

* Wait package exports map in tests

* Don't show code action if we can't handle this case

* Remove redundant parens

Co-authored-by: Pepe Iborra <pepeiborra@me.com>
2020-12-08 14:43:27 +00:00
Pepe Iborra
959db7b10b
Extract the benchmarking Shake rules to a standalone Cabal package (#941)
* [bench-hist] break down in rule functions

* Extract the benchmarking Shake rules to a shake-bench package

There's some room for reusing the rules used in the historic benchmarking suite
in other projects. This change makes that a bit easier and improves the
documentation and code structure.

The new structure is:
- lib:shake-bench - a Cabal library with functions to generate Shake rules
- ghcide:bench:benchHist - the ghcide instantiation of the above Shake rules

That's not to say that shake-bench is completely decoupled from ghcide -
there are still plenty of assumptions on how the benchmarks are organized, their
outputs, etc. But with a little bit of effort, it should be easy to make
these rules more reusable

* Fix nix build

* Fix license

* hlints and redundant imports

* more hlints

* Exclude shake-bench from the stack build
2020-12-07 15:03:15 +00:00
Potato Hatsue
eff14cb1ab
Support extending constructors (#916)
* Use exports map

* Use exports map in suggestExtendImport

* Update test

* Support extend constructor

* Revert format changes

* Support extending constructors

* Fix multi line
2020-12-06 14:39:15 +00:00
Pepe Iborra
bd5b9d02ec
Qualified error messages (#938)
* Add a test for #726

* Add a test for #652

* Fix missing qualifiers in code actions
2020-12-06 14:18:47 +00:00
Pepe Iborra
e24a744a06
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module

* Bump opentelemetry to 0.6.0

* Write Values map size to OpenTelemetry metric

* Trace all requests and notifications

Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.

* Add flag for OpenTelemetry profiling

Run GC regularly with --ot-profiling

* Add flag to enable OT profiling in benchmark

* Use heapsize instead of ghc-datasize

I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.

* Bump opentelemetry to 0.6.1 - fixes 8.6 build

* Use heapsize from hackage

* Address HLint messages

* Record size of each key independently

* Refactor `startTelemetry` function

* Remove delay between measuring memory loops

* Each key in values map gets own OT instrument

* Measure values map length more rarely

* Rename --ot-profiling to --ot-memory-profiling

* Add docs for how to use the opentelemetry output

* Add instructions to build release version of tracy

* Clarify dependencies in opentelemetry instructions

* Fix LSP traces

* otTraced: delete unused

* Extract types out of D.IDE.Core.Shake

to avoid circular module dependencies

* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2

No more segfaults

* [nix] install opentelemetry

* [nix] install tracy

* Fix merge wibble

* Measure recursive sizes with sharing

* Sort keys for cost attribution

* Remove debug traces

* Allocate less, group keys, clean up hlints

* Add -A4G to the flags used for --ot-memory-profiling

* Modularize D.IDE.Core.Tracing

I want to reuse this code more directly in the non lsp driver

* Direct driver: report closure sizes when --ot-memory-profiling

An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to

* Everything is reachable from GhcSessionIO, so compute it last

I suspect the ShakeExtras record is reachable from GhcSessionIO

* bound recursion and use logger

* hlint suggestions

* Fix 8.6 build

* Format imports

* Do the memory analysis with full sharing. GhcSessionIO last

* Fail fast in the memory analysis

* error handling

* runHeapsize now takes initSize as an input argument

* Trace Shake sessions

* Reduced frequency for sampling values length

* Drop the -fexternal-interpreter flag in the Windows stack build

* Produce more benchmark artifacts

* Fix stack descriptors to use heapsize-0.2 from Hackage

* Bump to heapsize-0.3.0

* Record completions snippets (#900)

* Add field for RecordSnippets to CachcedCompletion

* Initial version of local record snippets

* Supprt record snippet completion for non local declarations.

* Better integration of local completions with current implementation

* Clean up non-local completions.

* Remove commented code.

* Switch from String to Text

* Remove ununsed definition

* Treat only Records and leave other defintions as is.

* Differentiate Records from Data constructors for external declaration

* Update test to include snippet in local record completions expected list.

* Update completionTest to also compare insertText.

* Add test for record snippet completion for imported records.

* Hlint fixes

* Hlint fixes

* Hlint suggestions.

* Update type.

* Consolidate imports

* Unpack tuple with explicit names

* Idiomatic changes

* Remove unused variable

* Better variable name

* Hlint suggestions

* Handle exhaustive pattern warning

* Add _ to snippet field name suggestions

* Remove type information passed around but not used

* Update to list comprehension style

* Eliminate intermediate function

* HLint suggestions.

* Idiomatic list comprehension

Co-authored-by: Pepe Iborra <pepeiborra@me.com>

* [nix] use gitignore.nix (#920)

* Ignore import list while producing completions (#919)

* Drop any items in explicit import list

* Test if imports not included in explicit list show up in completions

* Update README.md (#924)

* Custom cradle loading (#928)

When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether

* Favor `lookupPathToId` over `pathToId` (#926)

* Favor `lookupPathToId` over `pathToId`

* Fix `typecheckParentsAction`

* Fix `needsCompilationRule`

* Return completion snippets only when client supports it (#929)

* Use the real client capabilities on completions

* Return completion snippets only when supported by the client

Restored from https://github.com/haskell/ghcide/pull/900

* Redundant import

* Fix stack windows build

Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 17:44:17 +00:00
Pepe Iborra
28f33ccb1a
Drop stack Windows CI (#934)
The Stack Windows build is problematic:
  https://github.com/haskell/ghcide/pull/922

Stack is already covered by the Azure CI
Windows is already covered by the Github Actions CI
2020-12-05 08:29:51 +00:00
Guru Devanla
36a2f0027e
Extend import list automatically (#930)
* Drop any items in explicit import list

* Test if imports not included in explicit list show up in completions

* Update CompItem to hold additionalTextEdit

* Add placeholder value for additionalTextEdit field

* Improvement completion tests.

* Use explicit fields while constructing CompletionItem

* Add function that will extend an import list

* Use externalImports to extend import list

* Make import list information available

* First working prototype of extending import list.

* Pass the original importDecl to cacheDataProducer

* Add tests for completions with addtional text edits

* Hlinting

* Refine function name and signature

* Pass the original importDecl to cacheDataProducer

* Refactor code to use gaurds

* Exhaust patterns

* Handle empty import list

* Use correct pattern

* Update expected values in TextEdit

* Add test adding imports to empty list

* Remove old code

* Handle names with underscore

* Exhaust patterns

* Improve storing of import map

* Add trailing comma to import list completions.

* Add support for Record snippets

* Add 8.8.4 support

* Code cleanup.
2020-12-05 07:26:11 +00:00
Avi Dessauer
42901e39f7
Simplify and Bump implicit-hie version constraints (#933) 2020-12-04 18:10:16 +01:00
Pepe Iborra
dc3c104f37
Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions

* Return completion snippets only when supported by the client

Restored from https://github.com/haskell/ghcide/pull/900
2020-11-29 19:03:09 +00:00
Samuel Ainsworth
54f17d1d52
Favor lookupPathToId over pathToId (#926)
* Favor `lookupPathToId` over `pathToId`

* Fix `typecheckParentsAction`

* Fix `needsCompilationRule`
2020-11-29 16:35:47 +00:00
Pepe Iborra
89eeb50034
Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
2020-11-29 13:52:52 +00:00
Samuel Ainsworth
51f70d410a
Update README.md (#924) 2020-11-28 16:21:02 +00:00
Guru Devanla
d79fdba39c
Ignore import list while producing completions (#919)
* Drop any items in explicit import list

* Test if imports not included in explicit list show up in completions
2020-11-27 23:24:21 +00:00
Pepe Iborra
c4418abdc1
[nix] use gitignore.nix (#920) 2020-11-23 16:49:49 +00:00
Guru Devanla
02899170c6
Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion

* Initial version of local record snippets

* Supprt record snippet completion for non local declarations.

* Better integration of local completions with current implementation

* Clean up non-local completions.

* Remove commented code.

* Switch from String to Text

* Remove ununsed definition

* Treat only Records and leave other defintions as is.

* Differentiate Records from Data constructors for external declaration

* Update test to include snippet in local record completions expected list.

* Update completionTest to also compare insertText.

* Add test for record snippet completion for imported records.

* Hlint fixes

* Hlint fixes

* Hlint suggestions.

* Update type.

* Consolidate imports

* Unpack tuple with explicit names

* Idiomatic changes

* Remove unused variable

* Better variable name

* Hlint suggestions

* Handle exhaustive pattern warning

* Add _ to snippet field name suggestions

* Remove type information passed around but not used

* Update to list comprehension style

* Eliminate intermediate function

* HLint suggestions.

* Idiomatic list comprehension

Co-authored-by: Pepe Iborra <pepeiborra@me.com>
2020-11-23 13:24:34 +00:00
Pepe Iborra
90b859b202
Add a GitHub action for the Nix build (#918)
* Add an action to build and cache the nix-shell

* [nix] ghc-paths must always be in the package set

Otherwise ghc-check will not get the Nix libdir and fail at compile time

* [nix] extract the nixpkgs instantiation to nix/default.nix

* [nix] niv init

* [nix] switch to haskell-updates

* Mention the Cachix binary cache in the README

* [nix] pin the version used to set up Cachix

* [nix] disable tests and jailbreak 8.10.x packages

* [nix] rely on cabal2nix to enumerate the dependencies

* [nix] install haskell tools from the Nix cache
2020-11-23 09:38:15 +00:00
Guru Devanla
863392b9b9
Extend import suggestions for more than one option (#913)
* Add support for extending import list when multiple options are available

* Add function to module export list to make it available for testing

* Fix typo

* Add doc strings

* Add tests for testing regex used to parse multiple choices for import suggestions.

* Add test group

* Remove trailing spaces

* Hlint suggestions

* Remove not used variable

* Remove temporary code

* Reuse matchRegExUnifySpaces

* Fix test input.

* Use testCase instead of testSession

* Update extend import tests to assert on multiple actions.

* Extend extendImports to use multiple modules for setup

* Hlint changes
2020-11-21 21:17:03 +00:00
fendor
b11d0106a3
Make Filetargets absolute before continue using them (#914)
* Add testcase for proving relative filetargets

* Normalise file targets after loading
2020-11-21 10:11:13 +01:00
Pepe Iborra
7d908488d1
Switch to sliding tags in Github actions (#915)
* Switch to sliding tags in Github actions

* Allow insecure actions should no longer be needed

https://github.com/actions/setup-haskell/issues/44
2020-11-19 11:06:55 +01:00
Javier Neira
3d6d0d3713
Bump up implicit-hie-cradle lower bound (#912)
* Bump up implicit-hie-cradle lower bound

* Allow insecure commands temporary
2020-11-18 20:45:40 +00:00
Alejandro Serrano
b3e95d17cb
Do not enable every "unnecessary" warning by default (#907)
* Do not enable every "unnecessary" warning by default

* Fix tests that wait for diagnostics
2020-11-17 21:16:09 +00:00
Javier Neira
a345e11aa3
Remove allow-newer (#908) 2020-11-16 22:50:33 +01:00
Pepe Iborra
03e89d9b47
GitHub test action (#903)
* Add github test action

* Disable unreliable test

Does not work reliably on all platforms.

Reenable when #861 lands

* Add hlint and -Werror

* Explicit timeout

6h is the default and also the maximum:

https://docs.github.com/en/free-pro-team@latest/actions/reference/usage-limits-billing-and-administration

* Experiment tests to use Cabal instead of Stack

* Fix an unreliable test

* Trim down matrix

* Add ghc-lib to the test matrix

* Address broken hie-compat ghc-lib build

* Drop stack descriptor family

We keep two stack descriptors:

- One for Nightly
- One for Windows (stuck in GHC 8.10.1)

To ensure that `stack test` doesn't break, we keep running the stack tests in CI

* Update README to point end users to HLS

* Drop support for `stack test`
2020-11-15 23:08:17 +00:00
Potato Hatsue
a791afdea1
Parenthesize operators when exporting (#906)
* Parenthesize operators when exporting

* Add tests

* Only consider if the head is an operator letter
2020-11-13 20:05:43 +00:00
Pepe Iborra
30a46e8a18
Avoid calling kick explicitly (#904)
* Avoid calling kick explicitly

Leverages that rules are rerun by shakeRunDatabase.
Allows users of ghcide as a library to use their own kick

* Tweak doc comment
2020-11-12 19:18:21 +00:00
Avi Dessauer
9b8aaf9b06
Update implicit-hie to 0.3.0 (#905) 2020-11-12 07:55:59 +01:00
Pepe Iborra
c206840573
Test fixes (#899)
* Fix plugin tests for 'cabal test'

* Check for Haddocks on Int instead of Text

The text package may have been installed without documentation, in which case
the test will fail. base is always installed with documentation

* Fix test in Mac OS

* Ignore plugin tests in GHC 8.10.1
2020-11-10 11:25:36 +00:00
Pepe Iborra
dcf6804027
Prepare for 0.5.0 release (#896)
The changelog is a trimmed down summary of the git log.
I have removed several non-user visible changes while making sure that
everyone who contributed is listed at least once.
2020-11-07 19:58:13 +00:00
Pepe Iborra
1e17ed9b77
GitHub actions (#895)
* Add Github action for benchmarks

* Change action name to benchmark

* Fix - remove empty env section

* Rename step

* Add steps to print and upload results

* Shrink the matrix of versions for benchmarking

* Enable benchmarks

* rename job

* Fix fetch

* bump actions/setup-haskell

* disable windows - bench script requires Cairo

* Delete Azure bench script

* add comment on git fetch call

* clean up cache key

* Update archive step
2020-11-07 19:57:50 +00:00
Pepe Iborra
f4bfe9c103
Compatibility with fbghc (#892)
* Compatibility with fbghc

Rather than forking ghcide, we use conditional compilation to build with https://github.com/facebook/fbghc hopefully only until certain changes have been upstreamed.

* Reexport DynFlags from Compat.GHC

* Add a link to the fbghc repo
2020-11-07 15:13:40 +00:00
Javier Neira
00614465fa
Expose Development.IDE.GHC.Orphans (#894) 2020-11-07 13:01:35 +00:00
Pepe Iborra
c92ccfed6f
Disable CI benchmark suite (#893)
* Test the stack version in the benchmark CI script

* [bench script] specify cwd in findGhc

* Disable CI bench script
2020-11-07 11:35:18 +00:00
Pasqualino 'Titto' Assini
e922a16234
Expose Development.IDE.Core.Preprocessor (#887) 2020-10-29 01:46:09 +05:30
wz1000
933c0c9ea7
Simplify and deduplicate ModSummary logic (#884)
* Simplify and dedup parsing logic

* delete removePackageImports

* add dependencies on included files

* hlint
2020-10-27 14:53:08 +05:30