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

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #75 on: December 28, 2012, 07:02:38 pm »
Quote
Please stick to lower case file names.
Ok.
Quote
Well in fact, on Windows none of the blue links works for me:
I just tested it on windows, and it works very bad, much worse than on linux. Fortunately I know how to fix it.
Quote
I don't understand this sentence.
Sorry, if it wasn't clear. I mean when you have function/method declaration:
Code
void function(int arg0, float arg1);
you can use autocomplete to write implementation easily:
Code
void fun| // <- use autocomplete here
and you will get
Code
void function(int arg0, float arg1)
The only requirement is that implementation must be outside block.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #76 on: December 29, 2012, 06:39:28 am »
Code
void fun| // <- use autocomplete here
and you will get
Code
void function(int arg0, float arg1)
The only requirement is that implementation must be outside block.
Juts my 2 cents on that one: This should definitely be an option, off by default. Otherwise we will get tons of reports how to turn it off.

As a general rule: Every automatism that affects the way you write code or something that even changes written code must be an option unless you need a special key combination to activate it.
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 #77 on: January 01, 2013, 05:17:46 pm »
I fixed windows related issues, but still it isn't configurable. I can generate and upload patch if you want to test it.

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Patch: function arguments added to autocomplete tooltip
« Reply #78 on: January 07, 2013, 12:24:14 am »
Next update, now all newly added functionalities are disabled by default. To enable them you have modify your config file manually.
Code
<USE_DOCUMENTATION_HELPER bool="1" />
<DOCUMENTATION_HELPER_BACKGROUND_COLOR>
<colour r="255" g="255" b="255" />
</DOCUMENTATION_HELPER_BACKGROUND_COLOR>
<DOCUMENTATION_HELPER_TEXT_COLOR>
<colour r="0" g="0" b="0" />
</DOCUMENTATION_HELPER_TEXT_COLOR>
<DOCUMENTATION_HELPER_LINK_COLOR>
<colour r="0" g="0" b="255" />
</DOCUMENTATION_HELPER_LINK_COLOR>
These lines enables documentation helper, and sets colours used in generated html document.

Code
<DETECT_IMPLEMENTATION bool="1" />
This one enables functionality described in my previous post - if you use autocomplete in global scope or inside class declaration then arguments' types and names will be added.

Code
<SORT_CRITERION1 int="2" />
<SORT_CRITERION2 int="1" />
<SORT_CRITERION3 int="6" />
<SORT_CRITERION4 int="5" />
<SORT_CRITERION5 int="7" />
<SORT_CRITERION6 int="8" />
<SORT_CRITERION7 int="4" />
<SORT_CRITERION8 int="0" />

By the way I also added possibility to sort autocomplete list. You can use up to 8 sort criteria. Lower criterion number means higher priority (SORT_CRITERION1 has highest priority). Argument's specify how auto complete list will be sorted. Possible values and its meanings:
Code
        enum Criterium
        {
            NO_CRITERION      = 0,
            
            CMP_SCOPE         = 1,  // compare by token's scope
            IS_LOCAL          = 2,      // compare by Token::m_IsTemp: checks if token is local variable
            CMP_NAME          = 3,  //compare by token's name
            CMP_KIND          = 4,   //compare by token's kind with order defined by Token::m_TokenKind value; don't use this comparator with lower priority than IS_FN, IS_VAR, IS_CLASS, IS_NS
            IS_FN             = 5,  // compare by token's kind: checks if token is function
            IS_VAR            = 6,  //compare by token's kind: checks if token is variable
            IS_CLASS          = 7, //  ... is it class
            IS_NS             = 8, //  ... is it namespace
        };
And if you set criterion to "0" (NO_CRITERION) all criteria with lower priority will be disabled, so to sort only by token's name simply set SORT_CRITERION1 to "0".

edit: those tags should be sub-nodes  of <code_completion> node.
edit2: Changes in project files are not included in patch, so remember to add doxygen_parser.* files to project.
« Last Edit: January 07, 2013, 06:33:41 pm by p2rkw »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Patch: function arguments added to autocomplete tooltip
« Reply #79 on: January 07, 2013, 12:55:43 am »
Code
<SORT_CRITERION1 int="2" />
<SORT_CRITERION2 int="1" />
<SORT_CRITERION3 int="6" />
<SORT_CRITERION4 int="5" />
<SORT_CRITERION5 int="7" />
<SORT_CRITERION6 int="8" />
<SORT_CRITERION7 int="4" />
<SORT_CRITERION8 int="0" />

By the way I also added possibility to sort autocomplete list. You can use up to 8 sort criteria. Lower criterion number means higher priority (SORT_CRITERION1 has highest priority). Argument's specify how auto complete list will be sorted. Possible values and its meanings:
Code
        enum Criterium
        {
            NO_CRITERION      = 0,
            
            CMP_SCOPE         = 1,  // compare by token's scope
            IS_LOCAL          = 2,      // compare by Token::m_IsTemp: checks if token is local variable
            CMP_NAME          = 3,  //compare by token's name
            CMP_KIND          = 4,   //compare by token's kind with order defined by Token::m_TokenKind value; don't use this comparator with lower priority than IS_FN, IS_VAR, IS_CLASS, IS_NS
            IS_FN             = 5,  // compare by token's kind: checks if token is function
            IS_VAR            = 6,  //compare by token's kind: checks if token is variable
            IS_CLASS          = 7, //  ... is it class
            IS_NS             = 8, //  ... is it namespace
        };
And if you set criterion to "0" (NO_CRITERION) all criteria with lower priority will be disabled, so to sort only by token's name simply set SORT_CRITERION1 to "0".

edit: those tags should be sub-nodes  of <code_completion> node.
edit2: Changes in project files are not included in patch, so remember to add doxygen_parser.* files to project.
If this is some separate functionallity it will be best to post a separate patch...

Also, I guess you'll have to provide some gui...
(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 #80 on: January 07, 2013, 12:59:43 am »
I know that, but I don't know will I have time in this week.
« Last Edit: January 07, 2013, 02:34:13 am by p2rkw »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #81 on: January 07, 2013, 09:26:01 am »
Next update, now all newly added functionalities are disabled by default. To enable them you have modify your config file manually.
Unfortunately it doesn't compile. The error I get is:
C:\Devel\CodeBlocks\src\plugins\codecompletion\parser\parserthread.cpp: In constructor 'ParserThread::ParserThread(ParserBase*, const wxString&, bool, ParserThreadOptions&, TokenTree*)':
C:\Devel\CodeBlocks\src\plugins\codecompletion\parser\parserthread.cpp:200:72: error: no matching function for call to 'Tokenizer::SetTokenizerOption(bool&)'

You changed the interface of that method from:
void SetTokenizerOption(bool wantPreprocessor)
...to:
void SetTokenizerOption(bool wantPreprocessor, bool storeDocumentation)
...maybe you forgot to update all its calls / references?
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 #82 on: January 07, 2013, 06:33:07 pm »
Oh, sorry. I cut out too much when I was removing unnecessary chunks from patch.
You can use revised patch (in attachment) or apply this:
Code
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (wersja 8771)
+++ src/plugins/codecompletion/parser/parserthread.cpp (kopia robocza)
@@ -197,7 +197,8 @@
     m_IsBuffer(parserThreadOptions.useBuffer),
     m_Buffer(bufferOrFilename)
 {
-    m_Tokenizer.SetTokenizerOption(parserThreadOptions.wantPreprocessor);
+    bool storeDocumentation = true;
+    m_Tokenizer.SetTokenizerOption(parserThreadOptions.wantPreprocessor, storeDocumentation);
     if (!m_TokenTree)
         cbThrow(_T("m_TokenTree is a nullptr?!"));
 }
« Last Edit: January 13, 2013, 10:56:41 pm by p2rkw »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #83 on: January 07, 2013, 07:47:51 pm »
You can use revised patch (in attachment) or apply this:
Yes, work now... I have it applied and report if something is badly broken... ;-)
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Patch: function arguments added to autocomplete tooltip
« Reply #84 on: January 10, 2013, 02:56:27 pm »
I have a wired build issue:
Quote
[ 58.3%] g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE  -DBUILDING_PLUGIN    -iquote.objs\include -I.objs\include -I. -IE:\code\cb\wx\wxWidgets-2.8.12\include -IE:\code\cb\wx\wxWidgets-2.8.12\contrib\include -IE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll\mswu -Isdk\wxscintilla\include -Isdk\wxpropgrid\include -Iinclude\tinyxml -Iinclude -Iinclude\mozilla_chardet -Iinclude\mozilla_chardet\mfbt -Iinclude\mozilla_chardet\nsprpub\pr\include -Iinclude\mozilla_chardet\xpcom -Iinclude\mozilla_chardet\xpcom\base -Iinclude\mozilla_chardet\xpcom\glue  -c plugins\codecompletion\codecompletion.cpp -o .objs\plugins\codecompletion\codecompletion.o
In file included from plugins\codecompletion\codecompletion.h:17:0,
                 from plugins\codecompletion\codecompletion.cpp:53:
plugins\codecompletion\doxygen_parser.h:181:9: error: expected identifier before numeric constant
plugins\codecompletion\doxygen_parser.h:181:9: error: expected '}' before numeric constant
plugins\codecompletion\doxygen_parser.h:181:9: error: expected unqualified-id before numeric constant
plugins\codecompletion\doxygen_parser.h:197:37: error: 'Command' was not declared in this scope
plugins\codecompletion\doxygen_parser.h:197:50: error: expected primary-expression before 'const'
plugins\codecompletion\doxygen_parser.h:197:72: error: expected primary-expression before 'const'
plugins\codecompletion\doxygen_parser.h:199:40: error: 'Command' was not declared in this scope
plugins\codecompletion\doxygen_parser.h:199:53: error: expected primary-expression before 'const'
plugins\codecompletion\doxygen_parser.h:199:75: error: expected primary-expression before 'int'
plugins\codecompletion\doxygen_parser.h:201:12: error: 'Command' does not name a type
plugins\codecompletion\doxygen_parser.h:207:27: error: uninitialized const 'separatorTag' [-fpermissive]
plugins\codecompletion\doxygen_parser.h:211:39: error: expected ')' before '*' token
plugins\codecompletion\doxygen_parser.h:213:27: error: expected constructor, destructor, or type conversion before ';' token
plugins\codecompletion\doxygen_parser.h:229:23: error: non-member function 'bool IsAttached()' cannot have cv-qualifier
plugins\codecompletion\doxygen_parser.h:235:1: error: expected unqualified-id before 'protected'
plugins\codecompletion\doxygen_parser.h:251:1: error: expected unqualified-id before 'public'
plugins\codecompletion\doxygen_parser.h:259:1: error: expected unqualified-id before 'protected'
plugins\codecompletion\doxygen_parser.h:284:5: error: expected unqualified-id before 'private'
plugins\codecompletion\doxygen_parser.h:284:5: error: expected unqualified-id before 'protected'
plugins\codecompletion\doxygen_parser.h:284:5: error: 'virtual' outside class declaration
plugins\codecompletion\doxygen_parser.h:284:5: error: non-member function 'const wxEventTable* GetEventTable()' cannot have cv-qualifier
plugins\codecompletion\doxygen_parser.h:284:5: error: no matching function for call to 'wxEventHashTable::wxEventHashTable()'
plugins\codecompletion\doxygen_parser.h:284:5: note: candidates are:
E:\code\cb\wx\wxWidgets-2.8.12\include/wx/event.h:2380:5: note: wxEventHashTable::wxEventHashTable(const wxEventHashTable&)
E:\code\cb\wx\wxWidgets-2.8.12\include/wx/event.h:2380:5: note:   candidate expects 1 argument, 0 provided
E:\code\cb\wx\wxWidgets-2.8.12\include/wx/event.h:2342:5: note: wxEventHashTable::wxEventHashTable(const wxEventTable&)
E:\code\cb\wx\wxWidgets-2.8.12\include/wx/event.h:2342:5: note:   candidate expects 1 argument, 0 provided
plugins\codecompletion\doxygen_parser.h:284:5: error: 'virtual' outside class declaration
plugins\codecompletion\doxygen_parser.h:284:5: error: non-member function 'wxEventHashTable& GetEventHashTable()' cannot have cv-qualifier
plugins\codecompletion\doxygen_parser.h:285:1: error: expected declaration before '}' token

The first error happens here:
Code
class DocumentationHelper : public /*wxHtmlWindow*/ wxEvtHandler
{
    //typedef wxHtmlWindow BaseClass;
    typedef wxEvtHandler BaseClass;

public:
    enum Command
    {
        NO_COMMAND,
        DISPLAY_TOKEN,  //args: token index
        SEARCH,         //args: token name
        SEARCH_ALL,     //args: token name **************Here
        OPEN_DECL,      //args: token index
        OPEN_IMPL,      //args: token index
        CLOSE,          //args: -----
    };

I just run the preprocessor:
Quote
@echo Add MinGW path
@set PATH=E:\code\gcc\PCXMinGW463\bin;%PATH%

g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE  -DBUILDING_PLUGIN    -iquote.objs\include -I.objs\include -I. -IE:\code\cb\wx\wxWidgets-2.8.12\include -IE:\code\cb\wx\wxWidgets-2.8.12\contrib\include -IE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll\mswu -Isdk\wxscintilla\include -Isdk\wxpropgrid\include -Iinclude\tinyxml -Iinclude -Iinclude\mozilla_chardet -Iinclude\mozilla_chardet\mfbt -Iinclude\mozilla_chardet\nsprpub\pr\include -Iinclude\mozilla_chardet\xpcom -Iinclude\mozilla_chardet\xpcom\base -Iinclude\mozilla_chardet\xpcom\glue  -E plugins\codecompletion\codecompletion.cpp >> a.txt

The wired thing is, when I look at the a.txt(the preprocessed output), I see such code:
Code
class DocumentationHelper : public wxEvtHandler
{

    typedef wxEvtHandler BaseClass;

public:
    enum Command
    {
        NO_COMMAND,
        DISPLAY_TOKEN,
        SEARCH,
        0x0,
        OPEN_DECL,
        OPEN_IMPL,
        CLOSE,
    };

I don't know where the "0x0" comes???? I just searched the whole file, and I see no macro definition of "SEARCH_ALL". I have no idea what happens.....

EDIT:
It looks like I can add such code to avoid the issue.
Code
#ifdef SEARCH_ALL
#undef SEARCH_ALL
#endif
But I still have no idea where does the previous "SEARCH_ALL" defined.

« Last Edit: January 10, 2013, 03:01:17 pm 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 #85 on: January 10, 2013, 03:10:34 pm »
If you don't know where macro is defined, then it's defined in windows.h :) Thanks for information, I will change this name.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Patch: function arguments added to autocomplete tooltip
« Reply #86 on: January 10, 2013, 03:11:21 pm »
Ok, by putting the text:
Code
<USE_DOCUMENTATION_HELPER bool="1" />
<DOCUMENTATION_HELPER_BACKGROUND_COLOR>
<colour r="255" g="255" b="255" />
</DOCUMENTATION_HELPER_BACKGROUND_COLOR>
<DOCUMENTATION_HELPER_TEXT_COLOR>
<colour r="0" g="0" b="0" />
</DOCUMENTATION_HELPER_TEXT_COLOR>
<DOCUMENTATION_HELPER_LINK_COLOR>
<colour r="0" g="0" b="255" />
</DOCUMENTATION_HELPER_LINK_COLOR>

in the configure file, section:

Quote
<code_completion>
....
</code_completion>

I'm happy testing this new feature, really good job, p2rkw!!!
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 #87 on: January 10, 2013, 03:22:32 pm »
If you don't know where macro is defined, then it's defined in windows.h :) Thanks for information, I will change this name.
Nope, this time its well hidden in "ntddchgr.h" of the DDK ([MinGW]\include\ddk\) of MinGW.

This shows very nice, how badly macros can suck.
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch: function arguments added to autocomplete tooltip
« Reply #88 on: January 10, 2013, 03:26:08 pm »
If you don't know where macro is defined, then it's defined in windows.h :) Thanks for information, I will change this name.
Nope, this time its well hidden in "ntddchgr.h" of the DDK ([MinGW]\include\ddk\) of MinGW.

This shows very nice, how badly macros can suck.
Oh, and BTW: In my personal projects I always declare enums as following:
Code
    enum ECommand
    {
        eNO_COMMAND,
        eDISPLAY_TOKEN,  //args: token index
        eSEARCH,         //args: token name
        eSEARCH_ALL,     //args: token name
        eOPEN_DECL,      //args: token index
        eOPEN_IMPL,      //args: token index
        eCLOSE,          //args: -----
    };
Notice the prefixes... this usually never conflicts with #defines, as they are 99% of the cases declared upper-case only.
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 #89 on: January 13, 2013, 10:56:10 pm »
Gui added, last bugs fixed... It seems to be finished now :) http://developer.berlios.de/patch/?func=detailpatch&patch_id=3381&group_id=5358

(Ability to define custom sort order had been removed from this patch, so remember to clean your configuration file.)