Commit Graph

49 Commits

Author SHA1 Message Date
Moritz Kiefer
5aa3cba949
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-07-16 15:51:01 +02:00
Moritz Kiefer
6fb2703d6d Add useNoFile helpers matching defineNoFile (#2126) 2019-07-12 15:06:03 +00:00
Moritz Kiefer
48a3f77c4f
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-07-11 17:49:23 +02:00
Moritz Kiefer
13253d82d1
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-07-09 15:10:40 +02:00
Moritz Kiefer
4f55cb3bda Fix VSCode extension and remove silly warnings (#2042) 2019-07-08 19:47:38 +00:00
Moritz Kiefer
bb3a98bf61
Move code in daml-tools outside of daml-foundations (#2033) 2019-07-08 11:40:48 +02:00
Moritz Kiefer
ef9d27d80a Expose TcModuleResult in RuleTypes (#2014)
This should really be part of the public API.
2019-07-04 18:29:52 +00:00
Moritz Kiefer
6e14215bcc 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-07-04 14:57:14 +00:00
Moritz Kiefer
93f930f438 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-07-04 12:44:35 +00:00
Shayne Fletcher
96cfa3e346 Add Development.IDE.Core.Debouncer to library other-modules (#1998) 2019-07-03 19:05:54 +00:00
Moritz Kiefer
79f44e703c 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-07-03 17:30:59 +00:00
Neil Mitchell
4dc9cd0020 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-07-03 15:38:57 +00:00
Neil Mitchell
a2ba883092 Make Haddock work for hie-core (#1990) 2019-07-03 15:21:12 +01:00
Neil Mitchell
ea3e0a863c Hide some hie-core modules (#1987)
* Hide some hie-core modules

* Make bazelifier happy
2019-07-03 13:37:13 +00:00
Neil Mitchell
ad1e8cafbf 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-07-03 13:01:26 +02:00
Neil Mitchell
2e45ff3c57 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-07-03 11:51:46 +01:00
Moritz Kiefer
330ee17be6 Make Priority in hie-core independent of DAML (#1983) 2019-07-03 10:03:16 +00:00
Moritz Kiefer
3b64291a92 Cleanup moduleImportPaths now that file paths are normalized (#1980) 2019-07-03 09:55:40 +00:00
Moritz Kiefer
b748fab0f9
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-07-01 17:30:13 +02:00
Moritz Kiefer
af795d14ca Combine all artifacts output by damlc in .daml (#1959)
Fixes #1241
2019-07-01 15:07:30 +00:00
Moritz Kiefer
6919b07186
Implement LSP request cancellation (#1954)
* Implement LSP request cancellation
2019-07-01 13:04:37 +02:00
Neil Mitchell
3b4c5a6597
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-07-01 08:30:37 +01:00
Andreas Herrmann
9da78116d6 Mask async exceptions in updateFileDiagnostics (#1944)
* Mask async exceptions in updateFileDiagnostics

* lsp-tests remove flaky flag
2019-07-01 07:14:31 +00:00
Shayne Fletcher
cc0e39c89e 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-06-28 22:14:40 +00:00
Neil Mitchell
51beadd39f
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-06-28 18:37:08 +01:00
Neil Mitchell
acffcb40e5 Fix hie.cabal (#1943)
* I put safe-exceptions in the executable, not the library

* Sort all the lines in the .cabal file
2019-06-28 15:04:00 +00:00
Neil Mitchell
dfe9c00c62
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-06-28 14:56:27 +01:00
Neil Mitchell
ac4272edc5
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-06-28 12:47:45 +01:00
Neil Mitchell
e75d2b465e 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-06-27 22:17:37 +00:00
Neil Mitchell
8db9941858
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-06-26 17:07:08 +01:00
Neil Mitchell
b01464339c
Delete bits of hie-core that were unused (#1885)
* Delete now unused code

* Make protocol not reexport LSP.Types

* Delete more comments

* HLint
2019-06-26 12:15:16 +01:00
Neil Mitchell
1a1d1591af
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-06-26 09:04:10 +01:00
Neil Mitchell
409eba0aab Correct hie-core grammar (#1871) 2019-06-25 19:24:56 +00:00
Neil Mitchell
c6ba459709
Give the readme a significant pass (#1869) 2019-06-25 19:07:00 +01:00
Robin Krom
05d80eeeb4
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-06-25 18:17:34 +02:00
Neil Mitchell
c8adb9810d 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-06-25 15:13:17 +00:00
Neil Mitchell
0fcbbf489e Delete unused deps (#1856)
* Delete unused package dependencies

* Eliminate the use of pretty

* Don't export some things that weren't necessary

* Add a missing dependency

* Avoid reexporting files of interest methods

* Put toIdeResult back
2019-06-25 09:09:42 +00:00
Neil Mitchell
95176a4f2b
Don't import LSP.Protocol (#1853) 2019-06-24 18:48:28 +01:00
Moritz Kiefer
5a951120b6
Support goto definition on types in type annotations and type signatures (#1845) 2019-06-24 14:49:36 +02:00
Neil Mitchell
ee3b62c380
Clean up the logging in hie-core (#1839)
* Move prettyPosition over to a more sensible place

* Avoid some pretty printing

* Remove duplicate methods and switch to having a function to get the logger handle

* Remove unncessary bits of the logger

* Remove reportSeriousErrorDie - was unused

* Rename the Logger methods to Logger rather than Handle

* Delete the unique supply

* Decrease the use of getServiceEnv

* Move getIdeOptions inside Service

* Add getFilesOfInterest rule

* Hide the existence of Env

* Inline some redundant forwarding methods

* Add a FIXME for a dodgy function

* Delete some redundant imports

* Rename Map to HMap, since I need to use Data.Map too

* Make the Shake-specific Diagnostics functions into that module

* Delete errorDiag which was unused

* Inline the diagnostic function, since it had one user

* Add ofInterest rule as a separate module

* Sort the exposed modules

* Fix up the demo

* Make sure you add the OfInterestVar global

* HLint

* Get rid of some of interest stuff in other places

* Remove the OfInterest stuff from Service
2019-06-24 12:46:51 +01:00
Moritz Kiefer
d828956de2 Fix cross package goto definition (#1834)
The reason for why it was broken was rather simple: We just lost the
non-compat logic somewhere along the way.

fixes #1582
2019-06-24 09:18:26 +00:00
Neil Mitchell
0b396be07a
Make hie-core Compile simpler (#1832)
* Delete LoadPackageResult, was unused

* Delete tmrOccEnvName from Compile

* Push orphan instances around a bit, avoiding some

* Make convertModule take an explicit filename to report against (since we have a good one in our hands)

* Get rid of GhcModule - only one field was ever used

* Collapse setVritualFileContents and removeVirtualFile into one

* Make the VFSHandle abstract

* Make it clear runGhcSession does not need IdeOptions

* Avoid passing around IdeOptions so much when they aren't required

* Get rid of runGhcSessionExcept

* Make catchSrcErrors be in Either, not ExceptT

* Don't import ExceptT qualified

* Don't import Exception qualified

* Rewrite and simplify computePackageDeps
2019-06-24 08:46:16 +01:00
Neil Mitchell
282f8b4432 Delete prettyprinter-syntax (#1829)
* Delete the entirely unused reflow function

* Don't have Data.Text.Prettyprint.Doc.Syntax reexport stuff

* Move most of the pretty printing inside hie-core

* Get rid of the prettyprinter-syntax dependency from hie-core

* Get rid of prettyprinter-syntax, by collapsing the one definition into DA.Pretty
2019-06-24 08:00:42 +01:00
Shayne Fletcher
01a2de023d
Integrate Emacs instructions into README (#1831)
* Integrate Emacs instructions into README

* Fix a grammatical error
2019-06-23 17:59:53 -04:00
Neil Mitchell
023704cb67 Add additional step of building the hie-core extension (#1827) 2019-06-23 21:59:38 +00:00
Shayne Fletcher
c8e7af5fd8
Update the hie-bios commit SHA (#1825)
* Update the hie-bios commit SHA

* Also update the SHA in our bazel WORKSPACE

* Update the hash too

* Tutorial for Emacs integration

* Update hie-bios patch
2019-06-22 12:01:44 -04:00
Neil Mitchell
8885160c7c Further cleanups to hie-core (#1819)
* Move the span related functionality to one place

* Fuse docHeaders away

* Decouple AtPoint from the rest of the rule database, simplifying the dependencies

* Move the import related functionality to one place

* Move all the closely tied to GHC modules together

* Rename the Logger module

* Push the other module renames through the code base

* Rename Development.IDE.State to Development.IDE.Core

* Rename Functions.Compile to Core.Compile

* Fix up some module names

* Cut down on non-sensicle exports

* Don't worry about setting source - no one uses it

* Reorder the module header

* Give more sensible names to the diagnostic creating functions

* Use more appropriate diagnostic functions

* Simplify the internal diagnostic creations

* Rewrite the diagnostics to go direct, not via GHC error types

* Remove redundant dflags from some functions

* Make sure the warning vs error distinction remains

* Remove unnecessary extensions
2019-06-22 09:21:59 +01:00
Neil Mitchell
39e27fb2e3 Clean up hie-core (#1815)
* Make atPoint generate either haskell or daml syntax, depending on options

* Get rid of data HoverText

* Move VirtualResource out from hie-core

* Rename hie-core to the right name

* Drop Types.LSP, merge it into LSP.Protocol

* Remove orphans that aren't actually used in our code

* Delete redundant newlines

* Add a defaultIdeOptions function

* Move ideTryIOException over to its one user

* Delete unused exports

* Delete the ProjectDiagnostic newtype - the type index was always Key

* Don't reexport position information from Diagnostic

* Delete the unused bits from Location

* Delete unused stuff from getSrcSpan

* Move URL stuff into Location from Diagnostic

* Remove unnecessary CPP

* Remove unnecessary extension

* Change from stage being polymorphic to being a Text

* Fix up the test suite too

* Push the cleanup to the edges

* More dependencies

* Patch up the tests now they need to find the type signature inside a ```daml block
2019-06-21 21:19:07 +00:00
Neil Mitchell
3e1083e1fe Rename haskell-ide-core to hie-core (#1809)
* Rename haskell-ide-core as hie-core, after discussions with Alan Zimmerman and others

* Update the readme to just say how to install
2019-06-21 17:07:09 +00:00