-
Notifications
You must be signed in to change notification settings - Fork 98
Call hierarchy support #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ec01720
e95835b
a540245
6d165ed
cd501e5
4998fcc
ef59c28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
{- | Since LSP 3.16.0 -} | ||
module Language.LSP.Types.CallHierarchy where | ||
|
||
import Data.Aeson.TH | ||
import Data.Aeson.Types ( Value ) | ||
import Data.Text ( Text ) | ||
|
||
import Language.LSP.Types.Common | ||
import Language.LSP.Types.DocumentSymbol | ||
import Language.LSP.Types.Location | ||
import Language.LSP.Types.Progress | ||
import Language.LSP.Types.StaticRegistrationOptions | ||
import Language.LSP.Types.TextDocument | ||
import Language.LSP.Types.Uri | ||
import Language.LSP.Types.Utils | ||
|
||
|
||
data CallHierarchyClientCapabilities = | ||
CallHierarchyClientCapabilities | ||
{ _dynamicRegistration :: Maybe Bool } | ||
deriving (Show, Read, Eq) | ||
deriveJSON lspOptions ''CallHierarchyClientCapabilities | ||
|
||
makeExtendingDatatype "CallHierarchyOptions" [''WorkDoneProgressOptions] [] | ||
deriveJSON lspOptions ''CallHierarchyOptions | ||
|
||
makeExtendingDatatype "CallHierarchyRegistrationOptions" | ||
[ ''TextDocumentRegistrationOptions | ||
, ''CallHierarchyOptions | ||
, ''StaticRegistrationOptions | ||
] | ||
[] | ||
deriveJSON lspOptions ''CallHierarchyRegistrationOptions | ||
|
||
makeExtendingDatatype "CallHierarchyPrepareParams" | ||
[''TextDocumentPositionParams, ''WorkDoneProgressParams] [] | ||
deriveJSON lspOptions ''CallHierarchyPrepareParams | ||
|
||
data CallHierarchyItem = | ||
CallHierarchyItem | ||
{ _name :: Text | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we include haddock corresponding to the doc in the LSP spec for each item? Tedious, but matching the spec is a simple policy and more field documentation is almost always better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -- <https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_prepareCallHierarchy>
data CallHierarchyItem = ... Should it look like this? I have little knowledge about haddock. |
||
, _kind :: SymbolKind | ||
, _tags :: Maybe (List SymbolTag) | ||
-- | More detail for this item, e.g. the signature of a function. | ||
, _detail :: Maybe Text | ||
, _uri :: Uri | ||
, _range :: Range | ||
-- | The range that should be selected and revealed when this symbol | ||
-- is being picked, e.g. the name of a function. Must be contained by | ||
-- the @_range@. | ||
, _selectionRange :: Range | ||
-- | A data entry field that is preserved between a call hierarchy | ||
-- prepare and incoming calls or outgoing calls requests. | ||
, _xdata :: Maybe Value | ||
} | ||
deriving (Show, Read, Eq) | ||
deriveJSON lspOptions ''CallHierarchyItem | ||
|
||
-- ------------------------------------- | ||
|
||
makeExtendingDatatype "CallHierarchyIncomingCallsParams" | ||
[ ''WorkDoneProgressParams | ||
, ''PartialResultParams | ||
] | ||
[("_item", [t| CallHierarchyItem |])] | ||
deriveJSON lspOptions ''CallHierarchyIncomingCallsParams | ||
|
||
data CallHierarchyIncomingCall = | ||
CallHierarchyIncomingCall | ||
{ -- | The item that makes the call. | ||
_from :: CallHierarchyItem | ||
-- | The ranges at which the calls appear. This is relative to the caller | ||
-- denoted by @_from@. | ||
, _fromRanges :: List Range | ||
} | ||
deriving (Show, Read, Eq) | ||
deriveJSON lspOptions ''CallHierarchyIncomingCall | ||
|
||
-- ------------------------------------- | ||
|
||
makeExtendingDatatype "CallHierarchyOutgoingCallsParams" | ||
[ ''WorkDoneProgressParams | ||
, ''PartialResultParams | ||
] | ||
[("_item", [t| CallHierarchyItem |])] | ||
deriveJSON lspOptions ''CallHierarchyOutgoingCallsParams | ||
|
||
data CallHierarchyOutgoingCall = | ||
CallHierarchyOutgoingCall | ||
{ -- | The item that is called. | ||
_to :: CallHierarchyItem | ||
-- | The range at which this item is called. THis is the range relative to | ||
-- the caller, e.g the item passed to `callHierarchy/outgoingCalls` request. | ||
, _fromRanges :: List Range | ||
} | ||
deriving (Show, Read, Eq) | ||
deriveJSON lspOptions ''CallHierarchyOutgoingCall |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ | |||||||
|
||||||||
module Language.LSP.Types.Message where | ||||||||
|
||||||||
import Language.LSP.Types.CallHierarchy | ||||||||
import Language.LSP.Types.Cancellation | ||||||||
import Language.LSP.Types.CodeAction | ||||||||
import Language.LSP.Types.CodeLens | ||||||||
|
@@ -120,6 +121,10 @@ type family MessageParams (m :: Method f t) :: Type where | |||||||
MessageParams TextDocumentFoldingRange = FoldingRangeParams | ||||||||
-- Selection Range | ||||||||
MessageParams TextDocumentSelectionRange = SelectionRangeParams | ||||||||
-- Call hierarchy | ||||||||
MessageParams TextDocumentPrepareCallHierarchy = CallHierarchyPrepareParams | ||||||||
MessageParams CallHierarchyIncomingCalls = CallHierarchyIncomingCallsParams | ||||||||
MessageParams CallHierarchyOutgoingCalls = CallHierarchyOutgoingCallsParams | ||||||||
-- Server | ||||||||
-- Window | ||||||||
MessageParams WindowShowMessage = ShowMessageParams | ||||||||
|
@@ -193,6 +198,10 @@ type family ResponseResult (m :: Method f Request) :: Type where | |||||||
-- FoldingRange | ||||||||
ResponseResult TextDocumentFoldingRange = List FoldingRange | ||||||||
ResponseResult TextDocumentSelectionRange = List SelectionRange | ||||||||
-- Call hierarchy | ||||||||
ResponseResult TextDocumentPrepareCallHierarchy = Maybe (List CallHierarchyItem) | ||||||||
ResponseResult CallHierarchyIncomingCalls = Maybe (List CallHierarchyIncomingCall) | ||||||||
ResponseResult CallHierarchyOutgoingCalls = Maybe (List CallHierarchyOutgoingCall) | ||||||||
Comment on lines
+202
to
+204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the ResponseResult TextDocumentCallHierarchy = List CallHierarchyItem
ResponseResult CallHierarchyIncomingCalls = List CallHierarchyIncomingCall
ResponseResult CallHierarchyOutgoingCalls = List CallHierarchyOutgoingCall
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just keep it to satisfy the spec. And I still notice that we have several dealings about
Maybe we need to unify them under one specific rule. |
||||||||
-- Custom can be either a notification or a message | ||||||||
-- Server | ||||||||
-- Window | ||||||||
|
Uh oh!
There was an error while loading. Please reload this page.