ycmd icon indicating copy to clipboard operation
ycmd copied to clipboard

Switch source header

Open mibu138 opened this issue 3 years ago • 6 comments

Implements clangd's SwitchSourceHeader feature. Currenly issued as a GoTo response that will jump to the first line and column of the corresponding header/source of the current buffer.


This change is Reviewable

mibu138 avatar Jan 03 '22 18:01 mibu138

The main reasons for choosing SwitchSourceHeader are:

  1. It maps directly to the clangd command name https://code.woboq.org/llvm/clang-tools-extra/clangd/ClangdLSPServer.h.html#130 Note that clangd also has commands of the GoTo* style, and it has decided against using that form for jumping to the source/header file.

  2. It is more explicit than GoToAssociatedFile.

There are plusses and minusses to explicitness of course. The looseness of GoToAssociatedFile means that command could be repurposed for other types of jumps in other languages. The downside is if there ever came about another kind of jump in C/C++, that is if we had some notion of an associated file that is not the corresponding source or header and a server that can allow us to jump to it, then we would not be able to simple use GoToAssociatedFile for that. What might the associated file be if not the source or header? I don't know. Perhaps C++ 20 modules will have some need for something like that (or not, I am not read up on them) or a future version of the language.

But I'm not completely against GoToAssociatedFile either. Just wanted to raise my rationale.

mibu138 avatar Jan 09 '22 18:01 mibu138

I believe I've made all changes except for the name change to GoToAssociatedFile in e01b536f081aac73aa12c490553b059b8a3af46b If you still feel it should be GoToAssociatedFile given my rational above, then I'll go ahead and make that change as well.

mibu138 avatar Jan 09 '22 18:01 mibu138

Thanks for the updates! Looking good. Just a few style nits things to tidy up, and I think the tests are failing in CI ?

puremourning avatar Jan 23 '22 18:01 puremourning

@MergifyIO rebase

puremourning avatar Aug 13 '22 15:08 puremourning

rebase

✅ Branch has been successfully rebased

mergify[bot] avatar Aug 13 '22 15:08 mergify[bot]

tests are failing

puremourning avatar Aug 13 '22 16:08 puremourning

Seems abandoned.

puremourning avatar Sep 29 '22 19:09 puremourning

@mergifyio rebase

puremourning avatar Jan 03 '23 09:01 puremourning

rebase

☑️ Nothing to do

  • [ ] -closed [:pushpin: rebase requirement]

mergify[bot] avatar Jan 03 '23 10:01 mergify[bot]

@mergifyio rebase

puremourning avatar Jan 03 '23 10:01 puremourning

⚠️ This pull request got rebased on behalf of a random user of the organization. This behavior will change on the 1st February 2022, Mergify will pick the author of the pull request instead.

To get the future behavior now, you can configure bot_account options (e.g.: bot_account: { author } or update_bot_account: { author }.

Or you can create a dedicated github account for squash and rebase operations, and use it in different bot_account options.

mergify[bot] avatar Jan 03 '23 10:01 mergify[bot]

rebase

✅ Branch has been successfully rebased

mergify[bot] avatar Jan 03 '23 10:01 mergify[bot]

I believe these tests could be fixed by the following changes. Unfortunately I'm not allowed to post these changes as a "suggestion" nor test them locally but maybe you'll want to give it a try.

--- ycmd/tests/clang/subcommands_test.py
+++ ycmd/tests/clang/subcommands_test.py
@@ -56,6 +56,7 @@ def RunGoToTest_all( app, filename, command, test ):
   }
   common_response = {
     'filepath': os.path.abspath( PathToTestFile( filename ) ),
+    'file_only': False,
   }

   if 'extra_conf' in test:
@@ -103,6 +104,7 @@ def RunGoToIncludeTest( app, command, test ):
     'filepath'   : PathToTestFile( 'test-include', test[ 'response' ] ),
     'line_num'   : 1,
     'column_num' : 1,
+    'file_only'  : False,
   }

xpac27 avatar Jan 03 '23 12:01 xpac27

Thanks @xpac27 - I've pushed that change. let's see.

puremourning avatar Jan 03 '23 12:01 puremourning

Codecov Report

Merging #1623 (7dfda1c) into master (c65849a) will decrease coverage by 0.02%. The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1623      +/-   ##
==========================================
- Coverage   95.47%   95.45%   -0.03%     
==========================================
  Files          90       90              
  Lines        8156     8164       +8     
  Branches      164      164              
==========================================
+ Hits         7787     7793       +6     
- Misses        318      320       +2     
  Partials       51       51              

codecov[bot] avatar Jan 03 '23 14:01 codecov[bot]

Thanks for sending a PR!

mergify[bot] avatar Jan 03 '23 14:01 mergify[bot]