User forums > Help
Code completion does not list enum members
ollydbg:
--- Quote from: alberto 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!
--- End quote ---
Hi, what you want is not implemented in CC. here, when you type:
--- Code: ---Tr_Scroller_Dynamic =| // your caret are here
--- End code ---
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
--- End code ---
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
nanyu:
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.
ollydbg:
@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().|
--- End code ---
Till now, the currently implementation just do the analyze below:
--- Code: ---Ogre::Root::getSingleton().|
--- End code ---
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)
--- End code ---
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
nanyu:
@ollydbg:
1, about the "=" operator
--- Quote from: ollydbg on April 25, 2010, 04:59:37 pm ---
--- Code: ---int aaa = Ogre::Root::getSingleton().|
--- End code ---
Till now, the currently implementation just do the analyze below:
--- Code: ---Ogre::Root::getSingleton().|
--- End code ---
--- End quote ---
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 {};
--- End code ---
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 |
:)
--- End code ---
--------------
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]
Navigation
[0] Message Index
[*] Previous page
Go to full version