Skip to content

Enable rename plugin #2809

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 21 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f16def
refactor rename plugin
OliverMadine Mar 29, 2022
0207037
prevent renaming of built-in syntax
OliverMadine Mar 29, 2022
801271d
limit rename scope to current module
OliverMadine Mar 29, 2022
03c31ab
refine imports in rename plugin
OliverMadine Mar 29, 2022
8dafdd7
allow renaming with implicit module names
OliverMadine Mar 29, 2022
b7cda24
update tests with cross-module renaming limitation
OliverMadine Mar 29, 2022
ca5f91a
enable rename plugin
OliverMadine Mar 29, 2022
6731ef0
add rename plugin to features docs
OliverMadine Mar 29, 2022
c9ae847
add rename plugin to ghc-8.10.X stack yaml files
OliverMadine Mar 29, 2022
062fe8c
improve position printing in rename error
OliverMadine Mar 29, 2022
866d6f5
implement cross-module rename config option
OliverMadine Apr 2, 2022
bace426
unignore tests for cross-module renames
OliverMadine Apr 2, 2022
f35775e
update docs for cross-module renaming
OliverMadine Apr 2, 2022
b6065ca
fix within module renaming for ghc-9
OliverMadine Apr 2, 2022
61656f5
fix rename plugin language extensions for ghc-92
OliverMadine Apr 2, 2022
53b9cee
add explicit GHC.Parser imports in rename plugin
OliverMadine Apr 2, 2022
d024a6b
fix typo in rename docs
OliverMadine Apr 3, 2022
b469eef
use implicit import lists in rename plugin
OliverMadine Apr 3, 2022
bb91db0
relocate orphaned instances from rename plugin
OliverMadine Apr 3, 2022
70f4e18
Revert "relocate orphaned instances from rename plugin"
OliverMadine Apr 3, 2022
64f942f
Merge branch 'master' into rename-within-module
pepeiborra Apr 3, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/hackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
"hls-class-plugin", "hls-eval-plugin", "hls-explicit-imports-plugin",
"hls-haddock-comments-plugin", "hls-hlint-plugin",
"hls-module-name-plugin", "hls-pragmas-plugin",
"hls-refine-imports-plugin", "hls-retrie-plugin",
"hls-refine-imports-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-selection-range-plugin",
Expand Down
14 changes: 13 additions & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Many of these are standard LSP features, but a lot of special features are provi
| [Code actions](#code-actions) | `textDocument/codeAction` |
| [Code lenses](#code-lenses) | `textDocument/codeLens` |
| [Selection range](#selection-range) | `textDocument/selectionRange` |
| [Rename](#rename) | `textDocument/rename` |

The individual sections below also identify which [HLS plugin](./what-is-hls.md#hls-plugins) is responsible for providing the given functionality, which is useful if you want to raise an issue report or contribute!
Additionally, not all plugins are supported on all versions of GHC, see the [GHC version support page](supported-versions.md) for details.
Expand Down Expand Up @@ -305,6 +306,18 @@ support.

![Selection range demo](https://user-images.githubusercontent.com/16440269/150301502-4c002605-9f8d-43f5-86d3-28846942c4ff.mov)

## Rename

Provided by: `hls-rename-plugin`

Provides renaming of symbols within a module.

![Rename Demo](https://user-images.githubusercontent.com/30090176/133072143-d7d03ec7-3db1-474e-ad5e-6f40d75ff7ab.gif)

Known limitations:

- Only works within a module due to limited [multi-component support](https://github.com/haskell/haskell-language-server/issues/2193).

## Missing features

The following features are supported by the LSP specification but not implemented in HLS.
Expand All @@ -315,7 +328,6 @@ Contributions welcome!
| Signature help | Unimplemented | `textDocument/signatureHelp` |
| Jump to declaration | Unclear if useful | `textDocument/declaration` |
| Jump to implementation | Unclear if useful | `textDocument/implementation` |
| Renaming | [Parital implementation](https://github.com/haskell/haskell-language-server/issues/2193) | `textDocument/rename`, `textDocument/prepareRename` |
| Folding | Unimplemented | `textDocument/foldingRange` |
| Semantic tokens | Unimplemented | `textDocument/semanticTokens` |
| Linked editing | Unimplemented | `textDocument/linkedEditingRange` |
Expand Down
8 changes: 4 additions & 4 deletions ghcide/src/Development/IDE/Spans/AtPoint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Development.IDE.Spans.AtPoint (
, computeTypeReferences
, FOIReferences(..)
, defRowToSymbolInfo
, getAstNamesAtPoint
, getNamesAtPoint
, toCurrentLocation
, rowToLoc
) where
Expand Down Expand Up @@ -86,7 +86,7 @@ foiReferencesAtPoint file pos (FOIReferences asts) =
case HM.lookup file asts of
Nothing -> ([],[],[])
Just (HAR _ hf _ _ _,mapping) ->
let names = getAstNamesAtPoint hf pos mapping
let names = getNamesAtPoint hf pos mapping
adjustedLocs = HM.foldr go [] asts
go (HAR _ _ rf tr _, mapping) xs = refs ++ typerefs ++ xs
where
Expand All @@ -96,8 +96,8 @@ foiReferencesAtPoint file pos (FOIReferences asts) =
$ concat $ mapMaybe (`M.lookup` tr) names
in (names, adjustedLocs,map fromNormalizedFilePath $ HM.keys asts)

getAstNamesAtPoint :: HieASTs a -> Position -> PositionMapping -> [Name]
getAstNamesAtPoint hf pos mapping =
getNamesAtPoint :: HieASTs a -> Position -> PositionMapping -> [Name]
getNamesAtPoint hf pos mapping =
concat $ pointCommand hf posFile (rights . M.keys . getNodeIds)
where
posFile = fromMaybe pos $ fromCurrentPosition mapping pos
Expand Down
2 changes: 1 addition & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ flag refineImports

flag rename
description: Enable rename plugin
default: False
default: True
manual: True

flag retrie
Expand Down
5 changes: 4 additions & 1 deletion plugins/hls-rename-plugin/hls-rename-plugin.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: hls-rename-plugin
version: 1.0.0.1
version: 1.0.0.2
synopsis: Rename plugin for Haskell Language Server
description:
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
Expand All @@ -26,13 +26,16 @@ library
, ghc
, ghc-exactprint
, ghcide ^>=1.6
, hashable
, hiedb
, hls-plugin-api ^>=1.3
, lsp
, lsp-types
, mod
, syb
, text
, transformers
, unordered-containers

default-language: Haskell2010

Expand Down
Loading