vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Add the ability to generate definitions from declarations and vice versa

Open benjaminjack opened this issue 9 years ago • 53 comments

I spend a lot of time typing out lists of arguments (or copying and pasting them) when I'm defining functions that have already been declared in a header file. It would be nice if cpptools could automatically generate a skeleton definition of a function that has already been declared, or at least provide a shortcut to auto-fill the argument list.

benjaminjack avatar Apr 26 '17 23:04 benjaminjack

I was going to suggest something very similar. I'd also be interested in a feature to create a header- and source-file pair with a single task invocation. This would be similar to XCode, for example, which generates both a .h and .cpp file when the user selects an option to create a new class file.

BrianSipple avatar Sep 19 '17 07:09 BrianSipple

@bobbrow I believe this is the most used feature in VS that we are missing (used more often than Find All References).

As mentioned in https://github.com/Microsoft/vscode-cpptools/issues/3056, we should also support the "opposite" case of adding the declaration to the header from an existing definition.

sean-mcmanus avatar Dec 14 '18 01:12 sean-mcmanus

Yeah, I have seen this feedback a few times in our survey responses. It is on my radar.

bobbrow avatar Dec 14 '18 17:12 bobbrow

Would love to have this feature!

daranday avatar Feb 20 '19 18:02 daranday

Upvote!

davidbitton avatar Apr 29 '19 22:04 davidbitton

Is this something you are looking for?:

It is able to preserve existing methods and inclusions

2019-06-03 12 55 16

https://github.com/reignofwebber/vscode-c-cpp-definition-generator

exocode avatar Jun 03 '19 10:06 exocode

@exocode yep! your work?

davidbitton avatar Jun 03 '19 13:06 davidbitton

Can't wait to have this implemented. Such a basic feature, yet very useful.

yannickbt64 avatar Aug 05 '19 18:08 yannickbt64

Can't wait to use it. Do we have any plan to implement it?

ArcticLampyrid avatar Sep 08 '19 03:09 ArcticLampyrid

@1354092549 Yes, but we don't have it on our schedule yet.

sean-mcmanus avatar Sep 09 '19 23:09 sean-mcmanus

it would be really useful feature :)

rafaelchen avatar Oct 14 '19 13:10 rafaelchen

I would love that!

PoetaKodu avatar Nov 07 '19 20:11 PoetaKodu

@davidbitton sorry, no.. some other genius did that for all of us :-)

exocode avatar Nov 07 '19 21:11 exocode

Just upVote it, and it woud be better to have it with funcitonality like "changing signature".

dbsxdbsx avatar Nov 30 '19 11:11 dbsxdbsx

Very related: Move implementation to source file (possibly creating it) which not only generates the signature but also moves the implementation from header to source.

Flamefire avatar Dec 03 '19 08:12 Flamefire

this feature will be very useful

but, when this feature will be implemented?

asynchronoust avatar Dec 05 '19 07:12 asynchronoust

@asynchronoust It's scheduled for post-v1, which would be some time (not early) next year (no guarantees though).

sean-mcmanus avatar Dec 06 '19 02:12 sean-mcmanus

It would also be nice to have similar auto-generation for the initializer list in a class constructor.

victorvianna avatar Dec 21 '19 02:12 victorvianna

+1

stonedreamforest avatar Feb 22 '20 14:02 stonedreamforest

I also created an extension for generating implementations last week. With namespace, nested class/namespace, classes with templates and methods with templates support.

screenshot

amir9480/vscode-cpp-helper

https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.cpp-helper

amir9480 avatar Feb 28 '20 18:02 amir9480