* Upgrade haskell-lsp and lsp-test
There have been some fixes upstream that should hopefully mean that we
no longer need to mark the lsp-tests as flaky on Windows. I am having
trouble reproducing the flakiness locally, so let’s see what happens
on CI.
* Also bump stack.yaml
Comparing FilePaths is really slow so by mapping them to Ints, we can
speed up dependency chasing significantly.
We might want to switch to doing some kind of global hash consing of
file paths at the Shake level but for now, this seems like a nice
improvement while not being too invasive.
This is roughly an ~8s speedup on my testcase.
This PR moves as much work as possible to GetLocatedImports which
contracry to GetDependencyInformation is shared between rules.
It’s still slower than it should be and somewhat messy but at least
it’s slightly faster and imho cleaner than before.
* Make --shake-profiling use the directory based profiling
The single-file based profiling is rather useless in the IDE and I
always found myself having to modify the source to set `profileDir` so
this PR switches the CLI option to control that instead.
* Add --shake-profiling to damlc ide
This is in preparation for #2326 as well as for splitting hie-core
into a separate repo. Given that, it explicitely avoids using our
dev-env.
We do need to install a few system packages, so for now this uses the
hosted builder so we can do this. Another option would be to just add
those to our builders. I don’t really have a preference either
way. The builds are < 5 minutes so I don’t expect issues from using
the hosted builders.
Speed up file modification checks
Summary: `getModificationTime` from the `directory` package is really
slow. The `unix` package is faster but still slow. This PR brings the
time spent checking file modifications (which is required on every
change) from ~0.5s to ~0.15s.
* language: a shake rule to get interface/hie files
This adds a shake rule to get module interfaces and hie files. This
gives more control on when to build them and also an opportunity to
change the package name after typechecking. This is used in the next
PR to add package hashes to the package name in the interface files.
* generate hie files only on demand
* Improve debugging output
Displaying the exception makes it easier to figure out what is going
wrong.
I’ve also added a HasCallStack constraint to `locateRunfiles` since it
looked like that was failing. Turned out to be a call to `create` that
didn’t go via `locateRunfiles` but I think it’s useful either way.
Should be more useful with https://github.com/tweag/rules_haskell/pull/1007
* Update compiler/hie-core/src/Development/IDE/Core/Shake.hs
Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
* Upgrade ghc-lib
* Patch bazel_tools : hazel-include-paths patch, no-isystem patch.
* Provide "haskell_c2hs" for package name to cabal_haskell_package
* Package name haskell_c2hs => c2hs.
* Switch to less hacky patch for include dirs
* Support depending on potentially stale values in damlc
For now, this is opt-in and only enabled for the scenario service.
Locations should be properly mapped so if lines are inserted above a
scenario, the scenario link will move down.
* 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
This is a refactoring-only PR in preparation for supporting stale
values in damlc so we can still produce some results if a rule fails
to produce a value but has a stale value stored.
Some `Development.IDE.*` modules were imported qualified as either `Compile`
or `CompilerService`. These names are at least odd and maybe also
misleading. Since there's no actual need to import them qualified, let's
just import them not qualified.
There is lots of room for improvements here but I think this is a good
first step. The 3 main things that could be improved imho are:
- Rewrite source locations to point to the original file rather than
the generated module
- Provide some way to declare things like imports or more general,
setup code that is added to the generated module.
- Prettier/more helpful output during a run, e.g., print the list of
successful tests.
For now, we only show a “Progressing” message and a done/todo
indicator. We could eventually try to come up with something better
but I’m not quite sure what that would be since we try a lot of things
in parallel and the triggering request isn’t particularly
useful (users won’t know what a codelens request is and why they have
to wait for it).
Note that VSCode seems to have some delay in updating these
notifications so you only see the done/todo reports if it is
processing for a while.
Most of them were caused by off-by-one errors in goto definition.
There was also one test that was marked as an expected failure but the
actual bug has been fixed for some time and the only reason it was
failing is that the error message was different than the test
expected.
I’ve also renamed daml-ghc-shake-test-ci to damlc-shake-tests which is
something that I might actually be able to remember :)
Previously, we only checked two diagnostics messages. However, the
second diagnostics messages does not actually need to correspond to
the latest change but can just be a message that has been in the queue
from one of the 1000 changes before. Now we make sure to actually
check all (or at least every second) diagnostic.
This was technically also an issue before but since we only emitted
diagnostics when they changed and we alternate between two states it
worked fine. The way we implement debouncing means that we can now
also end up emitting two consecutive diagnostics changes for the same
set of diagnostics which made this test flaky.
Previously, we emitted diagnostics notifications as soon as we got
them. This resulted in a lot of flickering due to diagnostics getting
cleared briefly when typing only to immediately reappear.
Now, we buffer them for 0.1s so that a new event restoring the
same diagnostics for a slightly modified file will overwrite the
initial clear of diagnostics for the new document version.
* Split off addRelativeImport from modifying the session
* Switch located imports to adding their own relative imports
* Delete the unused getGhcDynFlags
* Make runGhcEnv no longer need to consult import paths
* Call runGhcEnv directly
* Move getSrcSpanInfos out to Spans
* Remove a redundant import
* Make findImports in Either rather than ExceptT
* Move getImports over to the right place
* Switch to liftEither
* Get rid of orphan usage in Convert
* Get rid of orphan usage in AtPoint
* Delete one entirely unused orphan
* Remove a comment that is no longer true
* Add a .gitignore just for the hie-core piece
* Add standalone pieces to make hie-core work with a global Cabal install
* Add more things to .gitignore, PR suggestion
* Add copyright header
* Fix running the IDE on damlc
There were two issues:
1. Missing include paths.
2. Files where the module name does not match the file name.
I’ve fixed both and added a test that we can load the damlc Main.hs.
* Push the suggestion work further up
* Make LspFuncs an argument to the handlers
* Actually pass around the contents of the buffer to suggestAction
* Make suggestAction do sensible figuring out if you remove the next line too
* Better indentation
* Code action to add GHC extensions as required
* Deal with extra arguments to LSP handler
* Add a code action
* Update comments
* Remove logging, since its too verbose
* Fix a few warnings, add a final case
* Add an example of what the code action matches
* Add more comments to shakeRun
* Delete the multiple versions of runActions, since they weren't used and parallel is good enough
* Delete runActionsSync entirely
* Make sure runAction returns even if shakeRun throws an exception
* Remove the callback from shakeRun - it was never used
* Fix one last use
* More comments