1-- Copyright (c) 2019 The DAML Authors. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
5-- | Go to the definition of a variable.
6module Development.IDE.LSP.Definition
7 ( setHandlersDefinition
10import Language.Haskell.LSP.Types
11import Development.IDE.Types.Location
13import Development.IDE.Types.Logger
14import Development.IDE.Core.Rules
15import Development.IDE.Core.Service
16import Development.IDE.LSP.Server
17import qualified Language.Haskell.LSP.Core as LSP
18import Language.Haskell.LSP.Messages
20import qualified Data.Text as T
22-- | Go to the definition of a variable.
25 -> TextDocumentPositionParams
26 -> IO LocationResponseParams
27gotoDefinition ide (TextDocumentPositionParams (TextDocumentIdentifier uri) pos) = do
28 mbResult <- case uriToFilePath' uri of
30 logInfo (ideLogger ide) $
31 "Definition request at position " <> T.pack (showPosition pos) <>
32 " in file: " <> T.pack path
33 runAction ide $ getDefinition (toNormalizedFilePath path) pos
34 Nothing -> pure Nothing
35 pure $ case mbResult of
36 Nothing -> MultiLoc []
37 Just loc -> SingleLoc loc
40setHandlersDefinition :: PartialHandlers
41setHandlersDefinition = PartialHandlers $ \WithMessage{..} x -> return x{
42 LSP.definitionHandler = withResponse RspDefinition $ const gotoDefinition
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list