Skip to content

Add resolve support in refine imports by merging it with explicit imports #3729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/hackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
"hls-cabal-plugin",
"hls-floskell-plugin", "hls-fourmolu-plugin",
"hls-ormolu-plugin", "hls-stylish-haskell-plugin",
"hls-class-plugin", "hls-eval-plugin", "hls-explicit-imports-plugin",
"hls-class-plugin", "hls-eval-plugin", "hls-import-actions-plugin",
"hls-haddock-comments-plugin", "hls-hlint-plugin", "hls-stan-plugin",
"hls-module-name-plugin", "hls-pragmas-plugin",
"hls-refine-imports-plugin", "hls-rename-plugin", "hls-retrie-plugin",
"hls-rename-plugin", "hls-retrie-plugin",
"hls-splice-plugin", "hls-tactics-plugin",
"hls-call-hierarchy-plugin", "hls-alternate-number-format-plugin",
"hls-qualify-imported-names-plugin", "hls-code-range-plugin",
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,8 @@ jobs:
run: cabal test hls-tactics-plugin --test-options="$TEST_OPTS" || cabal test hls-tactics-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-refine-imports-plugin test suite
run: cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-explicit-imports-plugin test suite
run: cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS"
name: Test hls-import-actions-plugin test suite
run: cabal test hls-import-actions-plugin --test-options="$TEST_OPTS" || cabal test hls-import-actions-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-call-hierarchy-plugin test suite
Expand Down
3 changes: 1 addition & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/plugins/hls-call-hierarchy-plugin @July541
/plugins/hls-class-plugin @Ailrun
/plugins/hls-eval-plugin
/plugins/hls-explicit-imports-plugin @pepeiborra
/plugins/hls-import-actions-plugin @pepeiborra
/plugins/hls-floskell-plugin @Ailrun
/plugins/hls-fourmolu-plugin @georgefst
/plugins/hls-gadt-plugin @July541
Expand All @@ -23,7 +23,6 @@
/plugins/hls-ormolu-plugin @georgefst
/plugins/hls-pragmas-plugin @berberman @Ailrun @eddiemundo
/plugins/hls-qualify-imported-names-plugin @eddiemundo
/plugins/hls-refine-imports-plugin
/plugins/hls-rename-plugin @OliverMadine
/plugins/hls-refactor-plugin @santiweight
/plugins/hls-retrie-plugin @pepeiborra
Expand Down
6 changes: 2 additions & 4 deletions bench/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@ configurations:
- ghcide-completions
- ghcide-type-lenses
- hlint
- importLens
- importActions
- moduleName
- ormolu
- pragmas
- qualifyImportedNames
- refineImports
- rename
- stylish-haskell
# - alternateNumberFormat
Expand All @@ -163,12 +162,11 @@ configurations:
# - ghcide-type-lenses
# - haddockComments
# - hlint
# - importLens
# - importActions
# - moduleName
# # - ormolu
# - pragmas
# - qualifyImportedNames
# - refineImports
# - rename
# - retrie
# - splice
Expand Down
3 changes: 1 addition & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ packages:
./plugins/hls-fourmolu-plugin
./plugins/hls-class-plugin
./plugins/hls-eval-plugin
./plugins/hls-explicit-imports-plugin
./plugins/hls-refine-imports-plugin
./plugins/hls-import-actions-plugin
./plugins/hls-hlint-plugin
./plugins/hls-rename-plugin
./plugins/hls-retrie-plugin
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Here is a list of the additional settings currently supported by `haskell-langua
Plugins have a generic config to control their behaviour. The schema of such config is:

- `haskell.plugin.${pluginName}.globalOn`: usually with default true. Whether the plugin is enabled at runtime or it is not. That is the option you might use if you want to disable completely a plugin.
- Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `refineImports`, `importLens`, `class`, `tactics` (aka wingman), `hlint`, `haddockComments`, `retrie`, `rename`, `splice`, `stan`.
- Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `refineImports`, `importActions`, `class`, `tactics` (aka wingman), `hlint`, `haddockComments`, `retrie`, `rename`, `splice`, `stan`.
- So to disable the import lens with an explicit list of module definitions you could set `haskell.plugin.importLens.globalOn: false`
- `haskell.plugin.${pluginName}.${lspCapability}On`: usually with default true. Whether a concrete plugin capability is enabled.
- Capabilities are the different ways a lsp server can interact with the editor. The current available capabilities of the server are: `callHierarchy`, `codeActions`, `codeLens`, `diagnostics`, `hover`, `symbols`, `completion`, `rename`.
Expand Down
22 changes: 11 additions & 11 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,20 @@ Known limitations:

### Make import lists fully explicit

Provided by: `hls-explicit-imports-plugin`
Provided by: `hls-import-actions-plugin`

Code action kind: `quickfix.literals.style`

Make import lists fully explicit (same as the code lens).

### Refine import

Provided by: `hls-import-actions-plugin`

Code action kind: `quickfix.import.refine`

Refines imports to more specific modules when names are re-exported (same as the code lens).

### Qualify imported names

Provided by: `hls-qualify-imported-names-plugin`
Expand All @@ -192,14 +200,6 @@ Rewrites imported names to be qualified.

For usage see the ![readme](../plugins/hls-qualify-imported-names-plugin/README.md).

### Refine import

Provided by: `hls-refine-imports-plugin`

Code action kind: `quickfix.import.refine`

Refines imports to more specific modules when names are re-exported (same as the code lens).

### Add missing class methods

Provided by: `hls-class-plugin`
Expand Down Expand Up @@ -346,15 +346,15 @@ Known limitations:

### Make import lists fully explicit code lens

Provided by: `hls-explicit-imports-plugin`
Provided by: `hls-import-actions-plugin`

Shows fully explicit import lists and rewrites them with a click (same as the code action).

![Imports code lens Demo](https://imgur.com/pX9kvY4.gif)

### Refine import code lens

Provided by: `hls-refine-imports-plugin`
Provided by: `hls-import-actions-plugin`

Shows refined imports and applies them with a click (same as the code action).

Expand Down
3 changes: 1 addition & 2 deletions docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| ghcide core plugins | 1 | |
| `hls-call-hierarchy-plugin` | 1 | |
| `hls-code-range-plugin` | 1 | |
| `hls-explicit-imports-plugin` | 1 | |
| `hls-import-actions-plugin` | 1 | |
| `hls-pragmas-plugin` | 1 | |
| `hls-refactor-plugin` | 1 | |
| `hls-alternate-number-plugin` | 2 | |
Expand All @@ -59,7 +59,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-qualify-imported-names-plugin` | 2 | |
| `hls-ormolu-plugin` | 2 | |
| `hls-rename-plugin` | 2 | |
| `hls-refine-imports-plugin` | 2 | |
| `hls-stylish-haskell-plugin` | 2 | |
| `hls-tactics-plugin` | 2 | 9.2, 9.4, 9.6 |
| `hls-overloaded-record-dot-plugin` | 2 | 8.10, 9.0 |
Expand Down
25 changes: 7 additions & 18 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,8 @@ flag eval
default: True
manual: True

flag importLens
description: Enable importLens plugin
default: True
manual: True

flag refineImports
description: Enable refineImports plugin
flag importActions
description: Enable importActions plugin
default: True
manual: True

Expand Down Expand Up @@ -246,15 +241,10 @@ common eval
build-depends: hls-eval-plugin == 2.1.0.0
cpp-options: -Dhls_eval

common importLens
if flag(importLens)
build-depends: hls-explicit-imports-plugin == 2.1.0.0
cpp-options: -Dhls_importLens

common refineImports
if flag(refineImports)
build-depends: hls-refine-imports-plugin == 2.1.0.0
cpp-options: -Dhls_refineImports
common importActions
if flag(importActions)
build-depends: hls-import-actions-plugin == 2.1.0.0
cpp-options: -Dhls_importActions

common rename
if flag(rename)
Expand Down Expand Up @@ -376,8 +366,7 @@ library
, class
, haddockComments
, eval
, importLens
, refineImports
, importActions
, rename
, retrie
, tactic
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions plugins/hls-explicit-imports-plugin/test/testdata/OnlyThis.hs

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions plugins/hls-explicit-imports-plugin/test/testdata/hie.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.2
name: hls-explicit-imports-plugin
name: hls-import-actions-plugin
version: 2.1.0.0
synopsis: Explicit imports plugin for Haskell Language Server
synopsis: Import actions plugin for Haskell Language Server
description:
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
license: Apache-2.0
Expand Down Expand Up @@ -30,7 +30,7 @@ common warnings
library
import: warnings
buildable: True
exposed-modules: Ide.Plugin.ExplicitImports
exposed-modules: Ide.Plugin.ImportActions
hs-source-dirs: src
build-depends:
, aeson
Expand Down
Loading