5

C++ Extension in VS Code 1.16 Release: Call Hierarchy & more

 1 year ago
source link: https://devblogs.microsoft.com/cppblog/c-extension-in-vs-code-1-16-release-call-hierarchy-more/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C++ Extension in VS Code 1.16 Release: Call Hierarchy & more

PXL_20220327_210111658.PORTRAIT_cropped3-96x96.jpg

Alexandra Kemper

June 28th, 20230 2

The 1.16 version of the C++ Extension in VS Code has now been shipped. With this version of the extension, we are releasing one of our most upvoted GitHub feature requests – Call Hierarchy. We also added new functionality when creating declarations and definitions that allows you to copy the declaration/definition and specify its placement in code, as well as adding other code enhancements. For the full list of changes, please reference the 1.16 release notes.  

Call Hierarchy  

With call hierarchy, you can now easily navigate your codebase, especially when trying to understand the complex calling relationships between functions. This might be a familiar experience if you have used call hierarchy in Visual Studio. Here you can see it in action:  

How can you view the call hierarchy?  

To view the call hierarchy, right-click a function to display the context menu and select Show Call Hierarchy. This will populate the call tree in the side bar with all of the functions called by your selected function. Toggle the phone icon in the side bar menu to switch to incoming calls. Incoming calls will show whenever your function is referenced by another function.

Image showing that the command in the context menu to look for is called

You can also invoke the command palette (Ctrl + Shift + P) and run the command Calls: Show Call Hierarchy to display the call hierarchy side bar.  

Image that shows that the command for call hierarchy in the command palette is called

Additionally, you can explore nested calls by selecting a function already shown in the call tree and right-clicking on that function to view the available commands.

Image shows that if you right click on a function displayed in the call hierarchy call tree, you will be able access another menu which gives you the option to find incoming/outgoing calls for that sub function

Copy Declaration/Definition 

After releasing the Create Declaration/Definition feature in version 1.13.6, you can now also copy that declaration or definition. Rather than using “Create Declaration/Definition” to automatically add a generated declaration or definition to a location chosen by the extension, “Copy Declaration/Definition” will copy the declaration or definition to your clipboard instead. This gives you the option to decide where exactly in your code you would like to paste the copied declaration or definition.   

To copy a definition or declaration, select a function that has a Quick Fix available (three dots under the function name), then select the Code Action (lightbulb icon) on the left. This will open the Code Action options, where you can select “Copy definition of ‘YourFunctionName’” or “Copy declaration of ‘YourFunctionName’” depending on which is being created.  

If the Declaration/Definition is not formatted for you when you paste, you can turn on auto formatting by navigating to the settings editor (Ctrl + ,) and searching for Format On Paste. Enabling this will automatically formal all items you paste into the editor.     

What do you think?  

Download the C/C++ extension for Visual Studio Code  today, give it a try, and let us know what you think.  

If you have any questions around this release, feel free to start a discussion in our GitHub repository. Otherwise, if you run into any issues, please report them in the  issues section. We can be reached via the comments below, per email at  [email protected], or through our team on Twitter at  @VisualC.  

Alexandra Kemper Product Manager, C++ Team

Follow


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK