Eclipse CDT method auto generation support - eclipse-cdt

When using other IDEs, I usually type non-existent methods which gives an unresolved method/variable error. In the screenshot below, the method Arrangement::check for the specific arguments does not exist. I was hoping to generate this method declaration automatically now after this.
Usually other IDEs gives me an option to create methods to resolve that error (This this there in IntelliJ Idea as well as Eclipse JDT, IIRC), but in Eclipse CDT, if I type in a non-existent method it gives me an error but without any way of auto generating the missing method. Now, if I press Cmd+1 on this error, I only see two options "Rename in File" or "Rename in Workspace". You can see this in the screenshot above.
I expected to see something like "create method" or "create instance method". Is there a plugin or another way which allows me to auto generate methods like this?

I would love to have such a feature. What is possible at the moment is to implement methods out of their declaration signatures. Imagine you have the following:
class Arrangment {
public:
void check(Edge* e, Edge* f, Events& heap, CirclePairSet &cpet) const;
}
Then set the cursor on check. Press Ctrl + Shift + S to open the Source Code context menu. Select Implement method... to create a stub with the method body.

Related

Visual Studio 2017: Ruleset won't execute

I want to define a custom set of rules to be checked at compile time. But it seems not to work.
Example:
I choose one rule directly and I'll get the expected warning.
But when I instead create a custom ruleset containing the exact same rule then I won't get the expected warning.
What could be wrong?
Edit:
void f(std::string& i) {
std::string s = i;
cout << s;
}
int main()
{
std::string s ("abc");
f(s);
}
This gives me the expected warning Warnung C26460 The reference argument 'i' for function 'f' can be marked as const (con.3). in the first case.
Even if I create a custom ruleset including all available rules, I won't get any warnings.
Here you see me selecting the custom ruleset:
Edit: The ruleset action must change one time to enable it.
When I create a new ruleset containing only the const-checks then I will get a .ruleset that does not work and look like this:
In the ruleset editor it looks like this:
When I then change its action from Warning to Error:
Then the .ruleset gets additional lines for each test case:
When I change the action back to warning it looks like this:
Now it is working as expected.
I've been able to reproduce your error with Visual Studio 2017. I don't know exactly what I changed (or if I changed anything at all), but I am able to see the code analysis warning you expect with a custom rule set.
Things I would try:
Double check the Error List window is visible and not hiding somewhere.
Open the rule set file, change the Action to Error and then back to Warning and save it. I wouldn't expect this to be the problem but it's one of the things I did and after which I started seeing the Error List window.

Eclipse CDT - Keyboard shortcuts or plugins for creating new Classes and methods from compile errors

Do you know of any keyboard shortcut for Eclipse CDT like the J2EE version of Ctrl + 1 + "New Class"?
I'm very used to Eclipse for J2EE where you can type the name of the new class you want to create right in your code, then Ctrl + 1 + "New Class" + Enter and that's it.
In Eclipse CDT, I have to manually create source and header files, or manually use the new class dialog/wizard, where no fields are pre-populated with any value.
The same goes for creating new methods, where you can type the method invocation and create it if it does not exist. I find it very useful for a "TDD" approach.
Thanks!
Probably no the answer you are looking for but in CDT currently (mars) there is no quick fix for creating new class. The best I can come up with is to define custom binding for New Class command (Window->Preferences ... type Keys .. type New and find New Class), define lets say Ctrl+4 to create new class. Then in the code double click on the class name, lets say MyClass and now press Ctrl+4, it will populate the class name (but not the file and header file names).
Send a bug to CDT if not already sent, it should be easy to add.

Qt ActiveX dynamicCall: bad parameter count

I am trying to use an ActiveX control in my program.
QAxWidget* mAX = new QAxWidget();
mAX->setControl("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}");
I know that there is a function:
put_ChannelType(long newValue)
But when I try to execute it:
mAX->dynamicCall("put_ChannelType(long)",2);
mAX->dynamicCall("put_ChannelType(int)",2);
mAX->dynamicCall("put_ChannelType(long)",QVariant(2));
mAX->dynamicCall("put_ChannelType(int)",QVariant(2));
I get:
QAxBase: Error calling IDispatch member put_ChannelType: Bad parameter count
Any idea what is going wrong ?
EDIT:
Weird thing is if I call
mAX->dynamicCall("put_ChannelType()");
I do not get any error message...
EDIT 2:
This also fails (as Constantin suggested)
QList<QVariant> varlist;
varlist << (int)1;
mAX->dynamicCall("put_ChannelType(int)",varlist);
Got this solved using the generateDocumentation() function.
I was using this ActiveX control in another application, but an MFC one.
It seems the function names I was referring to (which were in a machine generated IDispatch wrapper class created by VS) were not the same as the ones Qt listed.
i.e. put_ChannelType is actually SetChannelType...
Maybe this is just a version issue ?
Anyways, important part is knowing that generateDocumentation() can list you all the functions you can call with dynamicCall.
Is it OK?
mAX->dynamicCall("put_ChannelType(const QVariant &)", (long)2);

In the .cpp, is there a way to auto-implement all the functions from its .h?

I think this would increase the quality of life when devving, but google came up with nothing and I couldn't find anything specific inside inside Netbeans either.
What I want is to start with this header:
class bla
{
public:
static void gfg(somearg asd);
};
Then I open the blank bla.cpp and pressed 'autoimplement'. After that, it would look like this:
#include "bla.h"
static void bla::gfg(somearg asd)
{
//TODO: implement
throw unimplemented("void bla::gfg(somearg) is unimplemented");
}
Anyone know of a tool like this?
I found http://www.radwin.org/michael/projects/stubgen/
"stubgen is a C++ development tool that keeps code files in sync with their associated headers. When it finds a member function declaration in a header file that doesn't have a corresponding implementation, it creates an empty skeleton with descriptive comment headers."
This looks like it does exactly what you want it to do.
Some time has passed and in the meantime the requested feature seems to have been implemented in netbeans. Refer to https://netbeans.org/bugzilla/show_bug.cgi?id=213811 , which also gives a description on how to use it:
Note:
Implemented CTRL+SPACE.
IDE suggest implementing of class method if CTRL+SPACE was pressed:
- inside file that already has at least one method definition
- between method declarations

Anyway to get Visual Studio C++ to autocomplete parameter list?

Very specific issue with a specific piece of software, but I hope you fine folks can help!
I define a class in a header.h file that has a few method declarations that take parameters
class Lazy{
void complainForever(char * complaint, float forever = INFINITY);
};
Then I go into the Lazy.cpp file to define that function. Here is a psuedo timelapse of just how lazy I am.
void Lazy:: // <-- autocomplete kicks in, select method and hit enter
void Lazy::complainForever // <-- parameter list missing, completely defeating purpose
At that point, I either have to type it by hand, or copy/paste the parameter list from the header.h file
The question is this! Is there a keyboard shortcut or any method at all for having autocomplete take care of the parameter list for me?
Thank you in advance!
Why don't you try Visual Assist X. It isn't free though.
Once you are done defining the class in your header file, try to update Intellisense.
Updating intellisense can be achieved by reloading your project/solution. Once your intellisense is update, when you try to implement the class definition - you get the autocomplete feature on your newly defined class enabled. This includes the individual function prototypes as defined in the header.
Keyboard shortcut to display intellisense is Ctrl + Space.
Thanks