Author Topic: Code completion does not list enum members  (Read 13283 times)

Offline alberto

  • Single posting newcomer
  • *
  • Posts: 9
Code completion does not list enum members
« on: April 20, 2010, 03:48:35 pm »
I'm not sure if this is already a feature but I would expect code completion to list enum members upon typing the enum name (so you can select the name you require). Does anyone know if this is a fault or just not implemented??

Offline jajdoo

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code completion does not list enum members
« Reply #1 on: April 21, 2010, 11:40:23 am »
well ..
if you type the enum name and :: it you get the members...
( enumName:: )

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion does not list enum members
« Reply #2 on: April 21, 2010, 03:34:06 pm »
I'm not sure if this is already a feature but I would expect code completion to list enum members upon typing the enum name (so you can select the name you require). Does anyone know if this is a fault or just not implemented??

It should work well. Can you give a simple test code?
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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: Code completion does not list enum members
« Reply #3 on: April 21, 2010, 03:38:23 pm »
And as always:
please tell us which version of C::B and which OS (and version) you use !!

Offline alberto

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code completion does not list enum members
« Reply #4 on: April 22, 2010, 11:31:11 am »
Sample code.....

typedef enum
{
    DYN_NO_DISPLAY = 0,
    DYN_SELECTED,
    DYN_HIGHLIGHTED,
    DYN_NONE,

} T_TR_SCROLL_DYN;


static T_TR_SCROLL_DYN        Tr_Scroller_Dynamic =       DYN_NO_DISPLAY;


Then type Tr_Scroller_Dynamic = ..... no options appear, thought it would provide a choice of the four options above?

Using SVN 6181, on Windows XP SP3.

Please help!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code completion does not list enum members
« Reply #5 on: April 22, 2010, 11:58:58 am »
Does
Code
enum T_TR_SCROLL_DYN
{
    DYN_NO_DISPLAY = 0,
    DYN_SELECTED,
    DYN_HIGHLIGHTED,
    DYN_NONE,

};

work?
(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 alberto

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code completion does not list enum members
« Reply #6 on: April 22, 2010, 12:18:20 pm »
It only works if I type the defined name as above or the variable name as in my example if I add the :: after. Or is this how it is supposed to work? It's just that you need to know that its an enum (often there are too many to remember) and also remove the :: after you've chosen the corrrect definition.

Offline alberto

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code completion does not list enum members
« Reply #7 on: April 22, 2010, 12:20:46 pm »
Apologies if I'm being too pedantic, its probably a feature from CodeWright, hence why I'm expecting it to provide the list.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code completion does not list enum members
« Reply #8 on: April 22, 2010, 12:41:04 pm »
I think the correct behavior should be:
user types DYN| presses ctrl+space and the members of the enum are there.

I'm not sure, what has been implemented, though.
You've not said if there is any difference using "enum T_TR_SCROLL_DYN {};" and "typedef enum {} T_TR_SCROLL_DYN;"
In the past the "typedef enum/struct" was not supported.
(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 alberto

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code completion does not list enum members
« Reply #9 on: April 22, 2010, 12:50:16 pm »
Hi, yeah that would assume you already know the member names, likewise typing :: after the name assumes you know you're dealing with an Enum.

The behaviour is the same for both examples, typedef and direct definition. You need to type :: to get the member names.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion does not list enum members
« Reply #10 on: April 25, 2010, 02:25:27 pm »
Sample code.....

typedef enum
{
    DYN_NO_DISPLAY = 0,
    DYN_SELECTED,
    DYN_HIGHLIGHTED,
    DYN_NONE,

} T_TR_SCROLL_DYN;


static T_TR_SCROLL_DYN        Tr_Scroller_Dynamic =       DYN_NO_DISPLAY;


Then type Tr_Scroller_Dynamic = ..... no options appear, thought it would provide a choice of the four options above?

Using SVN 6181, on Windows XP SP3.

Please help!

Hi, what you want is not implemented in CC. here, when you type:
Code
Tr_Scroller_Dynamic =|    // your caret are here

For the currently implementation of CC, we just do a "left" search until we find a non-identifier. For this case, we stop after the "=", and get "nothing" returned.

If you type this:
Code
Tr_Scroller_Dynamic =DYN_|    // your caret are here
Then, the "left" search stopped at "=" as well, but now, it returned the "DYN_", so, CC plugin can use "DYN_" as a "search text" to do the suggestion list.

For your feature request, I think it will let the "left" search to parse the whole line, and analyze the whole syntax tree, then if it find the left side of the assignment is a enum, it will list all the enum values in the right side of the "=". I'd like to say, it can be done, but it need some effort and time. :D
« Last Edit: April 25, 2010, 03:07:49 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 nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Code completion does not list enum members
« Reply #11 on: April 25, 2010, 04:38:27 pm »
I hope CC can do work after we type " = " or "new"

1, =

enum EEE{  E1, E2, E3};
...
EEE e  = |  // <-- here,  cc show a list with items: E1, E2... we can select.

2, new  (VS and C# can do it)

class B {};
class D1 : public B {};
class D2 : public B {};
class C : public D2 {};
...
B* pb = new |  // <-- here, cc show a list with items: B, D1, D2, C ...

sorry for my English.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion does not list enum members
« Reply #12 on: April 25, 2010, 04:59:37 pm »
@nanyu
This means the "left search" should go beyond the "=", and find the token type before the "=" or "new". We just need to parse the whole statement line instead of partial statement. For example:

Code
int aaa = Ogre::Root::getSingleton().|


Till now, the currently implementation just do the analyze below:

Code
Ogre::Root::getSingleton().|

The code related in the nativeparser.cpp, in function
BreakUpComponents()..

see the code snippet:
Code
// Breaks up the phrase for code-completion.
// Suppose the user has invoked code-completion in this piece of code:
//
//   Ogre::Root::getSingleton().|
//
// This function will break this up into an std::queue (FIFO) containing
// the following items (top is first-out):
//
// Ogre             [pttNamespace]
// Root             [pttClass]
// getSingleton     [pttFunction]
// (empty space)    [pttSearchText]
//
// It also classifies each component as a pttClass, pttNamespace, pttFunction, pttSearchText
size_t NativeParser::BreakUpComponents(const wxString& actual, std::queue<ParserComponent>& components)

So, you can see, we will do a match algorithm one by one, from "Ogre" to "enpty space", and give the suggestion list. A more details can be find in the wiki.

BTW: There are a lot of features (till now, Loaden has released a lot CC patches), and we ( I and Loaden) are discussing about the Tokentree per project instead of Tokentree per workspace. Also, there are a lot of features of CC which we can improve.. We just need more help. :D
« Last Edit: April 26, 2010, 02:42:17 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 nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Code completion does not list enum members
« Reply #13 on: April 28, 2010, 05:56:40 am »
@ollydbg:

1, about the "=" operator

Code
int aaa = Ogre::Root::getSingleton().|

Till now, the currently implementation just do the analyze below:

Code
Ogre::Root::getSingleton().|


OH, no. borland C++ builder do this work, but I dislike it, since I't can't do 100% correct thing.

What I want is :

enum EE {e1,e2};
EE e1 =  // <-- here, I type a "space"
int e2 =  //<-- and here..

step1 : I type the "="
step2 : as you said, cc do a "left search". and find e1 is a enum, but e2 is a integer.
          in c++98, enum name is a namesapce...but cc allow we do this:
            EE e1 = EE::  //<--here , cc will show the item list. :)  but I have to delete "EE::" after.
          
step3 : for e1, it show the "enum items list". for e2, do nothing.
         so, the new function will have no bearing on " int aaa = Ogre::Root::getSingleton().| "

------------------
2, about "new" operator

As we known, cc have enough  "class inherited relation" information:

with the code :
Code
class B {};

class D1 : public B {};

class D2 :  B {};

class E : public D1 {};


cc got a very good parse result (look the image).  so what I want is :

Code
step1 :  E = new | << here I press the space key...
step 2 : cc do a parse, and found the "new" ,  and find the "=" ..and find the "E" .. NOW cc can easy to show a list seems like:
E = new |
            | E |
            | D1 |
            | B |

:)


--------------
I like C::B. and  thinks for you and Loaden do a lot work for c::b.
I hope I can do more work for c::b..
but I'm too busy .... :(.. and my english is too bad...:(((((

[attachment deleted by admin]
« Last Edit: April 28, 2010, 05:58:46 am by nanyu »