Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to generate definitions from declarations and vice versa #664

Closed
benjaminjack opened this issue Apr 26, 2017 · 53 comments
Closed
Assignees
Labels
Feature: Code Generation Feature Request fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@benjaminjack
Copy link

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.

@BrianSipple
Copy link

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.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Dec 14, 2018

@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 #3056, we should also support the "opposite" case of adding the declaration to the header from an existing definition.

@bobbrow
Copy link
Member

bobbrow commented Dec 14, 2018

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

@daranday
Copy link

Would love to have this feature!

@davidbitton
Copy link

Upvote!

@exocode
Copy link

exocode commented Jun 3, 2019

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

@davidbitton
Copy link

@exocode yep! your work?

@bobbrow bobbrow modified the milestones: Triage, Backlog Jun 3, 2019
@yannickbt64
Copy link

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

@ArcticLampyrid
Copy link

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

@sean-mcmanus sean-mcmanus modified the milestones: Backlog, On Deck Sep 9, 2019
@sean-mcmanus
Copy link
Collaborator

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

@rafaelchen
Copy link

it would be really useful feature :)

@PoetaKodu
Copy link

I would love that!

@exocode
Copy link

exocode commented Nov 7, 2019

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

@dbsxdbsx
Copy link

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

@Flamefire
Copy link

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.

@sean-mcmanus sean-mcmanus removed this from In progress in 1.10 Jun 8, 2022
@Colengms Colengms added this to Triage in 1.12 via automation Jul 25, 2022
@Colengms Colengms removed this from In progress in 1.11 Jul 25, 2022
@Colengms Colengms moved this from Triage to In progress in 1.12 Jul 25, 2022
@bobbrow bobbrow added this to Triage in 1.13 via automation Aug 18, 2022
@bobbrow bobbrow moved this from Triage to In Progress in 1.13 Aug 23, 2022
@bobbrow bobbrow removed this from In progress in 1.12 Aug 23, 2022
@sean-mcmanus sean-mcmanus modified the milestones: On Deck, 1.13.4 Nov 1, 2022
@bobbrow bobbrow moved this from In Progress to Done in 1.13 Nov 15, 2022
@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Nov 18, 2022
@bobbrow
Copy link
Member

bobbrow commented Nov 18, 2022

This feature is available for preview. Switch to the prerelease version of the C/C++ extension to install version 1.13.4 and give it a try. There are a few known issues with the first implementation documented here: https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.4.

@khlebnikov
Copy link

Filed an issue related to the new functionality: #10189

@bobbrow
Copy link
Member

bobbrow commented Nov 28, 2022

@khlebnikov thanks! We're looking into it.

@tirupatihemanth
Copy link

tirupatihemanth commented Dec 22, 2022

Hello! Is this feature released for the general public?
i.e the ability to generate definitions of methods/classes from declarations/function calls etc.,

@pfeerick
Copy link

pfeerick commented Dec 22, 2022

@tirupatihemanth Please read #664 (comment)

First release version of the extension to include it was https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.6, and https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.8 is the current latest version of the extension.

@tirupatihemanth
Copy link

@pfeerick Thank you for the reply. I have the v1.13.8 of cpp extension. I am using gcc compiler on the windows machine.
I still couldn't seem to activate this feature. I call a function in a method which hasn't been written yet. Now when I type
"Ctrl+." which brings up quickfix I don't see a suggestion to generate the method. How do I activate this feature?

@sean-mcmanus
Copy link
Collaborator

@tirupatihemanth Do you see the "..." under the start of the declaration of the methods that aren't implemented yet? Like in this screenshot?

image

@tirupatihemanth
Copy link

@sean-mcmanus Yes I get that for function declarations in a class.
Say If I call a function func2(); from main() function or any other global function then it doesn't suggest to generate the definition. It would be super useful if it can do that.

@sean-mcmanus
Copy link
Collaborator

@tirupatihemanth The feature works for you on a function declaration, right? It doesn't work when on a usage of a function that is not defined because our parser will see the identifier as just being undefined.

@tirupatihemanth
Copy link

@sean-mcmanus Yes it works for function declarations. It would be super useful if it suggests to generate definition of an undefined function on usage.
It works on visual studio this way for c#. Hope this feature comes to vscode for cpp.
Thank you,
Happy New Year

@sean-mcmanus
Copy link
Collaborator

@Mulf
Copy link

Mulf commented Jan 19, 2023

Other than genenrating function definition one by one, we need to generate a whole cpp files from the header. i.e. After we finish the declaration of a class or some functions in .h, we can create a .cpp with those definitions there. The extention c/c++ definition generator extenstion implements some functions, but far away from perfect.

It would be great if cpptool adding such a feature.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2023
@sean-mcmanus
Copy link
Collaborator

@Mulf Your suggested feature request is being tracked in #10414 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature: Code Generation Feature Request fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
No open projects
Development

No branches or pull requests