Author Topic: CodeCompletion gets confused with "dot"?  (Read 15842 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
CodeCompletion gets confused with "dot"?
« on: January 20, 2006, 12:56:44 pm »
Dear all,
I am experiencing a very strange thing: In a project I instantiate a class in a method like this:
Code
SingularValueDecomp SVD(blah);
The class has several methods. So I tried using CodeCompletion as: "SVD.[STRG+TAB]" and nothing happens. The parser output shows:
Code
[12:37:43.060]: Doing AI for '        SVD.':
[12:37:43.060]: Pos=10408
[12:37:43.060]: NS: 'Rapid', PROC: 'TrainPreModel'
[12:37:43.060]: tok='SVD'
[12:37:43.060]: Looking for SVD under Rapid
[12:37:43.070]: Looking for SVD under Unknown
[12:37:43.070]: Token found SVD, type 'std::vector'
[12:37:43.070]: actual type is std::vector
[12:37:43.070]: searching under std
[12:37:43.070]: Class 'unknown'
[12:37:43.070]: Bailing out: class not found
Now if I try "SVD[STRG+TAB]" (without the dot) I see all methods and the output shows:
Code
[12:50:03.148]: Pos=10408
[12:50:03.148]: NS: 'Rapid', PROC: 'TrainPreModel'
[12:50:03.158]: Doing AI for '        SVD':
[12:50:03.158]: Pos=10408
[12:50:03.158]: NS: 'Rapid', PROC: 'TrainPreModel'
[12:50:03.158]: tok='SVD'
[12:50:03.158]: Scope='Rapid'
[12:50:03.158]: Procedure of class 'Rapid' (0x021b6324), name='TrainPreModel'
[12:50:03.168]: Checking inheritance of Rapid
[12:50:03.168]: - Has 0 ancestor(s)
Of course in this case I have to add the "dot" afterwards to seperate the method from the class which is annoying. What am I doing wrong here?
Best regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: CodeCompletion gets confused with "dot"?
« Reply #1 on: January 20, 2006, 02:36:50 pm »
I 've found and fixed a bug in codecompletion regarding this. Might wanna give it another try...
Be patient!
This bug will be fixed soon...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeCompletion gets confused with "dot"?
« Reply #2 on: January 20, 2006, 03:38:51 pm »
Might wanna give it another try...
I did (build 1823) now it works partially, but unfortunately for the class described it's the same. But: I have another information regarding this: It seems to happen only for this very single class. (I didn't realise this because currently I am only working on this specific one). I instantiated the class as SVD. Now this class has a member function with exactly the same name "SVD()" with a parameter and a return value (both std::vector<double>). I assume the plugin interprets this somehow as constructor because if you look at the log again there is:
Code
[12:37:43.070]: actual type is std::vector
where I wonder where this comes from.
The class is as follows in detail:
Code
class SingularValueDecomp
{
public:
  SingularValueDecomp();
  SingularValueDecomp(unsigned int);
  ~SingularValueDecomp();
  void ReInit(unsigned int);

  std::vector<double> SVD(std::vector<double> &);
  std::vector<double> Variance();
  std::vector<double> SVDSingVals();
  // and some other methods...
private:
  bool DoSVD();
  bool SingularValueDecomposition(std::vector< std::vector<double> > &);
  // and dome more...
};
Maybe this helps for now... I am doing further research on that topic tomorrow (I have to leave now, sorry).
Regards, Morten.
« Last Edit: January 20, 2006, 03:40:27 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeCompletion gets confused with "dot"?
« Reply #3 on: January 24, 2006, 12:29:47 pm »
I am doing further research on that topic tomorrow [...]
A bit late, but I hadn't have time until now. I have prepared an example that shows the strange behaviour. I narrowed it down as following: If I instantiate the class as a variable with the name of a (public?) member function CodeCompletion does not work.
Thus in the example CodeCompletion works for the instantiation of the class "MyClass" as "c" but not as "SVD". The instatiation of "MyDummy" works anyways. Maybe rickg22 should take a look at it, too. I've tried to understand the parsing some times ago but I see that there were many changes so I would start from scratch. Any help is appreciated.

Morten.

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: CodeCompletion gets confused with "dot"?
« Reply #4 on: January 25, 2006, 11:37:27 pm »
Code completion works by parsing the current file and trying to identify the token. Only then it searches in the tokens database.

The reason for this is that local variables are NOT identified in the main parsing. Functions and class methods are just scanned until the respective '}' is found.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeCompletion gets confused with "dot"?
« Reply #5 on: January 26, 2006, 02:40:15 pm »
The reason for this is that local variables are NOT identified in the main parsing. Functions and class methods are just scanned until the respective '}' is found.
Sorry Rick, I don't understand. Please have a look at my example attached to the previous message. In the function "main": If I write "SVD." (and wait) nothing happens. Hence If I write "c." the CodeCompletion window pops up showing me the methods of MyClass. This is the same with "d.". So the only difference is that I define the class "MyClass" as "SVD" in the first case and as "c" in the second case. The second case works with CodeCompletion, the first one not...
If I got you right that it shouldn't work in both cases, right? Maybe CodeCompletion can even more than it was supposed to do?
...I guess I'm missing something here...
Morten.
« Last Edit: January 26, 2006, 02:45:33 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: CodeCompletion gets confused with "dot"?
« Reply #6 on: January 26, 2006, 07:58:45 pm »
erm, what i meant to say, is that there are two parse phases:

phase "a" is done when the project is opened, and doesn't scan anything inside functions. I know this part very well.
phase "b" is done everytime you use codecompletion, and i don't know how this works.

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: CodeCompletion gets confused with "dot"?
« Reply #7 on: January 27, 2006, 06:33:08 am »
The phase b part seems to be the less stable part right now.