Skip to content

Commit 8be4c54

Browse files
committed
move references out
1 parent 0b050bc commit 8be4c54

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Development.IDE.LSP.HoverDefinition
1010
, gotoDefinition
1111
, gotoTypeDefinition
1212
, documentHighlight
13-
, references
13+
-- , references
1414
-- , wsSymbols
1515
) where
1616

@@ -39,14 +39,6 @@ gotoTypeDefinition = request "TypeDefinition" getTypeDefinition (InR $ InR Null)
3939
hover = request "Hover" getAtPoint (InR Null) foundHover
4040
documentHighlight = request "DocumentHighlight" highlightAtPoint (InR Null) InL
4141

42-
references :: PluginMethodHandler IdeState Method_TextDocumentReferences
43-
references ide _ (ReferenceParams (TextDocumentIdentifier uri) pos _ _ _) = do
44-
nfp <- getNormalizedFilePathE uri
45-
liftIO $ logDebug (ideLogger ide) $
46-
"References request at position " <> T.pack (showPosition pos) <>
47-
" in file: " <> T.pack (show nfp)
48-
InL <$> (liftIO $ runAction "references" ide $ refsAtPoint nfp pos)
49-
5042

5143
foundHover :: (Maybe Range, [T.Text]) -> Hover |? Null
5244
foundHover (mbRange, contents) =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ descriptor plId = (defaultPluginDescriptor plId desc)
5151
gotoTypeDefinition ide TextDocumentPositionParams{..})
5252
<> mkPluginHandler SMethod_TextDocumentDocumentHighlight (\ide _ DocumentHighlightParams{..} ->
5353
documentHighlight ide TextDocumentPositionParams{..})
54-
<> mkPluginHandler SMethod_TextDocumentReferences references,
54+
,
5555

5656
pluginConfigDescriptor = defaultConfigDescriptor
5757
}

plugins/hls-core-plugin/src/Ide/Plugin/Core.hs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ module Ide.Plugin.Core(descriptor, CoreLog) where
66
import Control.Monad.IO.Class (liftIO)
77
import Data.Maybe (fromMaybe)
88
import Data.Text (Text)
9+
import qualified Data.Text as T
910
import Development.IDE
10-
import Development.IDE.Core.Actions (workspaceSymbols)
11+
import Development.IDE.Core.Actions (refsAtPoint, workspaceSymbols)
1112
import qualified Development.IDE.Core.Shake as Shake
13+
import Ide.Plugin.Error (getNormalizedFilePathE)
1214
import Ide.Types
1315
import Language.LSP.Protocol.Message
14-
import Language.LSP.Protocol.Types (WorkspaceSymbolParams (..),
16+
import Language.LSP.Protocol.Types (ReferenceParams (..),
17+
TextDocumentIdentifier (..),
18+
WorkspaceSymbolParams (..),
1519
type (|?) (InL))
1620

1721
data CoreLog
@@ -29,11 +33,23 @@ descriptor :: Recorder (WithPriority CoreLog) -> PluginId -> PluginDescriptor Id
2933
descriptor recorder plId =
3034
(defaultPluginDescriptor plId "Provides core IDE features for Haskell")
3135
{
32-
Ide.Types.pluginHandlers = mkPluginHandler SMethod_WorkspaceSymbol (wsSymbols recorder)
36+
Ide.Types.pluginHandlers =
37+
mkPluginHandler SMethod_WorkspaceSymbol (wsSymbols recorder)
38+
<> mkPluginHandler SMethod_TextDocumentReferences references
3339
}
3440

3541

3642
wsSymbols :: Recorder (WithPriority CoreLog) -> PluginMethodHandler IdeState Method_WorkspaceSymbol
3743
wsSymbols logger ide _ (WorkspaceSymbolParams _ _ query) = liftIO $ do
3844
logWith logger Debug $ CoreLogMsg $ "Workspace symbols request: " <> query
3945
runIdeAction "WorkspaceSymbols" (shakeExtras ide) $ InL . fromMaybe [] <$> workspaceSymbols query
46+
47+
48+
49+
references :: PluginMethodHandler IdeState Method_TextDocumentReferences
50+
references ide _ (ReferenceParams (TextDocumentIdentifier uri) pos _ _ _) = do
51+
nfp <- getNormalizedFilePathE uri
52+
liftIO $ logDebug (ideLogger ide) $
53+
"References request at position " <> T.pack (showPosition pos) <>
54+
" in file: " <> T.pack (show nfp)
55+
InL <$> (liftIO $ runAction "references" ide $ refsAtPoint nfp pos)

0 commit comments

Comments
 (0)