Author Topic: Code completion don't work perfectly in the latest version?  (Read 9715 times)

Offline c2q1989

  • Single posting newcomer
  • *
  • Posts: 5
Code completion don't work perfectly in the latest version?
« 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!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Code completion don't work perfectly in the latest version?
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline c2q1989

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code completion don't work perfectly in the latest version?
« Reply #2 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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion don't work perfectly in the latest version?
« Reply #3 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. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline c2q1989

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code completion don't work perfectly in the latest version?
« Reply #4 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;
}

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Code completion don't work perfectly in the latest version?
« Reply #5 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline c2q1989

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code completion don't work perfectly in the latest version?
« Reply #6 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".

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Code completion don't work perfectly in the latest version?
« Reply #7 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion don't work perfectly in the latest version?
« Reply #8 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. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Code completion don't work perfectly in the latest version?
« Reply #9 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion don't work perfectly in the latest version?
« Reply #10 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. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline c2q1989

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code completion don't work perfectly in the latest version?
« Reply #11 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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion don't work perfectly in the latest version?
« Reply #12 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)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.