Skip to content

Commit aa17b82

Browse files
committed
Provide symbols from ghcide too
1 parent 1aae2cf commit aa17b82

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

src/Ide/Plugin.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ makeSymbols sps lf ideState params
448448
si = SymbolInformation name' (ds ^. kind) (ds ^. deprecated) loc parent
449449
in [si] <> children'
450450

451-
mhs <- mapM (\(_,p) -> p ideState params) sps
451+
mhs <- mapM (\(_,p) -> p lf ideState params) sps
452452
case rights mhs of
453453
[] -> return $ Left $ responseError $ T.pack $ show $ lefts mhs
454454
hs -> return $ Right $ convertSymbols $ concat hs

src/Ide/Plugin/Example.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ logAndRunRequest label getResults ide pos path = do
194194
-- ---------------------------------------------------------------------
195195

196196
symbols :: SymbolsProvider
197-
symbols _ide (DocumentSymbolParams _doc _mt)
197+
symbols _lf _ide (DocumentSymbolParams _doc _mt)
198198
= pure $ Right [r]
199199
where
200200
r = DocumentSymbol name detail kind deprecation range selR chList

src/Ide/Plugin/Example2.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ logAndRunRequest label getResults ide pos path = do
191191
-- ---------------------------------------------------------------------
192192

193193
symbols :: SymbolsProvider
194-
symbols _ide (DocumentSymbolParams _doc _mt)
194+
symbols _lf _ide (DocumentSymbolParams _doc _mt)
195195
= pure $ Right [r]
196196
where
197197
r = DocumentSymbol name detail kind deprecation range selR chList

src/Ide/Plugin/GhcIde.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ module Ide.Plugin.GhcIde
88
import Data.Aeson
99
import Development.IDE.Core.Service
1010
import Development.IDE.LSP.HoverDefinition
11+
import Development.IDE.LSP.Outline
1112
import Development.IDE.Plugin.CodeAction
1213
import Development.IDE.Types.Logger
14+
import Ide.Plugin
1315
import Ide.Types
1416
import Language.Haskell.LSP.Types
1517
import Text.Regex.TDFA.Text()
@@ -25,7 +27,7 @@ descriptor plId = PluginDescriptor
2527
, pluginCodeLensProvider = Just codeLens'
2628
, pluginDiagnosticProvider = Nothing
2729
, pluginHoverProvider = Just hover'
28-
, pluginSymbolsProvider = Nothing
30+
, pluginSymbolsProvider = Just symbolsProvider
2931
, pluginFormattingProvider = Nothing
3032
, pluginCompletionProvider = Nothing
3133
}
@@ -54,3 +56,14 @@ codeLens' :: CodeLensProvider
5456
codeLens' lf ide _ params = codeLens lf ide params
5557

5658
-- ---------------------------------------------------------------------
59+
60+
symbolsProvider :: SymbolsProvider
61+
symbolsProvider ls ide params = do
62+
ds <- moduleOutline ls ide params
63+
case ds of
64+
Right (DSDocumentSymbols (List ls)) -> return $ Right ls
65+
Right (DSSymbolInformation (List _si)) ->
66+
return $ Left $ responseError "GhcIde.symbolsProvider: DSSymbolInformation deprecated"
67+
Left err -> return $ Left err
68+
69+
-- ---------------------------------------------------------------------

src/Ide/Types.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ data DiagnosticTrigger = DiagnosticOnOpen
132132
-- type HoverProvider = Uri -> Position -> IO (Either ResponseError [Hover])
133133
type HoverProvider = IdeState -> TextDocumentPositionParams -> IO (Either ResponseError (Maybe Hover))
134134

135-
type SymbolsProvider = IdeState
135+
type SymbolsProvider = LSP.LspFuncs Config
136+
-> IdeState
136137
-> DocumentSymbolParams
137138
-> IO (Either ResponseError [DocumentSymbol])
138139

0 commit comments

Comments
 (0)