Skip to content

Commit 21fb6a5

Browse files
mibu138mergify[bot]
authored andcommitted
Added support for clangd's SwitchSourceHeader feature.
1 parent c65849a commit 21fb6a5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ycmd/completers/cpp/clangd_completer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,24 @@ def GetCustomSubcommands( self ):
301301
'GetDocImprecise': (
302302
lambda self, request_data, args: self.GetDoc( request_data )
303303
),
304+
'SwitchSourceHeader': (
305+
lambda self, request_data, args: self.SwitchSourceHeader( request_data )
306+
),
304307
# To handle the commands below we need extensions to LSP. One way to
305308
# provide those could be to use workspace/executeCommand requset.
306309
# 'GetParent': (
307310
# lambda self, request_data, args: self.GetType( request_data )
308311
# )
309312
}
310313

314+
def SwitchSourceHeader( self, request_data ):
315+
request_id = self.GetConnection().NextRequestId()
316+
uri = lsp.FilePathToUri(request_data['filepath'])
317+
request = lsp.BuildRequest(request_id, "textDocument/switchSourceHeader", {"uri": uri})
318+
response = self.GetConnection().GetResponse(request_id, request, 30)
319+
filepath = lsp.UriToFilePath( response['result'] )
320+
return responses.BuildGoToResponse(filepath, 1, 1, "switch")
321+
311322

312323
def ShouldCompleteIncludeStatement( self, request_data ):
313324
column_codepoint = request_data[ 'column_codepoint' ] - 1

0 commit comments

Comments
 (0)