@@ -6,12 +6,16 @@ module Ide.Plugin.Core(descriptor, CoreLog) where
6
6
import Control.Monad.IO.Class (liftIO )
7
7
import Data.Maybe (fromMaybe )
8
8
import Data.Text (Text )
9
+ import qualified Data.Text as T
9
10
import Development.IDE
10
- import Development.IDE.Core.Actions (workspaceSymbols )
11
+ import Development.IDE.Core.Actions (refsAtPoint , workspaceSymbols )
11
12
import qualified Development.IDE.Core.Shake as Shake
13
+ import Ide.Plugin.Error (getNormalizedFilePathE )
12
14
import Ide.Types
13
15
import Language.LSP.Protocol.Message
14
- import Language.LSP.Protocol.Types (WorkspaceSymbolParams (.. ),
16
+ import Language.LSP.Protocol.Types (ReferenceParams (.. ),
17
+ TextDocumentIdentifier (.. ),
18
+ WorkspaceSymbolParams (.. ),
15
19
type (|? ) (InL ))
16
20
17
21
data CoreLog
@@ -29,11 +33,23 @@ descriptor :: Recorder (WithPriority CoreLog) -> PluginId -> PluginDescriptor Id
29
33
descriptor recorder plId =
30
34
(defaultPluginDescriptor plId " Provides core IDE features for Haskell" )
31
35
{
32
- Ide.Types. pluginHandlers = mkPluginHandler SMethod_WorkspaceSymbol (wsSymbols recorder)
36
+ Ide.Types. pluginHandlers =
37
+ mkPluginHandler SMethod_WorkspaceSymbol (wsSymbols recorder)
38
+ <> mkPluginHandler SMethod_TextDocumentReferences references
33
39
}
34
40
35
41
36
42
wsSymbols :: Recorder (WithPriority CoreLog ) -> PluginMethodHandler IdeState Method_WorkspaceSymbol
37
43
wsSymbols logger ide _ (WorkspaceSymbolParams _ _ query) = liftIO $ do
38
44
logWith logger Debug $ CoreLogMsg $ " Workspace symbols request: " <> query
39
45
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