Commit Graph

142 Commits

Author SHA1 Message Date
Moritz Kiefer
fbe192a7a3 Add a Stack based pipeline for testing hie-core (#2348)
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.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
01d84a6057 Speed up file modification checks (#2317)
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.
2019-09-10 14:52:17 +02:00
Robin Krom
3e163354cd language: a shake rule to get interface/hie files (#2291)
* 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
2019-09-10 14:52:17 +02:00
Andreas Herrmann
5643bff2c6 Fix hanging hie-core tests with stack (#2293) 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
Moritz Kiefer
8ab246bcdb Improve debugging output (#2281)
* 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>
2019-09-10 14:52:17 +02:00
Shayne Fletcher
e41f17c969 Ghc lib 8.8.0.20190723 (#2279)
* 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
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
Moritz Kiefer
904ab6d6fa Add property tests for PositionMapping (#2265) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
61c37a93b3 Support depending on potentially stale values in damlc (#2257)
* 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.
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
Moritz Kiefer
2b61d2c17c Use a custom Value type instead of Maybe for storing rule results (#2237)
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.
2019-09-10 14:52:17 +02:00
Martin Huschenbett
b2380eac70 Import the IDE modules unqualified instead of as Compile(rService) (#2227)
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.
2019-09-10 14:52:17 +02:00
Martin Huschenbett
2a7aaa9b5f Drop two useless occurences of 'import ... as Base' (#2216)
They don't serve any purpose and are just noise.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
3c64f5564e Add a damlc doctest command and test the standard library (#2157)
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.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
2d637aa488 Add useNoFile helpers matching defineNoFile (#2126) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
edaeac7a32 Report progress in VSCode (#2112)
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.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
eed26cda09 Turn the damlc module hierarchy into something a bit more sane (#2061)
This should hopefully be the last large reshuffling PR. I’ll write a
description of the new layout in the readme in a separate PR.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
906e5f85b1 Fix VSCode extension and remove silly warnings (#2042) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
0743b0e47c Move code in daml-tools outside of daml-foundations (#2033) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
1a7d83c7e8 Expose TcModuleResult in RuleTypes (#2014)
This should really be part of the public API.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
5beb77cdb0 Fix some expected failures in damlc-shake-tests (#2010)
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 :)
2019-09-10 14:52:17 +02:00
Moritz Kiefer
1fee8b0890 Fix flaky LSP stress tests (#2004)
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.
2019-09-10 14:52:17 +02:00
Shayne Fletcher
5e3fcffe1a Add Development.IDE.Core.Debouncer to library other-modules (#1998) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
d61807c240 Implement debouncing of diagnostics (#1991)
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.
2019-09-10 14:52:17 +02:00
Neil Mitchell
ddb7bd31d3 Clean up hie-core (#1992)
* 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
2019-09-10 14:52:17 +02:00
Neil Mitchell
5ebce24189 Make Haddock work for hie-core (#1990) 2019-09-10 14:52:17 +02:00
Neil Mitchell
44b40b5086 Hide some hie-core modules (#1987)
* Hide some hie-core modules

* Make bazelifier happy
2019-09-10 14:52:17 +02:00
Neil Mitchell
9308740773 Fewer orphan instances in hie-core (#1984)
* 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
2019-09-10 14:52:17 +02:00
Neil Mitchell
4a9010ba10 Standalone pieces for hie-core (#1982)
* 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
2019-09-10 14:52:17 +02:00
Moritz Kiefer
2bbde912c5 Make Priority in hie-core independent of DAML (#1983) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
2ba7d08ed6 Cleanup moduleImportPaths now that file paths are normalized (#1980) 2019-09-10 14:52:17 +02:00
Moritz Kiefer
27f547fd94 Fix running the IDE on damlc (#1956)
* 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.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
c1efd35bd0 Combine all artifacts output by damlc in .daml (#1959)
Fixes #1241
2019-09-10 14:52:17 +02:00
Moritz Kiefer
66d5bf17d8 Implement LSP request cancellation (#1954)
* Implement LSP request cancellation
2019-09-10 14:52:17 +02:00
Neil Mitchell
42221e66d5 More code actions for hie-core (#1948)
* 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
2019-09-10 14:52:17 +02:00
Andreas Herrmann
ff492c37b3 Mask async exceptions in updateFileDiagnostics (#1944)
* Mask async exceptions in updateFileDiagnostics

* lsp-tests remove flaky flag
2019-09-10 14:52:17 +02:00
Shayne Fletcher
205cce9b63 Make the README a little prettier (#1949)
* Make the README a little prettier

* Remove vscode.png

* Image float right

* Go back to regular title; scale image 75%
2019-09-10 14:52:17 +02:00
Neil Mitchell
9a45c0d17e Add "Remove import" code action (#1945)
* 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
2019-09-10 14:52:17 +02:00
Neil Mitchell
eddf78a798 Fix hie.cabal (#1943)
* I put safe-exceptions in the executable, not the library

* Sort all the lines in the .cabal file
2019-09-10 14:52:17 +02:00
Neil Mitchell
04576f086d Avoid non-termination in runAction (#1938)
* 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
2019-09-10 14:52:17 +02:00
Neil Mitchell
16873edb44 hie-core Logging and exceptions (#1933)
* Rename reportSeriousError to reportInternalError

* Stop using logError for logging things that are warnings to the user, not errors by us

* Rename logError

* Sort the log fields properly

* Delete tagAction from Logger

* Strip down the pure logger

* Delete unused pieces of the logger

* A quick check suggests the call stack will be useful in approximately none of the callers of logging, so just remove it

* When reporting an internal error, give as much detail as we can

* Change our logger to be based on Priority values

* HLint fixes

* Rename makeNopLogger

* In hie-core say what level of message you are setting

* Delete the unused makeOneLogger

* Make sure we can show messages floating around

* If a notification/response handler throws an exception, report it upwards

* Remove reportInternalError in favour of a general logging mechanism

* Add missing dependencies

* Just call fail for a dodgy error report

* Add a FIXME

* Make missing modules just an error
2019-09-10 14:52:17 +02:00
Neil Mitchell
f70eece4c7 Make CPP work better with hie-core (#1903)
* Pull the CPP into a separate module

* Pass Nothing to indicate that a text buffer shoud just be used from disk

* Add save handlers, since the version changing to ModTime may have an impact

* Rename contents to mbContents in one place

* Change runCpp to take a Maybe StringBuffer and attempt to reuse the existing file, if it can

* Add a Bazel alias for hie-core

* Add notes about the sad path

* Avoid one use of filePathToUri

* Avoid another use of filePathToUri which went wrong for CPP output

* Normalize Uri's by replacing adjacent // with a single /

* Improve how CPP works if you have a modified buffer

* Move textToStringBuffer out to Util

* Switch to hPutStringBuffer which is in GHC 8.8

* Note why we are escaping to /

* Refactoring suggested by review
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
876e07d5d6 Delete bits of hie-core that were unused (#1885)
* Delete now unused code

* Make protocol not reexport LSP.Types

* Delete more comments

* HLint
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
62cf82a32e Correct hie-core grammar (#1871) 2019-09-10 14:52:17 +02:00
Neil Mitchell
47332f1835 Give the readme a significant pass (#1869) 2019-09-10 14:52:17 +02:00
Robin Krom
067af9b356 language: upgrades: no generics for data types having the instances already (#1840)
language: upgrades: dont derive generics for data types having the instances already

We only derive generic instances on the fly for data types that don't
have them already.
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