Code::Blocks Forums

User forums => Help => Topic started by: spoofer on December 31, 2005, 03:52:07 pm

Title: Code completion trouble
Post by: spoofer on December 31, 2005, 03:52:07 pm
Code
class foo
{
   public:
      foo(int, float);
      void bar(const char *);
};

int main()
{
   foo var(    // <-
   var.        // <-

   return 0;
}

I get nothing on those marked spots. I have following option checked: [follow global, follow local, parse preprocessor]. Plugin is checked to be loaded. Class explorer is working.
Title: Re: Code completion trouble
Post by: thomas on December 31, 2005, 03:55:20 pm
Save the file.
Title: Re: Code completion trouble
Post by: spoofer on December 31, 2005, 06:05:25 pm
I know about that. I saved after typing int main(), doesn't work.
Title: Re: Code completion trouble
Post by: thomas on December 31, 2005, 06:15:05 pm
I tried, it works just fine.

If you did save your file and it still does not work for you, then you very likely have no project.
Title: Re: Code completion trouble
Post by: spoofer on December 31, 2005, 06:22:04 pm
This is strange, functions works:

Code
class foo
{
   public:
      foo(int);
      void bar(float);
};

void func(double);

// <- file saved at this point

int main()
{
   func(       // <- works
   foo var(    // <- doesn't work
   var.        // <- doesn't work

   return 0;
}

EDIT: I'll try installing latest SVN from Ceniza. Should I manually remove some files (configuration)?
Title: Re: Code completion trouble
Post by: thomas on December 31, 2005, 07:11:18 pm
SVN uses an entirely different config than RC2, so nothing to do.
Title: Re: Code completion trouble
Post by: killerbot on December 31, 2005, 07:17:45 pm
I quickly tried this also :

class foo
{
   public:
      foo(int);
      void bar(float);
};

void func(double);

// <- file saved at this point

int main()
{
   func(       // <- works
   foo var(    // <- doesn't work  <------------------------- so I only have problems here
   var.        // <- works

   return 0;
}


I am using latest svn code (windows xp sp2)

EDIT :  probably the code completion does not know yet var is of type foo (maybe it updates only after a line has ended ?? I am not sure)
Title: Re: Code completion trouble
Post by: rickg22 on January 02, 2006, 11:55:56 pm
Apparently it confuses bar with a function, but I'd need to check. Anyway this is a very special case, where on declaration of the variable, you invoke the constructor. This is not a fault of the parser, but of the codecompletion module, because it does a different kind of parsing. So it's very probable this case hasn't been coded yet.
Title: Re: Code completion trouble
Post by: spoofer on January 04, 2006, 09:56:10 am
I messed around plugin settion; by disabling SmartSense I get:

Code
class foo
{
   public:
      foo(int);
      void bar(float);
};

void func(double);

int main()
{
   foo var(    // <- doesn't work (explained)

   foo(        // <- works ???
   var.        // <- works
   func(       // <- works

   return 0;
}
Title: Re: Code completion trouble
Post by: rickg22 on January 04, 2006, 05:44:20 pm
If anybody fixes this bug or problem or whatever, please tell me so i can merge the changes in my to-be-optimized copy.
Title: Re: Code completion trouble
Post by: Michael on January 04, 2006, 07:47:01 pm
class foo
{
   public:
      foo(int);
      void bar(float);
};

void func(double);

// <- file saved at this point

int main()
{
   func(       // <- works
   foo var(    // <- doesn't work  <------------------------- so I only have problems here
   var.        // <- works

   return 0;
}

I have also tried this code and saved where killerbot did.

foo var( did not work, but if I pressed ctrl+space bar, I get a list of possibilities:

Quote
class foo
function func(double):void

I have also remarked that sometimes I do not get the list of possibilities when I type e.g., var.. Or, the first time I get it (if not, I simply press ctrl+space bar), but if I skip and try a second time it does not work (even ctrl+space bar does not work) :?. But if I save the file and then retry, it works.

I use C::B SVN rev1648 (windows XP SP2).

Michael

PS.: It seems to me that the code between tt tags is now small again (babylon theme). Did something change?
Title: Re: Code completion trouble
Post by: K.I.L.E.R on January 07, 2006, 12:43:00 pm
I have a suggestion.
I solved most of my code completion troubles by disabling cache but leaving the option enabled that always updates cache.
Title: Re: Code completion trouble
Post by: Michael on January 07, 2006, 01:42:10 pm
I have a suggestion.
I solved most of my code completion troubles by disabling cache but leaving the option enabled that always updates cache.
Interesting :). Anyway, not a long-term solution, because if you disable the cache, why you need to update it?

Michael
Title: Re: Code completion trouble
Post by: K.I.L.E.R on January 07, 2006, 01:45:05 pm
Just in case. :)

I have a suggestion.
I solved most of my code completion troubles by disabling cache but leaving the option enabled that always updates cache.
Interesting :). Anyway, not a long-term solution, because if you disable the cache, why you need to update it?

Michael