Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Is this something we can solve with the improved CC
killerbot:
Hi,
This code has had, and still has some problems with CC, more specifically with the 'find declaration' :
--- Code: ---#include <iostream>
class ITest
{
public:
virtual int Method1(int Arg) = 0;
};
class Test : public ITest
{
public:
int Method1(int Arg);
};
int Test::Method1(int Arg)
{
return Arg;
}
int main()
{
Test Hello;
std::cout << Hello.Method1(5);
return 0;
}
--- End code ---
Scenario :
1) right click Method1 in the call 'Hello.Method1(5)' and choose "find implementation' --> works nicely :-)
2) right click Method1 in the call 'Hello.Method1(5)' and choose "find declaration' --> gives me a choice :
--- Quote ---* the ITest declaration
* the Test declaration
--- End quote ---
I think since the parser should now that Hello is a Test variable, it should not allow me any choice, and automatically select the Test declaration one.
Is this something that can be fixed with the improved CC, or are we still missing something in our parsing/tokens list ?
blueshake:
Dear killerbot:
I dont think it is easy to do this.
For current parser.It will parse your test codes as this.
--- Quote ---ITest
|- Method1
Test
|-Method1
--- End quote ---
And for a faster seach,the parser just get the matched items from the tokenstree.so you can two items from your test codes.
It make no sense if you try to solve the expression,since Test is inherited from ITest.you still will get two items.One in ITest,the other in Test.
killerbot:if you get any idea about this.share it here,please. :D
I think it will be more harder for parse these codes:
--- Code: ---ITest* pHello = new Test();
--- End code ---
Even the codecompletion can not work correctly,not mention to others.
BTW:it is amazing that I can write so much English now. :lol: :lol: :lol:
ollydbg:
@killerbot
As blueshake said, the parsing tree (simply we can say the token tree, or AST) can be like:
--- Quote ---ITest
|- Method1
Test
|-Method1
--- End quote ---
Once using the find declaration on the statement: Hello.Method1(5).
In the current CC, I think there are some steps:
1, get the word under the caret, so, we return the "Method1"
2, then we do a search on the TokenTree( it is a trie structure, which store all the token names)
3, then we get all the tokens named "Method1", also, we filter the non-function tokens.
4, Then, we show "two result".
So, the more clever way is analysis the whole expression of "Hello.Method1()", and as you said, the parser knows that this is a function of the "Hello", and the parser also knows that "Hello" is type of class "Test", so, the member methods of "Test" should be searched first, then if the result is 0, we should search following the class inheritance hierarchy, in this case, the ITest class should be searched.
So, I think this bug can be fixed. :D
daniloz:
If I understand right what ollydbg says and if this is changed somehow in the CC to do what killerbot suggests, does it means that "find implementation" and "find declaration" would also be also to go directly to the relevant class function member in case of functions with same name in different classes?
For example, I have a Reset() function in several classes (more than 20, actually) and each time I do a "find declaration/implementation" I have to chose from a list which class I want.
So, if the whole expression of "Object.Reset()" is analyzed (as suggested by ollydbg), then the CC can go directly to the relevant Reset() function, right?
ollydbg:
--- Quote from: daniloz on April 14, 2010, 09:16:42 am ---
For example, I have a Reset() function in several classes (more than 20, actually) and each time I do a "find declaration/implementation" I have to chose from a list which class I want.
So, if the whole expression of "Object.Reset()" is analyzed (as suggested by ollydbg), then the CC can go directly to the relevant Reset() function, right?
--- End quote ---
Yes, 100% correct!!!
Navigation
[0] Message Index
[#] Next page
Go to full version