News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Patch: function arguments added to autocomplete tooltip

Started by p2rkw, November 26, 2012, 02:03:14 AM

Previous topic - Next topic

p2rkw

Hi,
tonight I wrote small patch that adds functions arguments to autocomplete:

As you can see types and return value will be removed.
I modify src/plugins/codecompletion/codecompletion.cpp and src/sdk/wxscintilla/src/scintilla/src/ScintillaBase.cxx

Maybe it will be useful for someone, so enjoy.
(I hope this is good section for posting patches?)

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Question: Why you hack the scintilla code? ;)

PS: should be posted/moved to CodeCompletion redesign
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

p2rkw

ollydbg: I thought that scintilla is only place that can I modify selected text, but I was wrong. Now I see that I should insert this code in EditorEventHook. I forgot about wxEVT_SCI_AUTOCOMP_SELECTION event. I'll fix it later.

MortenMacFly

Quote from: p2rkw on November 26, 2012, 04:03:48 AM
Now I see that I should insert this code in EditorEventHook. I forgot about wxEVT_SCI_AUTOCOMP_SELECTION event. I'll fix it later.
Definitely. wxScintilla should not be touched for such reasons.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

p2rkw

Ok, I attach corrected patch. Please test it. After patching autocomplete will insert default argument names, so if you want back to old behaviour set 'autoAddArgsNames' to false (line 1507 in codecompletion.cpp).

MortenMacFly

Quote from: p2rkw on November 26, 2012, 03:54:00 PM
Ok, I attach corrected patch. Please test it. After patching autocomplete will insert default argument names, so if you want back to old behaviour set 'autoAddArgsNames' to false (line 1507 in codecompletion.cpp).
Although the functionality might be interesting, please follow our general coding lines.

So (for example) don't add method names with a lower letter, don't add global static functions which can be private to the class and so on... Otherwise the code starts to become really messy and this is not what we want.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

oBFusCATed

Quote from: MortenMacFly on November 26, 2012, 08:15:08 PM
...don't add global static functions which can be private to the class and so on...
I don't agree here, global static function are way more private then a private function in the class. I tend to use them a lot.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

p2rkw

I forgot about capital letters, sorry,
I made those 3 functions as static free functions because they don't touch any Codecompletion's non-static and static fields. Moreover they're visible only in codecompletion.cpp compilation unit.

dmoore

Nice idea, but how do you deal with really long call sigs? Would be nice if the box was horizontally scrollable but that probably requires changes to scintilla. Also, would be really nice to have a second pane that shows doc strings. (see Netbeans)
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: p2rkw on November 26, 2012, 08:33:47 PM
I made those 3 functions as static free functions because they don't touch any Codecompletion's non-static and static fields. Moreover they're visible only in codecompletion.cpp compilation unit.
Then put them on top of the unit into a "Helper" namespace, as it is done in other files (i.e. nativeparser.cpp). ;)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

p2rkw

domore: I agree, docs might be displayed in scintilla's call tip, but first CC must handle documentation comments properly.

edit: It's possible but this require intervention into scintillaWX, IMO it is worth it. Currently call tip and auto complete hides each other.

p2rkw

About documentation, I tried to detect when user changes selection in autocomplete but currently I can't do that.
developers, have you any plans, ideas about documentation support?

QuoteWould be nice if the box was horizontally scrollable but that probably requires changes to scintilla.
Quote
I don't know to to add scroll, but I found that box's maximum dimensions are hardcoded in wxscintilla/src/PlatWX.cpp in ListBoxImpl::GetDesiredRect()

ollydbg

Quote from: p2rkw on November 28, 2012, 02:51:14 AM
About documentation, I tried to detect when user changes selection in autocomplete but currently I can't do that.
developers, have you any plans, ideas about documentation support?

First, you need to use a method to recognize comments? We can get comments from the Parserthread class (not implemented), or we can find/search comments around the symbol through Scintilla's API.

Second, to show the comments, I once see that Codelite IDE use an customized window. (not the build-in one in scintilla)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MortenMacFly

Quote from: p2rkw on November 28, 2012, 02:51:14 AM
ideas about documentation support?
Well did you try the Doxyblocks plugin in the first place? You have everything you need in place there. Including scanning for docs.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]