Vscode-cpptools: Add the ability to generate definitions from declarations and vice versa

Created on 27 Apr 2017  路  28Comments  路  Source: microsoft/vscode-cpptools

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.

Feature Request Code Generation Language Service

Most helpful comment

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

All 28 comments

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.

@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.

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

Would love to have this feature!

Upvote!

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 yep! your work?

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

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

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

it would be really useful feature :)

I would love that!

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

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

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.

this feature will be very useful

but, when this feature will be implemented?

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

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

+1

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 Great work.

@amir9480,nice work, and it would be better to add creating declaration. Anyway, good job!

Much needed feature! It will save a lot of time and effort. Waiting for it馃

@amir9480 thankyou so much

Waiting for it!

We began investigating this, but it won't likely be completed in time for the 0.30.0 milestone.

I would like the opposite feature. Auto generate a .hpp file on save(and update it every time saved). Would save a lot of time. Just use the same file path except use the .hpp extension. However this could be configured of course but it would be a sane default.

Was this page helpful?
0 / 5 - 0 ratings