What's done
* [x] Refactor the `runSession*` family function, properly add `TestConfig`, `runSessionWithTestConfig`, as the most generic `runSession*` function.
* [x] remove raraly used variants of `runSession*` functions and replaced by `runSessionWithTestConfig`.
* [x] migrate `ExceptionTests ClientSettingsTests CodeLensTests CPPTests CradleTests` to use the `hls-test-utils`
* [x] Only shift to lsp root when current root is different from the lsp root in DefaultMain of ghcide.
* [x] Remove most usage for `getCurrentDirectory`(After DefaultMain is called), Only remain those in top level of wrapper and exe, implement https://github.com/haskell/haskell-language-server/issues/3736#issuecomment-1924507928
* [x] add Note [Root Directory]
Co-authored-by: fendor <fendor@users.noreply.github.com>
* Another attempt at using the lsp API for some progress reporting
* Fixing tests
* Remove trace
* Make splice plugin tests not depend on progress
* More test fixing
* Switch to hackage
* stack
* warnings
* more
* Put tests back
---------
Co-authored-by: Patrick <fwy996602672@gmail.com>
* [x] migrate diagnosticTests, figure out how to pass `--test-no-kick`.
* [x] migrate openCloseTests
* [x] Lift a few functions from ghcide-test-utils to hls-test-utils
* [x] fixed `deeply nested cyclic module dependency`
* [x] modify `runSessionWithServer'` and ghcIde arguments to admit additional a switch for `no-kick`.
---------
Co-authored-by: fendor <fendor@users.noreply.github.com>
We add an option to `Config` that allows clients to specify how HLS
should load components.
We support two loading strategies:
* SessionLoadSingleComponent: Always load only a single component
when a new component is discovered.
* SessionLoadMultipleComponents: Always allow the cradle to load
multiple components at once. This might not be always possible,
e.g., if the tool doesn't support multiple components loading.
The cradle decides how to handle these situations.
By default, we use the conservative `SessionLoadSingleComponent` mode.
Additionally, changing the config at run-time leads to a reload of the
GHC session, allowing users to switch between the modes without
restarting the full server.
* Add cabal-gild as a cabal file formatter plugin
* Add support for multiple cabal formatters
In addition, allow different cabal file formatter provider to specify an
explicit file path, instead of searching only on $PATH.
* Fix cabal formatter test flags
* Remove more workarounds for GHCs < 9.0
* String, not [String]
* Remove GHC810 and GHC90 enum constants
* Fix logic mistake in windows tests
* Inline thDollarIdx
* Troubleshoot wrapper-test
* Troubleshoot
* Try free disk space action
* Run free-space in individual test jobs
* Only run the disk cleanup on ubuntu
* Revert troubleshooting code
* Revert free-disk-space workaround
* Reintroduce workaround
* Revert "Reintroduce workaround"
This reverts commit ec6e8da8c44d0130f0c23aac75df5e461c8f88e2.
* Don't install stack in tests?
* Revert "Don't install stack in tests?"
This reverts commit f53e9932f60eb6789ddef12f370ef81acf65fc58.
* Make the test use ghcup-managed stack
* More maintainable version of stack test
fix https://github.com/haskell/haskell-language-server/issues/3957
Things have been done:
1. Switch `Name` to `Identifier` in the implementation and add `ModuleName` to the `HsSemanticTokenType`
2. Strip ``` ` ` ``` and `()`, and split out qualified names. e.g.``` `Preclude.length` ``` to ```Preclude.``` `length`
3. add tokenizer to walk ast with the souce rope to get more accurate result and faster. Should fix https://github.com/haskell/haskell-language-server/issues/3983.
4. add type sig to semanticConfig's TH result
* Exactprint plugins for 9.8
* Fix last test
* comments
* fix borked cpp
* Don't use CPP in refactor plugin tests
* Fix -Wall, -Wunused-packages and hlint warnings in call-hierarchy plugin (#3979)
* Fix -Wall and -Wunused-packages in call-hierarchy plugin
* Make tests more uniform
* accept func test differences
* Run tests for 9.8 plugins in CI
* Fix another test
---------
Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* add config for semantic tokens for mapping between hs token type to LSP default token type
* fix Missing features header
* Delete plugins/hls-semantic-tokens-plugin/test/testdata/TDatatype.hs
* Delete plugins/hls-semantic-tokens-plugin/test/testdata/TDatafamily.hs
* Delete plugins/hls-semantic-tokens-plugin/test/testdata/TPatternsyn.hs
* update doc
* fix ghc96 schema generation
* remove typedata and add ghc98 scheme generation test file
* Ajust case in mappings
* add ghc92 generate scheme
* add ghc94 generate scheme
* cleanup
* modify the lspTokenReverseMap to take semantic config
* rename fromLspTokenType to lspTokenTypeHsTokenType
* add description for semantic tokens mappings config
* fix doc and cleanup
* delete content for /test/testdata/schema for now, since we are modifying the configuration
* semantic config keys use lower case in the first element
* add config generation scheme test
* fix config generation scheme test
* ajust names for semantic tokens
* add token suffix to token type configuration
* cleanup
* fix merge
* Implement semantic tokens lsp plugin draft
* SemanticTokens: combine information extracted from HieAst
* clean up
* map to default token types in lsp
* use lsp makeSemanticTokens to convert to lsp SemanticTokens type
* add test and cleanup
* refine semantic type to default one in lsp
* Use tokens from hieAst instead of renamedSource and add test
* use customize RefMap to get semantic type
* use refMap from useAsts
* Also compute imported names
* Also compute semantic type from TyThing
* Fix dependencies version
* fix version
* Retrieve nameSet from renamedSource to prevent names not visible(Such as by instance deriving) being handled
* add hlint config to ignore test data
* cean up test data
* revert flake.nix
* Rename query.hs to Query.hs
* Build: add semantic tokens to lts21
* Refactor and add README
* Semantic token, filter names in Ast
* CI: add consistancy check for wether semantic tokens computations is stable across different ghc versions
* Update documentation, cleanup test, remove default modifiers
* Fix: IO now classfied to TTypcon, add test for GADT and data family, Update documentation
* Restore stack.yaml
* fix stack build
* Refactor, move out ActualToken to Mappings and use ide logger
* Refactor: toLspTokenType should return Maybe type
* Stop use stale hieAst
* add getImportedNameSemanticRule rule to semantic tokens plugin
* do not retrieve hie in getImportedNameSemanticRule
* fix: add description for semantic tokens
* remove TValBind and TPaternBind and Use TFunction and TVariable instead
* cleanup
* Refactor useWithStaleMT and took care of the token range using position map
* fix build for 9.4
* refactor, use golden test
* refactor, use ExceptT for computeSemanticTokens
* Fix 9.2
* add persistentSemanticMapRule to prevent semantic tokens block on startup
* Fix, use hieKind instead of cast the type directly
* add options to turn semantic tokens on and off
* Disable stan plugin by default (#3917)
* Fix positionMapping in stale data (#3920)
* Fix positionMapping in stale data
* add test for updatePositionMapping
* add comment to demonstrate addOldDelta
* cleanup
* fix: for local variable, extract type from contextInfo instead of bind site, thus function in pattern binds can also be indentified
* clean up
* Update plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Query.hs
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* refactor: remove TNothing and compact the test output
* refactor: rename SemanticTokenType to HsSemanticTokenType to avoid confusion with lsp' SemanticTokenTypes
* refactor: push the computation of semantic token type to getSemanticTokensRule
* update documentation
* cleanup hieAstSpanNames
* remove renamed source from getSemanticTokensRule and optimize query function for semantic token type
* try to exclude names that is not visible in hie and cleanup
* add HieFunMaskKind, it is to differ wether a type at type index is a function or non-function
* expose function flag to expose (=>, ->, -=>, ==>)
* 1. Relax GetDocMap kindMap to get TyThing for more than type variables.
2. Backport isVisibleFunArg
* use customize logger, add test for unicode
* fix: handle unicode in semantic tokens
* update KindMap to TyThingMap
* cleanup
* add realSrcSpanToCodePointRange, realSrcLocToCodePointPosition to Development.IDE.GHC.Error
* add Note [Semantic information from Multiple Sources]
* move recoverFunMaskArray to Mappings.hs
* fix test, data.Set might not appear
* fix: handle semantic tokens with more than one ast
* fix: instance PluginMethod Request Method_TextDocumentSemanticTokensFull
* clean up
* turn semantic tokens off by default
* fix doc
* clean up doc
---------
Co-authored-by: fendor <fendor@users.noreply.github.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Changes to the vscode schema need to be communicated to vscode-haskell plugin maintainers,
otherwise users can't make use of the new configurations.
In general, changes to the schema need to be done consciously when new plugin or features are added.
We add these golden tests as an additional contract to inform relevant
parties whenever the configs change.
To fix a failing of these tests, review the change. If it is expected, accept the change via:
TASTY_PATTERN="generate schema" cabal test func-test --test-options=--accept
As changes need to be applied for all GHC version specific configs, you either need to run this command for each
GHC version that is affected by the config change, or manually add the change to all other golden config files.
Likely, the easiest way is to run CI and apply the generated diffs manually.
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* Add support for the multi unit argument syntax introduced in GHC 9.4: https://downloads.haskell.org/ghc/9.4.4/docs/users_guide/using.html#multiple-home-units
We now support arguments of the form
```
-unit @unitA -unit @unitB
```
where the response files `unitA` and `unitB` contain the actual list of arguments for that unit:
```
-this-unit-id a-0.1.0.0
-i
-isrc
A1
A2
```
Also refactor the session loader and simplify it.
Also adds error messages on GHC 9.4 if the units are not closed (#3422).
fixes
Fix closure check
session-loader: override old units with new in multi-unit support
Remove implicit-hie
session-loader: remember which files caused old components to be loaded, and
also pass them on to hie-bios so it can in turn pass them to `cabal repl` when
loading newer components.
This allows us to create valid set of build flags encompassing both the old and
new components, and the closure of all components in between.
The observation is that if you want to load some components X, Y, Z and so on,
cabal repl X Y Z ... will be more likely to give you a valid multi component
build plan/flags than cabal repl all, or any way of combining the results of
cabal repl X, cabal repl Y ...
Use new hie-bios
Move implicit cradles to HLS
Fix build on 9.0
Werror
Improve handling of specialTarget
* hie-bios doesn't mention the component name in the message anymore
* stack fixes
* wrapper: remove unused argument
* werror
* werror
* Implicit cradle: match implicit-hie-cradle logic
* Fix eval plugin
* ignore multi unit tests on 9.2
* Some fixes for 9.2
* Add hie.yaml for call-hierarchy-plugin tests
* Add hie.yaml for explicit-record-fields-plugin
* Add hie.yaml for hls-overloaded-record-dot-plugin
* Cleanup func-test suite
This test-suite is vastly legacy from Haskell IDE Engine.
It was originally written before we had a plugin-based architecture
where each plugin tests its feature in isolation.
Over time, this test-suite bitrotted, where a lot of testcases were
either redundant or out-of-date and consequentially disabled.
We clean up the test-suite, delete old tests and remove unused testdata.
* Remove unused config change
* Move qualified import tests to hls-refactor-plugin
* Add README for `func-test`
Provides guidance when to add a test to `func-test` and some historical
context.
* Add fendor as CODEOWNER for `func-test` and `hls-test-utils`
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* Adapt to lsp changes for workspace/configuration
This has a few substantive changes and a lot of messing with tests.
- We now tell `lsp` our config section, and parse just that section.
- We move the logic for updating the shake build rules for client config
from a `workspace/didChangeConfiguration` handler to the new `lsp`
callback, which will ensure it gets called in all circumstances that
can be relevant.
The test changes are more annoying:
- We ignore config and logging messages by default now, so we have to
stop doing that when we care about it.
- Many tests didn't really need to _change_ the config, but rather just
to set it once at the beginning. I adjusted a lot of test functions to
allow passing in the initial config for this reason.
* don't reduce the message timeout for wingman
* Fix stan plugin
* Doh
* Add arguments to direct logs to various locations
This adds arguments to HLS to allow the user to select whether to send
logs to any or all of:
- a file
- stderr
- the client
Importantly, we can toggle off the default stderr logging, so the vscode
extension can turn it off to avoid the double logging that arises from
logging to both the client and stderr.
I've set the default to _not_ log to the client. This is a change of
behaviour (today we log to the client by default), but I think it gives
the best experience by default, since most clients do show stderr output
somewhere, and then we probably want to make a case-by-case decision on
whether to use the client logging instead.
* Remove weird test
* Fix warning
* 9.6 support
Fixes
hls-refactor-plugin 9.6 support
hls-gadt-plugin
Fix 9.4 build
Fixes
hls-gadt-plugin fixes
WIP 9.6 patches
fixes
fixes
fixes
fixes
fixes
Fixes and add CI
CI
CI fixes
patch haskell/actions for https://github.com/haskell/ghcup-hs/issues/783
CI fixes
CI fixes
CI fixes
CI
CI
CI
CI
CI
Fix build on 9.0
Fix build on 9.0
hls-splice-plugin 9.6 compat
fixes
fixes
fixes
fixes
Fix benchmark build errors
9.2.5 and 8.10.7 had build errors when running benchmarks due to `mfsolve`
test suite having duplicate instances, so stop building tests for
mfsolve (see: https://github.com/kuribas/mfsolve/issues/8). Also,
`http2-4.0.0` has a parse error due to a misplaced haddock comment that
causes build failure with `-haddock`. It is fixed in the latest commit
of the source repo, so use that in the `cabal.project` for now.
Checkout correct commit on `pull_request` in CI
By default, the `pull_request` event has a `GITHUB_SHA` env variable set to the
"last merge commit on the GITHUB_REF branch"
(see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request).
But we want to check out the latest commit on the branch whether or not it is a
merge commit. This commit changes the CI actions to do just that.
fixes
Use head.hackage for 9.4
Only use head.hackage for 9.5 and up
Reverts the change that caused head.hackage to be used for 9.4 as
well
Reintroduce source-repo-package for ekg-json
Fix refactor plugin tests
Fix missing constraint detection in refactor plugin
ghc 9.6+ allow newer unordered-containers:template-haskell
Some refactor tests no longer broken for 9.2
Fix simple-multi-test on 9.6
Mark simple-plugin as broken on 9.6
func-test fixes
Disable unsupported plugins on 9.6
Eval plugin fixes
Eval plugin test fixes, debug output in CI script
Restore 'working' setup/actions
WIP Fix GHC prerelease windows install
Fix eval plugin T11
fixes
Eval plugin fixes
Fix splice plugin test
Mark `simple plugin` ghcide test broken on 9.6
fixes
fixes
Use GHC 9.6-rc1 in CI
Try using 9.6.1 for CI
* 9.6 nix
* Remove head.hackage
* fixes
* fixes
* fixes
* fixes
* fixes
* fixes
* Import qualified in postfix when applicable
* Dont import `EnumSet`
* Add `QualifiedImportStyle`
* Add qualified import test
* Ignore functional code action tests for windows-9.4.2
The test fails with:
test\functional\FunctionalCodeAction.hs:116:
expected: "Not in scope: \8216Control.when\8217\nNo module named \8216Control\8217 is imported."
but got: "Variable not in scope: when :: Bool -> IO () -> IO ()"
Seems like diagnostics for missing variables differ
* Add `importQualifiedPostTests`
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Set buildable on GHC 9.4
* Start work on GHC 9.4 compat
* Use patched `retrie`
* update retrie with github address. circumvent nix-prefetch-url.
* handle ExactPrint
* fix ghc 9.0 env.
* unwrap big CPP conditional for GHC 9.4
* GHC 9.4 buildable by disabling a few suggest.. functions
* enable disabled suggest...!
* hls-fourmolu-plugin is buildable
* hls-splice-plugin is buildable
* hls-hlint-plugin is buildable
* Enable plugins on GHC 9.4
* Add fourmolu for GHC 9.4
* fourmolu tweawk
* Fix `hls-hlint-plugin` build
- Build against GHC 9.4 API
- Increase upper bound on `hlint`
* Fix build of `hls-splice-plugin`
* annotation on close parenthesis. still need more work.
* found where closing parenthesis were missing
* examine internal annotation information.
* make use of makeDeltaAst. This fixes most of test failures in GHC 9.4
* remove dead code
* update apply-refact and hlint deps
* temporarily comment out hls-fourmolu-plugin.
* comment out build-tool-depends. then hls-fourmolu-plugin build succeeds with cabal v2-build
* remove unused fourmolu flake inputs
* fix ghc 9.0 build again.
* hlint and fourmolu for GHC 9.2!
* fix mistakenly overriden nix exp.
* remove unused hlint-3.3.6
* Fix CPP in hls-refactor-plugin
* Fix build error in hls-refactor-plugin
* Fix import
* Use `showErrors` instead of `showBag`
* fix initialization test error in refactor plugin.
* alternateNumberFormat and explicitFixity don't build on GHC 9.4
* force demoteIfDefer = id in typecheckModule for GHC 9.4.
* ignore tests which were already ignored with GHC 9.2
* fix extractDoesNotExportModuleName for GHC 9.4 by adjusting regex match
* use makeDeltaAst in removeRedundantConstraints
* fix addTypeAnnotationsToLiteralsTest
* Revert "alternateNumberFormat and explicitFixity don't build on GHC 9.4"
This reverts commit 4903092780031fb400b28f1e9ce696f1057855d8.
* Update flake lockfile
* Use upstream `retrie`
* Use upstream `retrie`
* Update lockfile
* Use upstream fourmolu
* fix arrow annotation on ghc 9.4
* fix flake.nix issue
* revert demoteIfDefer change for GHC 9.4.
* fix hls-splice-plugin build on GHC 9.0.2
* disable tracy on darwin.
* disable fourmolu plugin and ekg-json for now.
* fourmolu update to 0.10.1.0
* build fix for hls-refactor-plugin after merge
* update index-state.
* downgrade fourmolu to 0.9 for ghc 9.2 and 9.0
* remove unnecessary problematic Cabal-syntax dependency.
* update Cabal for ormolu in ghc 9.0 nix env.
* use custom apply-refact for now for both ghc 9.2 and 9.4
* added ghc >= 9.2 condition
* fix fourmolu with -f-fixity-th in nix env
* limit implicit-hie < 0.1.3
* add fourmolu back to build-tools-depends
* mark GHC92-failing tests to be failed on GHC 9.4
* ci failure test
* bump nix file.
* disable cachix action
* further comment out
* revive cachix action.
* remove commented-out
* fix hls-cabal-plugin by removing Cabal-syntax.
note that this is an opposite to #3383, to prioritize CI fix first.
* limit implicit-hie < 0.1.3
* added a small comment and link to the issue.
* put implicit-hie to ghcide dep
* update apply-refact rev
* use apply-refact-0.11.0.0 on hackage.
* 9.4 support for gadt and retrie plugins
Co-authored-by: Ian-Woo Kim <ianwookim@gmail.com>
Co-authored-by: Gabriella Gonzalez <gabriella@mercury.com>
Co-authored-by: Zubin Duggal <zubin.duggal@gmail.com>
* Support initial generic config for plugins
This enables opt-in plugins, i.e. plugins that are not enabled by default
* Support initial generic config for plugins
This enables opt-in plugins, i.e. plugins that are not enabled by default
* Address review comments and remove optionality in configInitialGenericConfig
I can't remember why this was optional in the first place, which probably means no good reason for it to be
* use defConfig instead of def
* test
* descriptor is the golden source for plugin default configs
Read plugin defaults from plugin descriptor instead of copying into initial config
This is less fragile as now the initial generic config specified in the plugin
descriptor is enforced by construction.
The downside is that now the descriptor is needed to parse the config, which
means a few places where a plugin id was enough now require a plugin descriptor,
which is much harder to get. We paper over this by moving these call sites to
the Action monad.
* redundant import
* simplify
* Build fixes
* Build fixes
* pedantic fixes
* Remove dead and obsolete code
* Organise export list with respect to utility functions
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Add plugin for formatting cabal files using cabal-fmt
* Add 'isolateTests' cabal flag to make plugin install cabal-fmt
For CI, we want to run the tests with a specific cabal-fmt version,
installed automatically by cabal.
However, locally, we might want to test with a locally installed
cabal-fmt version.
This flag allows developers to either let cabal install the
build-tool-depends or install a fitting version locally.
* Ignore failing cabal-fmt test on windows
* Add log message for missing cabal-fmt executable
Co-authored-by: Jana Chadt <jana.chadt@tuwien.ac.at>
Co-authored-by: Fendor <power.walross@gmail.com>
* Drop min_version_ghc (8.8.4 is min supported)
* Drop conditional glasgow_haskell cpp
* Inline some imports (review feedback)
* Drop hie-compat 8.6 (review feedback)
* Dropping more ghc 8.6 related code and docs
* Eval: Include tests that were broken for 8.6
* baseline for record completions
* address feedback
* gate ghc version
* add test
* refactor
* fix rope import
* fix plugins from rebase
* gate test by ghc version
* comments, fixes
* fix ghc90 test