Author Topic: Patch: function arguments added to autocomplete tooltip  (Read 125996 times)

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Patch: function arguments added to autocomplete tooltip
« on: November 26, 2012, 02:03:14 am »
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?)
« Last Edit: November 30, 2012, 03:01:12 pm by p2rkw »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Patch: function arguments added to autocomplete tooltip
« Reply #1 on: November 26, 2012, 02:15:48 am »
Looks good, I'll test tomorrow :)
(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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Patch: function arguments added to autocomplete tooltip
« Reply #2 on: November 26, 2012, 02:30:09 am »
Question: Why you hack the scintilla code? ;)

PS: should be posted/moved to CodeCompletion redesign
« Last Edit: November 26, 2012, 03:52:21 am by ollydbg »
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.

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #3 on: November 26, 2012, 04:03:48 am »
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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #4 on: November 26, 2012, 06:23:21 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #5 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).
« Last Edit: November 30, 2012, 03:01:40 pm by p2rkw »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #6 on: November 26, 2012, 08:15:08 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Patch: function arguments added to autocomplete tooltip
« Reply #7 on: November 26, 2012, 08:27:43 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!]

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #8 on: November 26, 2012, 08:33:47 pm »
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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Patch: function arguments added to autocomplete tooltip
« Reply #9 on: November 26, 2012, 09:02:12 pm »
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)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #10 on: November 26, 2012, 09:06: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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #11 on: November 26, 2012, 10:01:43 pm »
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.
« Last Edit: November 27, 2012, 01:06:45 am by p2rkw »

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #12 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?

Quote
Would 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()

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Patch: function arguments added to autocomplete tooltip
« Reply #13 on: November 28, 2012, 04:13: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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #14 on: November 28, 2012, 11:27:23 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ