Menu

#801 Tooltip is not displayed if constant only scoped by namespace

Undefined
open
nobody
Bug_Report
2021-06-27
2019-02-21
Andy Benn
No

Hi,
I work with code that contains many constants defined in various namespaces and enums. If I use the identifer scoped only by namespace, no tooltip is displayed, e.g.

void myFunction(diCat::nodeType pNodeType)
{
    if (pNodeType == diCat::FILE_NODE)   // <-- no tooltip appears when hover on FILE_NODE
    {
        LOG_ERROR("not supported")
    }
}

If the code is changed to have either the full namespace/enum or just the constant name then a proper tooltip is displayed. i.e. either of these cause the tooltip to be shown:-

   if (pNodeType == diCat::NodeTypesEnum::FILE_NODE) // <--- tooltip displayed
   if (pNodeType == FILE_NODE) // <--- tooltip displayed

Tested on build 11562 (Feb2019).
Andy

2 Attachments

Discussion

  • ollydbg

    ollydbg - 2019-02-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,7 @@
     Hi,
     I work with code that contains many constants defined in various namespaces and enums. If I use the identifer scoped only by namespace, no tooltip is displayed, e.g.
    
    +~~~
     void myFunction(diCat::nodeType pNodeType)
     {
         if (pNodeType == **diCat::FILE_NODE**)    <-- no tooltip appears when hover on FILE_NODE
    @@ -8,11 +9,14 @@
             LOG_ERROR("not supported")
         }
     }
    +~~~
    
     If the code is changed to have either the full namespace/enum or just the constant name then a proper tooltip is displayed. i.e. either of these cause the tooltip to be shown:-
    
    +~~~
        if (pNodeType == **diCat::NodeTypesEnum::FILE_NODE**)  <--- tooltip displayed
        if (pNodeType == **FILE_NODE**)  <--- tooltip displayed
    +~~~
    
     Tested on build 11562 (Feb2019).
     Andy
    
     
  • ollydbg

    ollydbg - 2019-02-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,7 +4,7 @@
     ~~~
     void myFunction(diCat::nodeType pNodeType)
     {
    -    if (pNodeType == **diCat::FILE_NODE**)    <-- no tooltip appears when hover on FILE_NODE
    +    if (pNodeType == diCat::FILE_NODE)   // <-- no tooltip appears when hover on FILE_NODE
         {
             LOG_ERROR("not supported")
         }
    @@ -14,8 +14,8 @@
     If the code is changed to have either the full namespace/enum or just the constant name then a proper tooltip is displayed. i.e. either of these cause the tooltip to be shown:-
    
     ~~~
    -   if (pNodeType == **diCat::NodeTypesEnum::FILE_NODE**)  <--- tooltip displayed
    -   if (pNodeType == **FILE_NODE**)  <--- tooltip displayed
    +   if (pNodeType == diCat::NodeTypesEnum::FILE_NODE) // <--- tooltip displayed
    +   if (pNodeType == FILE_NODE) // <--- tooltip displayed
     ~~~
    
     Tested on build 11562 (Feb2019).
    
     
  • ollydbg

    ollydbg - 2019-02-23
    • labels: Tooltip, enum --> Tooltip, enum, CodeCompletion
     
  • ollydbg

    ollydbg - 2019-02-23

    Can you show uas a minimal test code which can reproduce this bug?
    So that we can test it.
    Thanks.

     
  • Andy Benn

    Andy Benn - 2019-02-25

    Hopefully this is ok.. Hover over each literal name in the main code and for the first two you get the tooltip showing the enum details and value. But for UNEXPECTED_ERROR which is only qualified by namespace, you don't get any popup.
    Regards
    Andy

    #include <stdio.h>
    
    namespace literals
    {
        enum resultCodes
        {
            SUCCESS          = 0,
            INVALID_NAME     = 1,
            UNEXPECTED_ERROR = 99,
        };
    };
    
    using namespace literals;
    
    int main(int argc, char *argv[])
    {
        int a = 0;
        if (a == SUCCESS)                              // tooltip
        {
            printf("SUCCESS\n");
        }
    
        a = 1;
        if (a == literals::resultCodes::INVALID_NAME)  // tooltip
        {
            printf("INVALID_NAME\n");
        }
    
        a = 99;
        if (a == literals::UNEXPECTED_ERROR)           // No tooltip
        {
            printf("UNEXPECTED_ERROR\n");
        }
    
        return 0;
    }
    
     
  • Andrew Cottrell

    Andrew Cottrell - 2021-06-26

    Andy,
    Can you check to see if your code works with the latest nightly aa my test on Windows 10 with SVN 12468 (local build) worked okay and the tooltip after typing "if (a == literals::" showed the three enum options.

    The latest nightly can be downloaded from the following CB form thread:
    https://forums.codeblocks.org/index.php/topic,24545.0.html

    Thanks,
    Andrew

     
  • Andy Benn

    Andy Benn - 2021-06-27

    Hi thanks for the update.

    I checked the nightlies page but only saw 12462 (20 June) so I tried that one.

    Agree that if you type out "if (a == literals::" then at that point you do get a tooltip showing the available values of the enum.

    However my issue was when you click or hover on a piece of code like
    "if (a == literals::UNEXPECTED_ERROR)"
    then no tooltip appears at all.

    The tool tip does appear if the code you are looking at has fully qualify the constant with its namespace and enum, or you don't qualify it at all. But when it has been qualified by just the namespace, hovering does not popup a tooltip..

    Thanks
    Andy

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.