This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270516 - Create function declaration in .h when definition is created in .cpp file
Summary: Create function declaration in .h when definition is created in .cpp file
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Editor (show other bugs)
Version: Dev
Hardware: All All
: P2 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-28 16:39 UTC by antoniocs
Modified: 2017-05-01 18:18 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description antoniocs 2017-04-28 16:39:42 UTC
Hey,

Would it be possible to have netbeans generate the function declaration when I create a class function in the cpp file?

So for example in class.cpp I create this:

void classname::func() {
}

Then netbeans can have something that generates the declaration in the .h file (normally it's the same name as the class file but with .h or hpp)

So this would be generated:

void func();

This would have to be set in either the public, private or protected blocks.

Would this be possible to add?
Comment 1 Vladimir Voskresensky 2017-04-28 17:41:12 UTC
Hello Antonio,

yes, it is possible to implement. Thanks for the enhancement report.
For now I can recommend to use reverse steps:
- declare method foo (in appropriate private/protected/public section) in header inside class
- switch to source file (Ctrl+Shift+A)
- invoke code completion on empty line in file scope (between other methods)
- use "generate foo"
It saves quite a few time for me ;-)
Comment 2 Vladimir Voskresensky 2017-04-28 17:44:42 UTC
Btw,
http://wiki.netbeans.org/NewAndNoteworthyNB80#C.2FC.2B.2B
there is also  "Extract method body from class declaration"
Comment 3 antoniocs 2017-04-28 18:09:33 UTC
Thanks Vladimir Voskresensky. 

I never thought about doing it that way but I can see the benefits. (thanks also for the shortcut to switch between .h and .cpp and vice-versa).

Not sure how to utilize the "Extract method body from class declaration" feature you linked to. I always feel that for C++, netbeans is good IDE but the documentation/examples are always behind Java or PHP.

Thanks again.
Comment 4 Vladimir Voskresensky 2017-04-28 21:17:46 UTC
> Not sure how to utilize the "Extract method body from class declaration"
> feature you linked to. 
I use it when inline-method in class body grows from one line to multiple, i.e. impl need to use declarations which were not in #include sections for header, but now are needed for impl.
So just go to source and extract body... then add #include only in source file reducing (re)compilation time.