Skip to content

Commit

Permalink
Merge branch 'master' into feat-3183-gen_plugins_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
develop7 authored Oct 30, 2024
2 parents 475d762 + d923d82 commit fda2d80
Show file tree
Hide file tree
Showing 26 changed files with 613 additions and 63 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ jobs:
name: Test hls-splice-plugin
run: cabal test hls-splice-plugin-tests || cabal test hls-splice-plugin-tests

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

Expand Down
2 changes: 2 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
- CompletionTests #Previously part of GHCIDE Main tests
- DiagnosticTests #Previously part of GHCIDE Main tests
- FindDefinitionAndHoverTests #Previously part of GHCIDE Main tests
- FindImplementationAndHoverTests #Previously part of GHCIDE Main tests
- TestUtils #Previously part of GHCIDE Main tests
- CodeLensTests #Previously part of GHCIDE Main tests

Expand All @@ -134,6 +135,7 @@
- Ide.Plugin.Eval.Parse.Comments
- Ide.Plugin.Eval.CodeLens
- FindDefinitionAndHoverTests #Previously part of GHCIDE Main tests
- FindImplementationAndHoverTests #Previously part of GHCIDE Main tests

- name: [Prelude.init, Data.List.init]
within:
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages:
./hls-test-utils


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

tests: True
test-show-details: direct
Expand Down
18 changes: 18 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ Known limitations:

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

## Jump to implementation

Provided by: `ghcide`

Jump to the implementation instance of a type class method.

Known limitations:

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

## Jump to note definition

Provided by: `hls-notes-plugin`
Expand Down Expand Up @@ -316,6 +326,14 @@ Code action kind: `quickfix`

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

### Add dependency to `cabal` file

Provided by: `hls-cabal-plugin`

Code action kind: `quickfix`

Add a missing package dependency to your `.cabal` file.

## Code lenses

### Add type signature
Expand Down
2 changes: 1 addition & 1 deletion docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-overloaded-record-dot-plugin` | 2 | |
| `hls-semantic-tokens-plugin` | 2 | |
| `hls-floskell-plugin` | 3 | 9.10.1 |
| `hls-stan-plugin` | 3 | 9.10.1 |
| `hls-stan-plugin` | 3 | |
| `hls-retrie-plugin` | 3 | 9.10.1 |
| `hls-splice-plugin` | 3 | 9.10.1 |
12 changes: 11 additions & 1 deletion ghcide/src/Development/IDE/Core/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Development.IDE.Core.Actions
( getAtPoint
, getDefinition
, getTypeDefinition
, getImplementationDefinition
, highlightAtPoint
, refsAtPoint
, workspaceSymbols
Expand Down Expand Up @@ -98,7 +99,7 @@ getDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [(Location,
getDefinition file pos = runMaybeT $ do
ide@ShakeExtras{ withHieDb, hiedbWriter } <- ask
opts <- liftIO $ getIdeOptionsIO ide
(HAR _ hf _ _ _, mapping) <- useWithStaleFastMT GetHieAst file
(hf, mapping) <- useWithStaleFastMT GetHieAst file
(ImportMap imports, _) <- useWithStaleFastMT GetImportMap file
!pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
locationsWithIdentifier <- AtPoint.gotoDefinition withHieDb (lookupMod hiedbWriter) opts imports hf pos'
Expand All @@ -120,6 +121,15 @@ getTypeDefinition file pos = runMaybeT $ do
pure $ Just (fixedLocation, identifier)
) locationsWithIdentifier

getImplementationDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [Location])
getImplementationDefinition file pos = runMaybeT $ do
ide@ShakeExtras{ withHieDb, hiedbWriter } <- ask
opts <- liftIO $ getIdeOptionsIO ide
(hf, mapping) <- useWithStaleFastMT GetHieAst file
!pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
locs <- AtPoint.gotoImplementation withHieDb (lookupMod hiedbWriter) opts hf pos'
traverse (MaybeT . toCurrentLocation mapping file) locs

highlightAtPoint :: NormalizedFilePath -> Position -> IdeAction (Maybe [DocumentHighlight])
highlightAtPoint file pos = runMaybeT $ do
(HAR _ hf rf _ _,mapping) <- useWithStaleFastMT GetHieAst file
Expand Down
7 changes: 5 additions & 2 deletions ghcide/src/Development/IDE/LSP/HoverDefinition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Development.IDE.LSP.HoverDefinition
, foundHover
, gotoDefinition
, gotoTypeDefinition
, gotoImplementation
, documentHighlight
, references
, wsSymbols
Expand Down Expand Up @@ -47,9 +48,11 @@ instance Pretty Log where
gotoDefinition :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (MessageResult Method_TextDocumentDefinition)
hover :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (Hover |? Null)
gotoTypeDefinition :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (MessageResult Method_TextDocumentTypeDefinition)
gotoImplementation :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) (MessageResult Method_TextDocumentImplementation)
documentHighlight :: Recorder (WithPriority Log) -> IdeState -> TextDocumentPositionParams -> ExceptT PluginError (HandlerM c) ([DocumentHighlight] |? Null)
gotoDefinition = request "Definition" getDefinition (InR $ InR Null) (InL . Definition. InR . map fst)
gotoTypeDefinition = request "TypeDefinition" getTypeDefinition (InR $ InR Null) (InL . Definition. InR . map fst)
gotoDefinition = request "Definition" getDefinition (InR $ InR Null) (InL . Definition . InR . map fst)
gotoTypeDefinition = request "TypeDefinition" getTypeDefinition (InR $ InR Null) (InL . Definition . InR . map fst)
gotoImplementation = request "Implementation" getImplementationDefinition (InR $ InR Null) (InL . Definition . InR)
hover = request "Hover" getAtPoint (InR Null) foundHover
documentHighlight = request "DocumentHighlight" highlightAtPoint (InR Null) InL

Expand Down
2 changes: 2 additions & 0 deletions ghcide/src/Development/IDE/Plugin/HLS/GhcIde.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ descriptor recorder plId = (defaultPluginDescriptor plId desc)
Hover.gotoDefinition recorder ide TextDocumentPositionParams{..})
<> mkPluginHandler SMethod_TextDocumentTypeDefinition (\ide _ TypeDefinitionParams{..} ->
Hover.gotoTypeDefinition recorder ide TextDocumentPositionParams{..})
<> mkPluginHandler SMethod_TextDocumentImplementation (\ide _ ImplementationParams{..} ->
Hover.gotoImplementation recorder ide TextDocumentPositionParams{..})
<> mkPluginHandler SMethod_TextDocumentDocumentHighlight (\ide _ DocumentHighlightParams{..} ->
Hover.documentHighlight recorder ide TextDocumentPositionParams{..})
<> mkPluginHandler SMethod_TextDocumentReferences (Hover.references recorder)
Expand Down
Loading

0 comments on commit fda2d80

Please sign in to comment.