Skip to content

Commit fda2d80

Browse files
authored
Merge branch 'master' into feat-3183-gen_plugins_docs
2 parents 475d762 + d923d82 commit fda2d80

File tree

26 files changed

+613
-63
lines changed

26 files changed

+613
-63
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ jobs:
160160
name: Test hls-splice-plugin
161161
run: cabal test hls-splice-plugin-tests || cabal test hls-splice-plugin-tests
162162

163-
# TODO enable when it supports 9.10
164-
- if: matrix.test && matrix.ghc != '9.10'
163+
- if: matrix.test
165164
name: Test hls-stan-plugin
166165
run: cabal test hls-stan-plugin-tests || cabal test hls-stan-plugin-tests
167166

.hlint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
- CompletionTests #Previously part of GHCIDE Main tests
111111
- DiagnosticTests #Previously part of GHCIDE Main tests
112112
- FindDefinitionAndHoverTests #Previously part of GHCIDE Main tests
113+
- FindImplementationAndHoverTests #Previously part of GHCIDE Main tests
113114
- TestUtils #Previously part of GHCIDE Main tests
114115
- CodeLensTests #Previously part of GHCIDE Main tests
115116

@@ -134,6 +135,7 @@
134135
- Ide.Plugin.Eval.Parse.Comments
135136
- Ide.Plugin.Eval.CodeLens
136137
- FindDefinitionAndHoverTests #Previously part of GHCIDE Main tests
138+
- FindImplementationAndHoverTests #Previously part of GHCIDE Main tests
137139

138140
- name: [Prelude.init, Data.List.init]
139141
within:

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ packages:
88
./hls-test-utils
99

1010

11-
index-state: 2024-08-22T00:00:00Z
11+
index-state: 2024-10-21T00:00:00Z
1212

1313
tests: True
1414
test-show-details: direct

docs/features.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ Known limitations:
8181

8282
- Only works for [local definitions](https://github.com/haskell/haskell-language-server/issues/708).
8383

84+
## Jump to implementation
85+
86+
Provided by: `ghcide`
87+
88+
Jump to the implementation instance of a type class method.
89+
90+
Known limitations:
91+
92+
- Only works for [local definitions](https://github.com/haskell/haskell-language-server/issues/708).
93+
8494
## Jump to note definition
8595

8696
Provided by: `hls-notes-plugin`
@@ -316,6 +326,14 @@ Code action kind: `quickfix`
316326

317327
Correct common misspelling of SPDX Licenses such as `BSD-3-Clause`.
318328

329+
### Add dependency to `cabal` file
330+
331+
Provided by: `hls-cabal-plugin`
332+
333+
Code action kind: `quickfix`
334+
335+
Add a missing package dependency to your `.cabal` file.
336+
319337
## Code lenses
320338

321339
### Add type signature

docs/support/plugin-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has
6565
| `hls-overloaded-record-dot-plugin` | 2 | |
6666
| `hls-semantic-tokens-plugin` | 2 | |
6767
| `hls-floskell-plugin` | 3 | 9.10.1 |
68-
| `hls-stan-plugin` | 3 | 9.10.1 |
68+
| `hls-stan-plugin` | 3 | |
6969
| `hls-retrie-plugin` | 3 | 9.10.1 |
7070
| `hls-splice-plugin` | 3 | 9.10.1 |

ghcide/src/Development/IDE/Core/Actions.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Development.IDE.Core.Actions
33
( getAtPoint
44
, getDefinition
55
, getTypeDefinition
6+
, getImplementationDefinition
67
, highlightAtPoint
78
, refsAtPoint
89
, workspaceSymbols
@@ -98,7 +99,7 @@ getDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [(Location,
9899
getDefinition file pos = runMaybeT $ do
99100
ide@ShakeExtras{ withHieDb, hiedbWriter } <- ask
100101
opts <- liftIO $ getIdeOptionsIO ide
101-
(HAR _ hf _ _ _, mapping) <- useWithStaleFastMT GetHieAst file
102+
(hf, mapping) <- useWithStaleFastMT GetHieAst file
102103
(ImportMap imports, _) <- useWithStaleFastMT GetImportMap file
103104
!pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
104105
locationsWithIdentifier <- AtPoint.gotoDefinition withHieDb (lookupMod hiedbWriter) opts imports hf pos'
@@ -120,6 +121,15 @@ getTypeDefinition file pos = runMaybeT $ do
120121
pure $ Just (fixedLocation, identifier)
121122
) locationsWithIdentifier
122123

124+
getImplementationDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [Location])
125+
getImplementationDefinition file pos = runMaybeT $ do
126+
ide@ShakeExtras{ withHieDb, hiedbWriter } <- ask
127+
opts <- liftIO $ getIdeOptionsIO ide
128+
(hf, mapping) <- useWithStaleFastMT GetHieAst file
129+
!pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
130+
locs <- AtPoint.gotoImplementation withHieDb (lookupMod hiedbWriter) opts hf pos'
131+
traverse (MaybeT . toCurrentLocation mapping file) locs
132+
123133
highlightAtPoint :: NormalizedFilePath -> Position -> IdeAction (Maybe [DocumentHighlight])
124134
highlightAtPoint file pos = runMaybeT $ do
125135
(HAR _ hf rf _ _,mapping) <- useWithStaleFastMT GetHieAst file

ghcide/src/Development/IDE/LSP/HoverDefinition.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Development.IDE.LSP.HoverDefinition
1010
, foundHover
1111
, gotoDefinition
1212
, gotoTypeDefinition
13+
, gotoImplementation
1314
, documentHighlight
1415
, references
1516
, wsSymbols
@@ -47,9 +48,11 @@ instance Pretty Log where
4748
gotoDefinition :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (MessageResult Method_TextDocumentDefinition)
4849
hover :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (Hover |? Null)
4950
gotoTypeDefinition :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (MessageResult Method_TextDocumentTypeDefinition)
51+
gotoImplementation :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (MessageResult Method_TextDocumentImplementation)
5052
documentHighlight :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) ([DocumentHighlight] |? Null)
51-
gotoDefinition = request "Definition" getDefinition (InR $ InR Null) (InL . Definition. InR . map fst)
52-
gotoTypeDefinition = request "TypeDefinition" getTypeDefinition (InR $ InR Null) (InL . Definition. InR . map fst)
53+
gotoDefinition = request "Definition" getDefinition (InR $ InR Null) (InL . Definition . InR . map fst)
54+
gotoTypeDefinition = request "TypeDefinition" getTypeDefinition (InR $ InR Null) (InL . Definition . InR . map fst)
55+
gotoImplementation = request "Implementation" getImplementationDefinition (InR $ InR Null) (InL . Definition . InR)
5356
hover = request "Hover" getAtPoint (InR Null) foundHover
5457
documentHighlight = request "DocumentHighlight" highlightAtPoint (InR Null) InL
5558

ghcide/src/Development/IDE/Plugin/HLS/GhcIde.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ descriptor recorder plId = (defaultPluginDescriptor plId desc)
5151
Hover.gotoDefinition recorder ide TextDocumentPositionParams{..})
5252
<> mkPluginHandler SMethod_TextDocumentTypeDefinition (\ide _ TypeDefinitionParams{..} ->
5353
Hover.gotoTypeDefinition recorder ide TextDocumentPositionParams{..})
54+
<> mkPluginHandler SMethod_TextDocumentImplementation (\ide _ ImplementationParams{..} ->
55+
Hover.gotoImplementation recorder ide TextDocumentPositionParams{..})
5456
<> mkPluginHandler SMethod_TextDocumentDocumentHighlight (\ide _ DocumentHighlightParams{..} ->
5557
Hover.documentHighlight recorder ide TextDocumentPositionParams{..})
5658
<> mkPluginHandler SMethod_TextDocumentReferences (Hover.references recorder)

0 commit comments

Comments
 (0)