Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357309

Summary: Code completion for function pointers doesn't display parameters/arguments
Product: [Tools] CDT Reporter: Ben Davis <entheh>
Component: cdt-parserAssignee: Project Inbox <cdt-parser-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: enhancement    
Priority: P3 CC: cdtdoug, marc.khouzam, simon.marchi, ultrano, yevshif
Version: 8.0Flags: ultrano: review? (cdtdoug)
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Implement CA for function-pointers none

Description Ben Davis CLA 2011-09-10 13:56:36 EDT
Hi,

If I put the following code into a C++ editor:

void firstTest(int x);
void (*secondTest)(int x);

void test() {

}

Then I put the cursor inside the test() function body, begin to type 'firstTest', and press Ctrl+Space, then it will generate firstTest(), put the cursor between the brackets, and give me a tooltip showing '(int x)'.

If I instead begin to type 'secondTest', then it will autocomplete the name of the variable without giving me any arguments. If I type the ( myself and press Ctrl+Space again, it still won't tell me the required arguments. Even if I type '(*secondTest)(' and press Ctrl+Space, I still don't get anything.

This makes it difficult to develop with OpenGL extensions where all the functions are declared as pointers, so I'd like to request that function pointers be supported in this way if possible :)

Thanks in advance - let me know if you need any more information. (Also apologies if this is a duplicate; the search results weren't loading for me when I tried to search.)
Comment 1 Iliyan Dinev CLA 2014-09-14 20:21:45 EDT
Created attachment 247050 [details]
Implement CA for function-pointers

CFunctionType and CPPFunctionType get a new member, which is also marshalled. Most or all usecases should be covered, except for:

void main(){
	int (*rejected)(int b, int c);
	rejected(); // cursor is between ( and ), CA gets invoked
}
Comment 2 Iliyan Dinev CLA 2014-09-14 20:26:31 EDT
Here is a proposed patch, that implements the required functionality for C and C++.
 Note that marshalling gets extended for 2 types, and CFunctionType marshalling is using a flag "last_flag << 1". It was made inextendable, so I am unsure of a better solution. Maybe changing min_version from "172.0" to "173.0" would be best.
Comment 3 Iliyan Dinev CLA 2014-11-05 15:12:05 EST
Any update on this? 2 months and nothing. Seems like no-one should bother fix CDT issues, as the fixes go into /dev/null? I had planned to make a bunch of improvements/fixes...
Comment 4 Marc Khouzam CLA 2014-11-06 08:32:38 EST
(In reply to Iliyan Dinev from comment #3)
> Any update on this? 2 months and nothing. Seems like no-one should bother
> fix CDT issues, as the fixes go into /dev/null? I had planned to make a
> bunch of improvements/fixes...

Hi Iliyan,

we are no longer allowed to accept patches through bugzilla but must go through Gerrit.

First you will need to sign your CLA:
https://www.eclipse.org/legal/clafaq.php

and then you can submit your patch to Gerrit:
https://wiki.eclipse.org/CDT/git#Using_Gerrit_for_CDT

Thanks
Comment 5 Simon Marchi CLA 2014-11-29 13:23:53 EST
Heh, it's funny how I just stumbled upon the same "problem" and someone made a patch for it not so long ago. :)

Iliyan, I did try your patch for my very basic use case and it works fine for that. I think it would be very useful to have it merged, so I encourage you very much to post it to Gerrit.

As Marc said, you need to go through Gerrit. Patches posted directly as attachment to bugs go unnoticed whereas new changes posted on Gerrit pop on the TODO list of maintainers. Be assured that all contributions are appreciated.