Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: chenjl on April 22, 2015, 08:49:35 am

Title: When I use std::map or std::vector iterator,it can not remind...
Post by: chenjl on April 22, 2015, 08:49:35 am
eg.
Code: cpp
#include <iostream>
#include <map>
#include <vector>
struct Info
{
string name;
int age;
};

int main()
{
vector<Info*> vecInfos;
Info* p = new Info;
p->name = "account1";
p->age = 28;
vecInfos.push_back(p);
p = new Info;
p->name = "account2";
p->age = 17;
vecInfos.push_back(p);


vector<Info*>::iterator itVec = vecInfos.begin();
while (itVec != vecInfos.end())
{
cout << itVec->name /* at here */
<< itVec->age /* and at here */
<< endl;
}

map<string, Info*> mapInfos;
p = new Info;
p->name = "test1";
p->age = 21;
mapInfos.insert(make_pair(p->name, p));

p = new Info;
p->name = "test2";
p->age = 22;
mapInfos.insert(make_pair(p->name, p));

map<string, Info*>::iterator itMap = mapInfos.begin();
while (itMap != mapInfos.end())
{
cout << itMap->first /* at here */
cout << itMap->second->name /* at here */
}
return 0;
}
the codeCompletion can't display 'first','second',and the Members of struct Info.
If there are a lot of members for struct or class;
I'll feel Coding difficult;
Title: Re: When I use std::map or std::vector iterator,it can not remind...
Post by: ollydbg on May 03, 2015, 04:10:50 pm
This is a known bug of our CC, it can't handle the template related code very well.
Currently, you can use the clang based code completion plugin. Or help us by supplying patches ;)
Title: Re: When I use std::map or std::vector iterator,it can not remind...
Post by: jat1 on May 24, 2015, 02:02:46 am
Is anyone currently working on improving the template related code? If not, I'll work on it and come up with a solution for this issue.
Title: Re: When I use std::map or std::vector iterator,it can not remind...
Post by: ollydbg on May 24, 2015, 03:06:33 am
Is anyone currently working on improving the template related code? If not, I'll work on it and come up with a solution for this issue.
Hi, jat1. I think currently no one is working on the template related part of the parser and the codecompletion. It was two or three years ago that someone like blueshake, me, loaden worked on that parts. It is quite complex as I know, so if any question, ask here. Thanks.
Title: Re: When I use std::map or std::vector iterator,it can not remind...
Post by: padget on May 28, 2015, 08:22:25 pm
Indeed, with the new standart (11 and 14), the template is better than before. The code completion for template is very important for me (I use exclusively template :D).
 jat1, Thanks in advance if you work on that subject !
Title: Re: When I use std::map or std::vector iterator,it can not remind...
Post by: ollydbg on June 19, 2015, 04:16:27 pm
Good news: with revision 10339, I commit jat1's great patch to handle template related code completion(see the test file added in this revision). Many thanks to Jat1!!!

To handle the iterator related code completion, we may need to improve the parser on how to parse a statement.
Code
(*it).|      code suggestion here

Now, we need some operator precedence parser. (currently, we can only handle some pattern like AAA::BBB().CCC). In the above statement, we may have three steps:
1. solve the "it" -> result1
2, solve the operator * of result1 -> result2
3, list all the children of result2 -> result3

Title: Re: When I use std::map or std::vector iterator,it can not remind...
Post by: jat1 on June 19, 2015, 06:16:46 pm
Thanks ollydbg. This issue as well as code refactoring are my next projects. I'll start looking into these.