Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: c2q1989 on February 15, 2013, 08:33:09 am

Title: Code completion don't work perfectly in the latest version?
Post by: c2q1989 on February 15, 2013, 08:33:09 am
Version: 12.11 (windows)
OS: Windows 8 x64

    I found C::B Editor cannot provide code-assist showing members when typing symbols like dot(.), arrow(->).

    For example, supposing that I have defined "vector<double> vec;". If I wanna use vec.begin() or vec.size(), I must complete the latter part by myself, i.e. begin() or size(). No code-assist is provided.

    I am not sure whether this could be a bug? Expecting your answer. Thanks!
Title: Re: Code completion don't work perfectly in the latest version?
Post by: oBFusCATed on February 15, 2013, 08:48:47 am
Please provide an example which reproduces the problem. It works for me.
But keep in mind that parsing templates and macro-expansions is not fully implemented.
Title: Re: Code completion don't work perfectly in the latest version?
Post by: c2q1989 on February 16, 2013, 07:14:11 am
I just began to learn C++ a few days ago. I find this problem occured when parsing templates.

I wonder why the bug haven't been fixed yet? No offense, but it seems to be strange. Other C++ IDE, like C-Free, could do this kind of job.
Title: Re: Code completion don't work perfectly in the latest version?
Post by: ollydbg on February 16, 2013, 08:35:12 am
I just began to learn C++ a few days ago. I find this problem occured when parsing templates.

I wonder why the bug haven't been fixed yet? No offense, but it seems to be strange. Other C++ IDE, like C-Free, could do this kind of job.
1, did you see this message:
Please provide an example which reproduces the problem. It works for me.
Tell us the exact problem you have.

2, Parsing C++ is not easy, especially the the code contains templates. (search the forum, there are many topics about this issue)
Currently, no c::b devs have the time or ability to implement this, although you can help c::b by supplying patches. :)
Title: Re: Code completion don't work perfectly in the latest version?
Post by: c2q1989 on February 18, 2013, 07:10:07 am
This example comes from Accelerated C++. I have underlined the problematic parts.

#include <algorithm>
#include <iomanip>
#include <ios>
#include <stdexcept>
#include <string>
#include <vector>
#include "grade.h"
#include "Student_info.h"

using std::cin;                          using std::setprecision;
using std::cout;                        using std::sort;
using std::domain_error;             using std::streamsize;
using std::endl;                         using std::string;
using std::max;                         using std::vector;

int main()
{
    vector<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;

    while (read(cin, record))
    {
        maxlen = max(maxlen, record.name.size());
        students.push_back(record);
    }

    // alphabetize the student records
    sort(students.begin(), students.end(), compare);

    // write the name and grades
    for (vector<Student_info>::size_type i = 0;
        i != students.size(); ++i)
    {
        // write the name, padded on the right to maxlen + 1 characters
        cout << students.name
             << string(maxlen + 1 - students.name.size(), ' ');
        // compute and write the grade
        try {
            double final_grade = grade(students);
            streamsize prec = cout.precision();
            cout << setprecision(3) << final_grade
                 << setprecision(prec);
        } catch (domain_error e) {
            cout << e.what();
        }
        cout << endl;
    }
    return 0;
}
Title: Re: Code completion don't work perfectly in the latest version?
Post by: oBFusCATed on February 18, 2013, 12:34:50 pm
Please use code tags, next time and also have you tried to use "using namespace" or "std::" with the special "using blabla" directives?
Title: Re: Code completion don't work perfectly in the latest version?
Post by: c2q1989 on February 20, 2013, 07:15:03 am
Thanks for your help! ;) The problem has been solved by using namespace.

 But I still hope that C::B could fully support "using std::blabla".
Title: Re: Code completion don't work perfectly in the latest version?
Post by: oBFusCATed on February 20, 2013, 09:50:29 am
But I still hope that C::B could fully support "using std::blabla".
Me, too.

ollydbg: Can you look at this problem?
Title: Re: Code completion don't work perfectly in the latest version?
Post by: ollydbg on February 20, 2013, 02:57:48 pm
But I still hope that C::B could fully support "using std::blabla".
Me, too.

ollydbg: Can you look at this problem?
It is a problem, should take time to solve, all those kind of c++ template related bug are hard to solve.
I mainly focus on other important parts of CC, e.g. code-completion testing frame work. :)
Title: Re: Code completion don't work perfectly in the latest version?
Post by: oBFusCATed on February 20, 2013, 03:03:32 pm
I don't think it is template related bug, but namespace related and currently we handle namespaces pretty bad.
Title: Re: Code completion don't work perfectly in the latest version?
Post by: ollydbg on February 20, 2013, 03:10:33 pm
I don't think it is template related bug, but namespace related and currently we handle namespaces pretty bad.
Ok, you're right, the namespace related bug, this is another dirty part of the CC. It's all about the scope/symbol/type resolution, but our parser does not have the power of a c++ compiler. :)
Title: Re: Code completion don't work perfectly in the latest version?
Post by: c2q1989 on February 22, 2013, 06:26:39 am
But I still hope that C::B could fully support "using std::blabla".
Me, too.

ollydbg: Can you look at this problem?

 ;D You guys are extremely nice! Hoping that I could be one member of your group someday.
Title: Re: Code completion don't work perfectly in the latest version?
Post by: ollydbg on February 22, 2013, 07:08:39 am
...
 ;D You guys are extremely nice! Hoping that I could be one member of your group someday.
Thanks for the encouragement.

If you really consider to become a C::B developer, you can start by supplying patches to fix bugs/add new features. (You need to try build C::B, and debug it)