Commit Graph

62 Commits

Author SHA1 Message Date
Andreas Herrmann
d937a5ebad
Track source locations on Daml.Script.submit (#7252)
* Track source locations on Daml.Script.submit

Adds a `HasCallStack` constraint on `HasSubmit.submit` and
`HasSubmit.submitMustfail`.

We need to move the definition of `HasCallStack` to `GHC.Stack.Types` to
avoid a cyclic dependency between `DA.Stack` and `DA.Internal.LF`.
Alternatively, we could inline `HasCallStack` in `DA.Internal.LF` but it
seems preferable to use the alias on the signature of
`submit(MustFail)`.

We need to adapt the type of the builtins for scenario `submit` and
`submitMustfail`.

changelog_begin
changelog_end

* Test-case for scenario/script source locations

* Test second commit with intermediate definition

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478518834

* Store the full callstack on submit

For forwards compatibility.

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478520268

* Document unused location definition

Addressing review commit
https://github.com/digital-asset/daml/pull/7252/files#r478522373

* Make user facing `SrcLoc` zero based

Following LSP precedent rather than GHC

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478529138

* Add comment for backwards compatibility code

Addressing review comment
https://github.com/digital-asset/daml/pull/7252/files#r478529138

* fmt

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-08-28 12:22:15 +00:00
Andreas Herrmann
b812f09da9
Disable lsp-tests script tests on Windows (#7235)
The similar scenario tests are also disabled on Windows and the script
tests are flaky on Windows due to timeouts.

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-08-26 07:56:12 +00:00
Moritz Kiefer
d33e130f47
Enable DAML Script service by default and document it (#7229)
* Enable DAML Script service by default and document it

fixes #7193

changelog_begin

- [DAML Script] DAML Scripts are now run in DAML Studio just like
  scenarios. The functionality for inspecting the results is
  identical. If you encounter issues, please report them.

changelog_end

* fix double "is identical"

changelog_begin
changelog_end
2020-08-25 19:53:59 +02:00
Andreas Herrmann
9f2367f6cc
IDE distinguish scripts and scenarios (#7197)
* IDE distinguish scripts and scenarios

The code lens above DAML script definitions now reads `Script results`
instead of `Scenario results`.

This also adds DAML Script test cases to the lsp-tests.

The functionality for testing scenario and script code-lenses in the
`Utils` module is identical. However, this adds dedicated definitions
for scripts to clearly distinguish the scenario and script test-cases.

changelog_begin
changelog_end

* Add sum type to distinguish Scenario and Script

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-08-20 16:36:23 +00:00
Moritz Kiefer
75eb554841
Prefix IDE include paths with project root (#6463)
* Prefix IDE include paths with project root

As described in #6174, `--include` is broken pretty badly in the IDE
atm. LSP works based on absolute file paths so if you have a relative
include dir you run into two issues:

1. You end up with two GHC sessions e.g, one for `/multidir` and one
   for `.`. That results in fun type errors like “Couldn’t match expected
   type `Text` with actual type `Text`”.
2. The same file can end up being represented twice. Apart from being
   horribly inefficient, this breaks as soon as we try to build a DALF
   since the function for constructing that (correctly) explodes when
   there are two files with the same module name.

This change does not break `daml build` since the project root is
relative there.

fixes #6174

changelog_begin

- [DAML Studio] Fix an issue where use of the `--include` option
  resulted in various confusing type errors. See
  https://github.com/digital-asset/daml/issues/6174

changelog_end

* Stop wasting my time hlint

changelog_begin
changelog_end
2020-06-23 16:58:14 +02:00
Moritz Kiefer
c0e28d83ee
Turn warnings for module name/record name mismatches into errors (#5266)
* Turn warnings for module name/record name mismatches into errors

The module name warning existed for ages. We started warning about the
record name mismatch in 0.13.55 so I’d like to turn it into an error
before 1.0

changelog_begin

- [DAML Compiler] File names must now match up with module names. This
  already produced a warning in previous releases.

- [DAML Compiler] It is now an error to define a record with a single
  constructor where the constructor does not match the type
  name. To fix the error you need to change ```data X = Y { … }``` to
  ```data X = X { … }```.  This restriction only applies to
  single-constructor records. Variants and enums are not affected.
  This already produced a warning in 0.13.55.

changelog_end

* Fix integration tests

* Fix docs

* Fix lsp tests
2020-03-30 10:21:53 +00:00
Gary Verhaegen
1872c668a5
replace DAML Authors with DA in copyright headers (#5228)
Change requested by Manoj.

CHANGELOG_BEGIN
CHANGELOG_END
2020-03-27 01:26:10 +01:00
Moritz Kiefer
aa48f3026e
Bump ghcide (#5128)
This PR bumps ghcide, haskell-lsp and haskell-lsp-types. There aren’t
really any important changes in ghcide itself but the haskell-lsp
update includes my fix for crashing completions.

One change in ghcide itself is that NormalizedFilePath got moved to
haskell-lsp. ghcide needs special treatment for empty file paths so we
use `toNormalizedFilePath'` from ghcide instead of
`toNormalizedFilePath` from `haskell-lsp`. I’ve added an hlint rule to
enforce this.

changelog_begin
changelog_end
2020-03-23 12:09:36 +00:00
Shayne Fletcher
2525a4610a
Update hlint (#5123)
changelog_begin
changelog_end
2020-03-22 16:30:11 +00:00
Moritz Kiefer
be7f0802c6
Bump ghcide (#5103)
This includes some completion improvements.

changelog_begin
changelog_end
2020-03-20 16:43:59 +00:00
Moritz Kiefer
58c101c3ab
Mark lsp tests as flaky on Windows (#4906)
:sadpanda:

changelog_begin
changelog_end
2020-03-09 16:53:36 +01:00
Moritz Kiefer
cc4f1430fb
Fix flaky lsp tests (#4541)
I’ve failed to reproduce this locally so far but on CI we sometimes
get the DLint warning that `True == True` is redundant before we get the
parse error which results in the tests failing. There is no reason why
we need to use `True == True` here anyway so the fix is to simply
replace it by `True`.

changelog_begin
changelog_end
2020-02-17 12:50:53 +01:00
Moritz Kiefer
4e3cad411b
Extend LSP multi-package tests (#4481)
This adds a test for running the LSP server directly in the project
directory to make sure that we do not need to build first in that case
and that no --package flags are necessary.

changelog_begin
changelog_end
2020-02-12 10:21:01 +01:00
Moritz Kiefer
1dc40ca239
Support multiple-packages in damlc ide (#4445)
* Support multiple-packages in `damlc ide`

changelog_begin

- [DAML Studio] You can now open DAML Studio in the root of a
  multi-package project instead of opening it separately for each
  package. Take a look at the documentation for details on how to set
  this up.

changelog_end

There are a few caveats here:

1. You need a ``daml.yaml`` in the root of your project directory. I
think this is somewhat sensible but we should add a warning to VSCode
if you open it in a directory that does not have a ``daml.yaml`` (in a
separate PR).

2. Changes are not picked up accross dependencies. This is a larger
undertaking and given the current setup simply impossible (we don’t
know that the source files of one package belong to the DAR referenced
in the ``dependencies`` field of the other package. We can make this a
bit better by at least detecting that the ``.dar`` has changed but
let’s do that separately.

3. Since ``daml init`` runs once on startup, it will run in the root
directory instead of initializing the package db of the individual
packages. This is fixable but will conflict with #4391 so let’s
address this separately.

I’ve added docs to the daml studio section that explain the caveats.

* Use the proper sdk version in lsp-tests
2020-02-10 12:20:56 +00:00
Moritz Kiefer
52d4f60aec
Switch to ghcide 0.1.0 (#4381)
* Switch to ghcide 0.1.0

changelog_begin
changelog_end

* Bump hie-bios
2020-02-04 18:40:43 +01:00
Moritz Kiefer
93d7b1a472 Bump ghcide to fix GHC panics in LSP tests (#4176)
fixes #4152

changelog_begin
changelog_end
2020-01-24 08:40:57 +00:00
Moritz Kiefer
57d0e32c3e
Mark lsp-tests as flaky (#4158)
This makes me a :sadpanda: but until we have figured out what is going
on, this seems better than forcing manual restarts.

changelog_begin
changelog_end
2020-01-22 16:55:44 +01:00
Moritz Kiefer
74d12ce39a Bump ghcide to include bugfix (#4074)
* Bump ghcide to include bugfix

This includes a fix for a bug in completions which we introduced in
the latest ghcide bump which in turn broke the DAML IDE completely.

changelog_begin

- [DAML Studio] Fix a bug in completions that caused DAML Studio to
stop responding after the first completion was requested.

changelog_end

* Use ghcide from master branch and simplify test
2020-01-16 18:38:58 +00:00
Moritz Kiefer
42c586f8d4
Bump ghcide (#3943)
* Bump ghcide

* Fix ghcide build

* Include bugfix for Windows
2020-01-04 07:51:51 +01:00
Gary Verhaegen
878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
Moritz Kiefer
d675156e2c
Bump ghcide to fix flakiness in LSP tests (#3813)
fixes #3821

see https://github.com/digital-asset/ghcide/pull/235 for the actual
fix, I’ll change the commit before merging.
2019-12-12 17:11:35 +01:00
Moritz Kiefer
d6bf6f6c04 Mark lsp tests flaky (#3818) 2019-12-11 14:10:48 +00:00
Andreas Herrmann
f4d0eb636e Replace Hazel by stack_snapshot (#2743)
* Unmangled libz.so and libbz2.so

* Use stack_snapshot instead of Hazel

* Remove Hazel

* Define stack_snapshot

* Update rules_haskell

* Document stack_snapshot

* Clean stack's lock file from aborted builds
2019-11-22 14:24:08 +00:00
Moritz Kiefer
8615266230 Switch the default DAML-LF version to 1.7 (#3530) 2019-11-19 19:18:07 +00:00
Moritz Kiefer
64261c80d6 Fix race condition in LSP stress tests (#3482)
Previously we opened file FooX before FooX+1 which we import from FooX
so there is a race condition if we try to resolve imports in FooX fast
enough. Now we open them in reverse order to fix this.

The other option would be to write all files to disk before opening
them but given that we can easily avoid this here, I’d rather keep
things in memory.
2019-11-15 09:27:39 +00:00
Moritz Kiefer
36719717fa
Update to current state of progress reporting in LSP (#3211)
* Update to current state of progress reporting in LSP

* fix ide-debug-driver

* Fix tests

* Fix build of ghcide executable
2019-10-17 16:14:49 +02:00
Moritz Kiefer
a25c2e9de3
Avoid normalizing include dirs (#3103)
* Avoid normalizing include dirs

Fixes #3099

See https://github.com/digital-asset/ghcide/pull/152 for the
corresponding PR in ghcide

* bump to proper ghcide rev

* bump haskell-lsp rev
2019-10-04 10:41:44 +02:00
Moritz Kiefer
f7befca723
Get ghcide from the new upstream repo (#2867)
* Get ghcide from the new upstream repo

* Update azure-pipelines.yml

Co-Authored-By: Gary Verhaegen <gary.verhaegen@digitalasset.com>
2019-09-11 08:57:48 +02:00
Moritz Kiefer
d2b68d45d4 Rename hie-core to ghcide (#2820)
* Rename hie-core to ghcide

The name `hie-core` has caused a lot of confusion as to how we relate
to haskell-ide-engine so changing it should hopefully help with that.
I also think that ghcide is still a good name once we hopefully
integrate with haskell-ide-engine more closely.

The name ghcide seems to have a reasonable amount of support on
Twitter https://twitter.com/ndm_haskell/status/1170681262987710464
which is of course the only good way to come up with names.

* Add a readme that points people to the new directory.

* Fix bogus replacements

* Use a proper link

* links are hard
2019-09-09 13:55:16 +00:00
Andreas Herrmann
ed39800a9f Rename hazel_deps to hackage_deps (#2789)
* hazel_deps --> hackage_deps

Mechanical change:

```
sed -i 's/hazel_deps/hackage_deps/g' $(ag -l hazel_deps)
```

* Hazel dependencies --> Hackage dependencies
2019-09-06 09:01:09 +00:00
Anup Kalburgi
0a9e0a8911 Adding fields to template graphs (#2673)
* Adding more info to dor

* Adding fields to the graph

* Spelling mistakes and params

* Removing single line function

* Moving the duplicated code

* Revert "Moving the duplicated code"

This reverts commit 520b5d9b0d.

* Adding more structure to graph

* Working tests with graph which is more easy to understand and change.
have few more tests to migrate

* Adding edge details

* One more to go

* Adding more verbose field information

* All tests now tests the fields that are being added

* Removing unused Import

* defined not refined

* Unused imports

* Names need to be consitent

* Acutal and Expected, not expected and expected

* Removing unused export

* Lints
2019-09-05 15:57:58 +00:00
Anup Kalburgi
09b766c502 Visual integration with LSP (#2597)
* daml visualize with lsp

* Working command execution with ide

* Have to call visual now

* Split function

* Wrong constuctions of world or the module

* Working almost

* Have to gather all modules

* Now works end to end. Considers all the daml files in workspace

* removing unused code

* removing unused dependency

* Removing unused JS code and better error message

* Function re-arrange

* Removing us of heaad, instead handling error

* Format and rearranging

* Removing unused assignment

* Formating everything

* missed dependency

* Generating visual only for the file that is open

* Using modules from generated pkg, error messages

* Bringing back the commands

* Names and formating

* consitent error message

* Removing Just pattern match using _use now

* package

* Moving visual to a different module

* Function simple

* Removing Rule as it increases memeory consumption

* TODO LSP error

* White space

* Fmt things

* Handling if command was executed for a non daml files

* Better error message

* debugging

* Fix executeCommand

* Adding tests to execute command. Thanks moritz

* Unwanted lines

* Spaces and comment

* 3rd time ?

* Spaces are white

* assert equal instead of assert bool
2019-08-26 15:47:29 +00:00
Moritz Kiefer
3eb112e4ca
Only report progress when client supports it (#2517)
* Only report progress when client supports it

This fixes an issue that some people encountered when running hie-core
in Emacs with a version of haskell-lsp that does not understand
progress events.

* Fix tests

* More test fixes
2019-08-13 20:00:21 +02:00
Gary Verhaegen
99ea93168d
update copyright notices (#2499) 2019-08-13 17:23:03 +01:00
Moritz Kiefer
2b690fd420 Increase timeout on lsp-tests (#2478)
Now that they are no longer marked as flaky on Windows, we seem to be
hitting the actual Bazel timeout sometimes.
2019-08-09 15:32:32 +00:00
Moritz Kiefer
d388c5692b
Upgrade haskell-lsp and lsp-test (#2474)
* 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
2019-08-09 15:09:59 +02:00
nickchapman-da
b90862ebec
improve haskell module hierarchy to be more consistent (#2319) 2019-07-29 15:55:55 +01:00
nickchapman-da
b30228ab95
{-# LANGUAGE OverloadedStrings #-} is now on by default (#2270) 2019-07-24 08:09:26 +01:00
Moritz Kiefer
80360af18b
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-07-23 15:00:21 +02:00
Andreas Herrmann
e2a424e5fc 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-07-22 13:42:04 +00:00
Andreas Herrmann
63b46304eb
Base DA.Bazel.Runfiles on bazel-runfiles (#2147)
* DA.Bazel.Runfiles based on bazel-runfiles

* locateRunfilesMb -> locateRunfiles

* .exe extension on Windows

* Add docstring to locateRunfiles

* bazel-runfiles: Normalize on Windows
2019-07-17 09:48:44 +02:00
Shayne Fletcher
dcd20ace8a Daml hlint integration (#2115)
* Get draft rule in

* Hlint is now firing

* First hlint unit test

* This gets hlint working in the ide

* Select hlint.yaml contextually. Wip

* Fix prod path

* Switch between prod and test versions of hlint.yaml

* Format

* Ignore hlint hints in the language tests

* Add some debugging stuff. LSP stress test is broken

* Update compiler/damlc/daml-ide-core/src/Development/IDE/Core/Rules/Daml.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Tidy up some details

* Simplify settings (remove unused parseFlags)

* Fix LSP stress tests

* ./fmt.sh

* Collapse to one hlint.yaml, provide options

* Fix location of hlint runfiles

* Disable hlint by default; enable for shake-ide tests

* lint (ironic)

* Remove filtering of lints from integration test

* ./fmt.sh

* Respect the flag

* Silence opininated lint

* Update compiler/damlc/daml-opts/daml-opts-types/DA/Daml/Options/Types.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update compiler/damlc/lib/DA/Cli/Damlc.hs

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* I really did mean optHlintEnable here

* Move hlint enabled check to ofInterest like shouldRunScenarios

* Rename variable

* Cache settings

* Missed a merge conflict

* lift liftIO

* Remove the hlint-testing POC

* use useNoFile_
2019-07-12 16:17:06 +00:00
Moritz Kiefer
2371d173b1
Move all damlc tests to compiler/damlc/tests (#2057)
I’ve also changed some of the names to be more sensible.
2019-07-09 13:38:58 +02:00
Moritz Kiefer
edff8a416d
Move files in daml-foundations/daml-ghc to compiler/damlc (#2037)
* Move files in daml-foundations/daml-ghc to compiler/damlc

There is also a bit of refactoring going on to actually split things
apart into sensible targets. What is still missing is a cleanup of the
module hierarchy and a cleanup of the test targets but I’ll leave
those for separate PRs.

As a nice bonus, this also reduces dependencies between targets so it
will speed up compiles.

* Update .hie-bios
2019-07-08 17:55:51 +02:00
Moritz Kiefer
bb3a98bf61
Move code in daml-tools outside of daml-foundations (#2033) 2019-07-08 11:40:48 +02: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
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
Andreas Herrmann
93d8e01db2
Update rules_haskell and static GHC (#1515)
* Update rules_haskell and static GHC

Remove patches that have been upstreamed or are no longer required.
Update still required patches to match the new rules_haskell version.

Previously we patched rules_haskell to coerce GHC into using static
Haskell libraries in most places. In particular we moved hs-libraries
entries into extra-libraries entries in the package configuration files.
A much cleaner approach is to compile GHC with a static RTS, then GHC
will by itself choose to load static Haskell libraries.

* Remove haskell_cc_import

* da-hs-daml-cli -> daml-cli

* da-hs-damlc-app -> damlc-app
2019-07-01 13:26:19 +02: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