Skip to content

Commit 67af1ea

Browse files
committed
Add window/showDocument
1 parent 950cc52 commit 67af1ea

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed

lsp-test/src/Language/LSP/Test/Parsing.hs

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ loggingNotification = named "Logging notification" $ satisfy shouldSkip
198198
shouldSkip (FromServerMess SWindowLogMessage _) = True
199199
shouldSkip (FromServerMess SWindowShowMessage _) = True
200200
shouldSkip (FromServerMess SWindowShowMessageRequest _) = True
201+
shouldSkip (FromServerMess SWindowShowDocument _) = True
201202
shouldSkip _ = False
202203

203204
-- | Matches a 'Language.LSP.Types.TextDocumentPublishDiagnostics'

lsp-test/src/Language/LSP/Test/Session.hs

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ runSessionMonad context state (Session session) = runReaderT (runStateT conduit
231231

232232
isLogNotification (ServerMessage (FromServerMess SWindowShowMessage _)) = True
233233
isLogNotification (ServerMessage (FromServerMess SWindowLogMessage _)) = True
234+
isLogNotification (ServerMessage (FromServerMess SWindowShowDocument _)) = True
234235
isLogNotification _ = False
235236

236237
watchdog :: ConduitM SessionMessage FromServerMessage (StateT SessionState (ReaderT SessionContext IO)) ()

lsp-types/src/Language/LSP/Types/Lens.hs

+2
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ makeFieldsNoPrefix ''TypeDefinitionClientCapabilities
342342
makeFieldsNoPrefix ''ShowMessageParams
343343
makeFieldsNoPrefix ''MessageActionItem
344344
makeFieldsNoPrefix ''ShowMessageRequestParams
345+
makeFieldsNoPrefix ''ShowDocumentParams
346+
makeFieldsNoPrefix ''ShowDocumentResult
345347
makeFieldsNoPrefix ''LogMessageParams
346348
makeFieldsNoPrefix ''ProgressParams
347349
makeFieldsNoPrefix ''WorkDoneProgressBeginParams

lsp-types/src/Language/LSP/Types/Message.hs

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ type family MessageParams (m :: Method f t) :: Type where
136136
-- Window
137137
MessageParams WindowShowMessage = ShowMessageParams
138138
MessageParams WindowShowMessageRequest = ShowMessageRequestParams
139+
MessageParams WindowShowDocument = ShowDocumentParams
139140
MessageParams WindowLogMessage = LogMessageParams
140141
-- Progress
141142
MessageParams WindowWorkDoneProgressCreate = WorkDoneProgressCreateParams
@@ -219,6 +220,7 @@ type family ResponseResult (m :: Method f Request) :: Type where
219220
-- Server
220221
-- Window
221222
ResponseResult WindowShowMessageRequest = Maybe MessageActionItem
223+
ResponseResult WindowShowDocument = ShowDocumentResult
222224
ResponseResult WindowWorkDoneProgressCreate = Empty
223225
-- Capability
224226
ResponseResult ClientRegisterCapability = Empty

lsp-types/src/Language/LSP/Types/Method.hs

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ data Method (f :: From) (t :: MethodType) where
9090
-- Window
9191
WindowShowMessage :: Method FromServer Notification
9292
WindowShowMessageRequest :: Method FromServer Request
93+
WindowShowDocument :: Method FromServer Request
9394
WindowLogMessage :: Method FromServer Notification
9495
WindowWorkDoneProgressCancel :: Method FromClient Notification
9596
WindowWorkDoneProgressCreate :: Method FromServer Request
@@ -167,6 +168,7 @@ data SMethod (m :: Method f t) where
167168

168169
SWindowShowMessage :: SMethod WindowShowMessage
169170
SWindowShowMessageRequest :: SMethod WindowShowMessageRequest
171+
SWindowShowDocument :: SMethod WindowShowDocument
170172
SWindowLogMessage :: SMethod WindowLogMessage
171173
SWindowWorkDoneProgressCreate :: SMethod WindowWorkDoneProgressCreate
172174
SWindowWorkDoneProgressCancel :: SMethod WindowWorkDoneProgressCancel
@@ -307,6 +309,7 @@ instance A.FromJSON SomeServerMethod where
307309
-- Window
308310
parseJSON (A.String "window/showMessage") = pure $ SomeServerMethod SWindowShowMessage
309311
parseJSON (A.String "window/showMessageRequest") = pure $ SomeServerMethod SWindowShowMessageRequest
312+
parseJSON (A.String "window/showDocument") = pure $ SomeServerMethod SWindowShowDocument
310313
parseJSON (A.String "window/logMessage") = pure $ SomeServerMethod SWindowLogMessage
311314
parseJSON (A.String "window/workDoneProgress/create") = pure $ SomeServerMethod SWindowWorkDoneProgressCreate
312315
parseJSON (A.String "$/progress") = pure $ SomeServerMethod SProgress
@@ -400,6 +403,7 @@ instance A.ToJSON (SMethod m) where
400403
-- Window
401404
toJSON SWindowShowMessage = A.String "window/showMessage"
402405
toJSON SWindowShowMessageRequest = A.String "window/showMessageRequest"
406+
toJSON SWindowShowDocument = A.String "window/showDocument"
403407
toJSON SWindowLogMessage = A.String "window/logMessage"
404408
toJSON SWindowWorkDoneProgressCreate = A.String "window/workDoneProgress/create"
405409
toJSON SProgress = A.String "$/progress"

lsp-types/src/Language/LSP/Types/Parsing.hs

+1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ splitClientMethod SCustomMethod{} = IsClientEither
267267
splitServerMethod :: SServerMethod m -> ServerNotOrReq m
268268
splitServerMethod SWindowShowMessage = IsServerNot
269269
splitServerMethod SWindowShowMessageRequest = IsServerReq
270+
splitServerMethod SWindowShowDocument = IsServerReq
270271
splitServerMethod SWindowLogMessage = IsServerNot
271272
splitServerMethod SWindowWorkDoneProgressCreate = IsServerReq
272273
splitServerMethod SProgress = IsServerNot

lsp-types/src/Language/LSP/Types/Window.hs

+43
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import qualified Data.Aeson as A
88
import Data.Aeson.TH
99
import Data.Text (Text)
1010
import Language.LSP.Types.Utils
11+
import Language.LSP.Types.Uri
12+
import Language.LSP.Types.Location
1113

1214
-- ---------------------------------------------------------------------
1315

@@ -62,6 +64,47 @@ deriveJSON lspOptions ''ShowMessageRequestParams
6264

6365
-- ---------------------------------------------------------------------
6466

67+
-- | Params to show a document.
68+
--
69+
-- @since 3.16.0
70+
data ShowDocumentParams =
71+
ShowDocumentParams {
72+
-- | The document uri to show.
73+
_uri :: Uri
74+
75+
-- | Indicates to show the resource in an external program.
76+
-- To show for example `https://code.visualstudio.com/`
77+
-- in the default WEB browser set `external` to `true`.
78+
, _external :: Maybe Bool
79+
80+
-- | An optional property to indicate whether the editor
81+
-- showing the document should take focus or not.
82+
-- Clients might ignore this property if an external
83+
-- program is started.
84+
, _takeFocus :: Maybe Bool
85+
86+
-- | An optional selection range if the document is a text
87+
-- document. Clients might ignore the property if an
88+
-- external program is started or the file is not a text
89+
-- file.
90+
, _selection :: Maybe Range
91+
} deriving (Show, Read, Eq)
92+
93+
deriveJSON lspOptions ''ShowDocumentParams
94+
95+
-- | The result of an show document request.
96+
--
97+
-- @since 3.16.0
98+
data ShowDocumentResult =
99+
ShowDocumentResult {
100+
-- | A boolean indicating if the show was successful.
101+
_success :: Bool
102+
} deriving (Show, Read, Eq)
103+
104+
deriveJSON lspOptions ''ShowDocumentResult
105+
106+
-- ---------------------------------------------------------------------
107+
65108
data LogMessageParams =
66109
LogMessageParams {
67110
_xtype :: MessageType

0 commit comments

Comments
 (0)