Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
some issues and requests
killerbot:
with all the improvements currently being made on the code completion, I wonder what of the following is possible to achieve.
All tests described here are carried out on the cc branch.
Consider the following code (compile with C++Ox support) :
--- Code: ---#include <iostream>
#include <vector>
#include <memory>
class Test
{
public:
Test() : mMember() {}
void DoSomething() {}
private:
int mMember;
};
class Confuse
{
public:
Confuse() {}
void DoSomething() {}
};
int main()
{
std::vector<int> MyInts;
MyInts.push_back(2);
MyInts.push_back(4);
Test MyTest;
MyTest.DoSomething();
Test* MyPointerToTest = new Test();
MyPointerToTest->DoSomething();
// time for smart pointers
std::unique_ptr<Test> MyUniquePointer(new Test());
MyUniquePointer->DoSomething();
std::shared_ptr<Test> MySharedPointer(new Test());
MySharedPointer->DoSomething();
std::auto_ptr<Test> MyAutoPointer(new Test());
MyAutoPointer->DoSomething();
delete MyPointerToTest;
return 0;
}
--- End code ---
Let's start with a current issue : hover over the "DoSomething" part of "MyTest.DoSomething();", right click and choose "Find declaration". CB offers you a choice, although there should be no choice, only the the Test::DoSomething() is a candidate, it however also offer the one from the class Confuse an an option. [same applies when starting from 'MyPointerToTest->DoSomething();"].
Next, hover over the "MyInts" part of "MyInts.push_back(4);", CB shows in the tooltip it is a vector, I guess it would be better to say it is a "vector<int>" ?
A similar remark applies for all the smart pointers, for example : hovering over "MyAutoPointer" tells you it is a auto_ptr, where auto_ptr<Test> would be better, right ?
And now on to the new requests.
When I type "MyAutoPointer->", the completion allows me to choose from the list of auto_ptr methods [eg. get, release, reset, ...], it would be very good if this list is extended with the list of methods of the wrapped pointer. Since smart pointers are a very good tool to write good software, it is now less nice (in CB) since you loose the completion of the original pointer.
For the other smart pointers in this example, there's nothing at all, so it would be nice, those also got supported and provide the same level of user friendliness [codecompletion wise] as auto_ptr,
that is smart pointer methods, and original pointer methods.
How feasible do the cc gurus think this is ?
Personally I think this would be a major benefit.
oBFusCATed:
--- Quote from: killerbot on August 17, 2010, 12:51:39 pm ---For the other smart pointers in this example, there's nothing at all, so it would be nice, those also got supported and provide the same level of user friendliness [codecompletion wise] as auto_ptr,
that is smart pointer methods, and original pointer methods.
--- End quote ---
-std=c++0x in gcc defines a macro (GCC_CPP_OX_EXPERIMENTAL or something like that) and probably the current parser doesn't define this macro, so the c++-0x additions to the STL are not parsed at all.
--- Quote from: killerbot on August 17, 2010, 12:51:39 pm ---How feasible do the cc gurus think this is ?
Personally I think this would be a major benefit.
--- End quote ---
+1
daniloz:
--- Quote from: oBFusCATed on August 17, 2010, 01:32:41 pm ---
--- Quote from: killerbot on August 17, 2010, 12:51:39 pm ---How feasible do the cc gurus think this is ?
Personally I think this would be a major benefit.
--- End quote ---
+1
--- End quote ---
+1 = 2
ollydbg:
--- Quote from: killerbot on August 17, 2010, 12:51:39 pm ---Let's start with a current issue : hover over the "DoSomething" part of "MyTest.DoSomething();", right click and choose "Find declaration". CB offers you a choice, although there should be no choice, only the the Test::DoSomething() is a candidate, it however also offer the one from the class Confuse an an option. [same applies when starting from 'MyPointerToTest->DoSomething();"].
--- End quote ---
I'm under big work load these days, so I delayed my reply. :D.
There are three major parts of CC
A. collect tokens
B. resolve statement
C. other improvement
The cc_branch till now has a lot of improvement in the first part A "correct tokens", we have add some functionality like:
1, one parser peer a project, this means a workplace can have several parser object and tokenstree, thus they don't intervene each other.
2, a NONE parser, which means if you open a file which does not belong to any project, then a NONE parser will be created and now, you can have the symbols tree for these files.
3, preprocessor handling can deal with #if #ifdef like directive, and to achieve this, you need some "up-front" file list, so that these files(there are a lot of #define in them) will be parsed before other files, thus, proprocessor handling can works better.
4, function like macro handling, we have really do some kind macro expansion
5, there are some patches to support reading the "template information", but they are not complete, they can only handle some template class declared in global namespace, also if there are typedef the template class there are some parsing errors.
6, there are other patches to tokenizer and parserthread class, Yes, there a lot patches included.
About Part B: expression(statement) solving
This is most thing about your question
1, we have introduce some new match algorithm(this can avoid some recursive call and make it faster), as you can see, a match is from the parent to child. like: objA.m_aaa.m_x, if you do a cc's suggestion list here, you need to match "objA", then match "m_aaa" in the result of "match objA"....
2, about the "template issue", only template class or template function under global workspace can works.
3, about the "find declaration issue", I remember you have complaint in Is this something we can solve with the improved CC, this is still not solved. The current implementation is just do a plain text match in the tokenstree, so you get a lot of functions of other class. I have a solution in that thread, but I'm not sure it is a best way, since no one give any comments in that post. :D
4, about the smart pointer issue, I have tried it several days, but it is complex because there are some "typedef" in the template class that make things more hard, e.g.
--- Code: ---template <typename T1>
class AAA
{
typedef T1 T2;
typedef T2 T3;
T3 function();
}
--- End code ---
This will make the match algorithm failed when dealing with "function". :D
Also, our algorithm to split a statement is not good compare to CodeLite(it use a lex/yacc grammar). :D
About part C (UI and other improvement)
1, smart tab jump
2, auto completion for preprocessor, include files ....
3, some code format adjust after autocompletion
4, Toolbar improvement
5, symbols tree for AAA.cpp and AAA.h which are not in the same directory.
6, some auto generated code improvement
7, a Parser Test project was added, so we can find the parser error more quickly
8, realtime parse(parse while editing) and reparse issue fix, also support wxsmith change of code.
9, ..... can be seen in the SVN Log message.
--- Quote ---Next, hover over the "MyInts" part of "MyInts.push_back(4);", CB shows in the tooltip it is a vector, I guess it would be better to say it is a "vector<int>" ?
--- End quote ---
This one, as you define the variable like this:
--- Code: ---std::vector<int> MyInts;
--- End code ---
once a variable token "MyInts" is added to the Tokenstree, it has some other infomations like: its type string is: std::vector, its template argument list string is<int>, so I think this issue can be resolved.
--- Code: ---A similar remark applies for all the smart pointers, for example : hovering over "MyAutoPointer" tells you it is a auto_ptr, where auto_ptr<Test> would be better, right ?
And now on to the new requests.
When I type "MyAutoPointer->", the completion allows me to choose from the list of auto_ptr methods [eg. get, release, reset, ...], it would be very good if this list is extended with the list of methods of the wrapped pointer. Since smart pointers are a very good tool to write good software, it is now less nice (in CB) since you loose the completion of the original pointer.
For the other smart pointers in this example, there's nothing at all, so it would be nice, those also got supported and provide the same level of user friendliness [codecompletion wise] as auto_ptr,
that is smart pointer methods, and original pointer methods.
--- End code ---
If I have a template class, then I found that it has a operator "->" defined, I can get the return type. As I said before, e.g.
--- Code: ---template <typename T1>
class AAA
{
typedef T1 T2;
typedef T2 T3;
T3 function();
T3 operator -> () .....
}
--- End code ---
the return type of the operator -> is quite different of the T1(because there are a lot of typedef), so it is not easy to solve this. But logically it can. :D, it just need a lot of time.
We are fighting some bugs in the latest cc_branch, some thread safe problem of the parser can cause the crash... it is also tough :D
Loaden:
Sorry, I was busy these days to make a significant improvement, patch size has reached 95KB, so have not noticed this post.
I will carefully review your proposed that these features, and as much as possible to achieve them!
Navigation
[0] Message Index
[#] Next page
Go to full version