Author Topic: several completion issues  (Read 7616 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
several completion issues
« on: September 30, 2010, 04:40:01 pm »
This is the test code (just your ordinary main.cpp) :
Code: [Select]
#include <iostream>


enum enumerA
{
bla_on,
bla_off
};

enum enumerX
{
bla_on_foo,
bla_off_foo
};

class BitA
{
public:
BitA(){}
void Set(enumerA value) {mValue = value;}
enumerA Get() const {return mValue;}
private:
enumerA mValue;
};


enum enumerB
{
enable,
disable
};


class BitB
{
public:
BitB(){}
void Set(enumerB value) {mValue = value;}
enumerB Get() const {return mValue;}
private:
enumerB mValue;
};


template<typename T>
class BitTemplate
{
public:
BitTemplate() {std::cout << "bit template intended for enums" << std::endl;}
void Set(T value) {mValue = value;}
T Get() const {return mValue;}
private:
T mValue;
};

template<>
class BitTemplate<bool>
{
public:
BitTemplate() {std::cout << "bit template intended for bools" << std::endl;}
void Set(bool value) {mValue = value;}
bool Get() const {return mValue;}
private:
bool mValue;
};

template<>
class BitTemplate<int>
{
public:
BitTemplate() {std::cout << "bit template intended for ints" << std::endl;}
void Set(int value) {mValue = value;}
int Get() const {return mValue;}
private:
int mValue;
};


int main()
{
BitA a;
BitB b;

BitTemplate<enumerA> Bta;
BitTemplate<enumerB> Btb;

BitTemplate<bool> Btbool;

BitTemplate<int> Btint;

    return 0;
}

Carry out all experiments on the line before "return 0;"

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: several completion issues
« Reply #1 on: September 30, 2010, 04:41:47 pm »
Issue 1 :

type :
Code: [Select]
a.Set(bla_

You will see it offers 4 possibilities, but it should only be 2, only the 2 from "enumerA", and not the ones from "enumerX"

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: several completion issues
« Reply #2 on: September 30, 2010, 04:43:57 pm »
Issue 2 :

Type :
Code: [Select]
Bta.Set(

It give in the tooltip 3 entries. But the following ones should not be there :
Set(bool value)
Set(int value)

It should only be : Set(T value) (see more on this in Issue3 below)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: several completion issues
« Reply #3 on: September 30, 2010, 04:45:17 pm »
Issue 3.

Closely related to Issue2, assume the 2 entries that should not be there would be gone, then it would show :
Set(T value)

But we already know it is a template instantiated with enumerA, so ultimately it should show in the tooltip :
Set(enumerA value)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: several completion issues
« Reply #4 on: September 30, 2010, 04:51:07 pm »
Improvement :

In case the parameter in a method whose turn it is to be entered is an enumeration, it might be interesting to directly show the completion drop down with the possible enum values, now you first need to type some first characters before the completion is going to help you.

a.Set(  --> show the drop down with the 2 enum possibilities instead of the tooltip saying it is an enumerA.

What do you think ?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5229
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: several completion issues
« Reply #5 on: October 01, 2010, 04:55:00 am »
Issue 1 :

type :
Code: [Select]
a.Set(bla_

You will see it offers 4 possibilities, but it should only be 2, only the 2 from "enumerA", and not the ones from "enumerX"

Dear killerbot, let me explanation how CC generate the suggestion list.
It is very simple:

1, find the current statement:

for this code:
Code: [Select]
a.Set(bla_We just do a backward search from the caret position, then stop at characters like "[" or "(" etc. So, in this case, we stop at "(", so, the actual statement we are interest is:
Code: [Select]
bla_
2, find a initial search scope, Now, we guess the statement "bla_" is in global namespace scope.

3, do a match in the search scope, so all the tokens in the global namespace with a prefix "bla_" will be listed as suggestion list.

From this algorithm, you can see that NO function argument information is used.


Here is another example code:
Code: [Select]
#include <iostream>

void bla_my_function();


enum enumerA
{
bla_on,
bla_off
};

enum enumerX
{
bla_on_foo,
bla_off_foo
};

class BitA
{
public:
BitA(){}
void Set(enumerA value) {mValue = value;}
enumerA Get() const {return mValue;}
private:
enumerA mValue;
};


BitA a;

a.Set(bla_)

You can see the screen shot, even the global function named "bla_my_function" will be in suggest list:


Solution:

The statement analyzer should be more powerful to detect the caret was locate between parentheses, thus, the function argument type information can be used to filter the suggest result. :D

Currently I have no idea how we can improved it, sure, we can, let me think carefully....



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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5229
Re: several completion issues
« Reply #6 on: October 04, 2010, 09:45:48 am »
I know nothing has been done on this issues, but today due to rev 6663 ( or 6662), things got a little bit worse.

When I type :
Code: [Select]
Bta.Set(bla_
Nothing is suggested anymore.
« Last Edit: October 04, 2010, 09:52:49 am by killerbot »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: several completion issues
« Reply #7 on: October 04, 2010, 11:16:58 am »
I know nothing has been done on this issues, but today due to rev 6663 ( or 6662), things got a little bit worse.

When I type :
Code: [Select]
Bta.Set(bla_
Nothing is suggested anymore.
This is new issue from r6660.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: several completion issues
« Reply #8 on: October 04, 2010, 02:05:01 pm »
I know nothing has been done on this issues, but today due to rev 6663 ( or 6662), things got a little bit worse.

When I type :
Code: [Select]
Bta.Set(bla_
Nothing is suggested anymore.

I knew,will be fixed soon.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: several completion issues
« Reply #9 on: October 04, 2010, 03:03:03 pm »
had send patch to Loaden,and should be fixed.enjoy it. :P
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: several completion issues
« Reply #10 on: October 04, 2010, 03:35:18 pm »
had send patch to Loaden,and should be fixed.enjoy it. :P
applied! thanks! :)

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: several completion issues
« Reply #11 on: October 04, 2010, 07:02:40 pm »
lol, you guys are fast  :D