Michael Williams
Michael Williams

Reputation: 403

Cursor placement when calling a method with void parameters

This is a fairly straight forward question but I am unable to find an answer about this specific type of formatting. I'm looking for a way to modify where eclipse places the cursor after using its content assist to complete a method call based on whether or not the method has any parameters.

To illustrate what exactly I'm talking about lets consider a simple c++ class like so:

class Example
{
    public:
        int voidParams()
        {
            //do something
            return 42;
        };
        int nonVoidParams(int a)
        {
            //do something else
            return a*a;
        };
};

And at some point I created an instance of the class Example ex;

Now within eclipse if I started typing ex.nonV and I told eclipse to auto complete it would enter in ex.nonVoidParams() and after doing this my cursor would be inside the parenthesis like so ex.nonVoidParams(|) where | is my cursor. This makes sense and is useful since I need to give this particular method an argument.

Hopefully none of what I just said is new to anyone and is all pretty straight forward. This is where my question comes in. Having my cursor be placed within the parenthesis of a method call is only useful if that method takes parameters. If I were to type ex.voi and let eclipse auto complete to ex.voidParams() my cursor would be inside the parenthesis like so ex.voidParams(|) where | is my cursor. This isn't very useful since there is nothing for me to enter there.

I would like to know if there is a way to setup eclipse so, given the above examples, if it auto completes a method with void parameters such as ex.voidParams() it places the cursor after the method call like so ex.voidParams()| again where | is my cursor.

I'm not super familiar with customizing eclipse but I feel like there should be a way to do this since if eclipse is auto completing the method call it should know what its parameters are and be able to adjust its formatting from there.

Oh and this will probably be asked at some point, I'm currently using Eclipse CDT version 4.2.0 (Juno service Release 2).

Upvotes: 1

Views: 110

Answers (1)

HuDu
HuDu

Reputation: 21

Go to Window->Preferences->C++->Editor->Content Assist->Advanced, pick the "Parsing-based Proposals" instead of "Parsing-based Proposals (Task-Focused)".

Upvotes: 2

Related Questions