Author Topic: Help me understand AutoCompletion and ...  (Read 21557 times)

Offline mmccarty12

  • Multiple posting newcomer
  • *
  • Posts: 28
Help me understand AutoCompletion and ...
« on: August 30, 2013, 06:32:33 pm »
how to use it properly.

It is my understanding that AutoCompletion is supposed to make our lives, the users of IDEs easier by showing options for a given set of characters in the edit windows.  What I believe it does is look up, from some sort of data structure, all available tokens consisting of characters available to the project or workspace. 

It seems to me to now work consistently.  I know from reading posts that local variables are not necessarily parsed when the project is parsed to create the data structure.  While a tad inconvenient, I can see the logic of the programmer(s) who created the system.  What I am not understanding is the part where it fails to pop up the available data members for classes and structures.  This system seems to work for any class or structure I have defined in my project, but does not work when working with a class like wxWidgets, upon which CB is built.  As the auto-complete does work, I feel that I am missing something in my project or application set up that determines what shows up when.  I am, of course, referring to the idea as has been displayed several times in these forums.  What I have not seen is any explanation as to what appears to work "sometimes" as some have put it. 

When I use a class like std::vector, I get none of the available functions or data structures for that class. 

EX in the CB editor:
Code
//   my.cpp
#include <vector>

typedef struct foo { int a }

int main(int argc, char** argv) {
  std::vector<int> v;
  v.

  foo f;
  f.
  return 0; }
At the point I hit the dot after the v, nothing shows up, but when I hit the . after the f the autocomplete box pops up and shows me that 'a' is a member of f. 

My question is thus: What do I need to do to make sure, when my project is parsed for autocomplete, all available members of a class are included in the list for a given class or struct?

I find it frustrating that the system does not show me the available members of the wxWidgets especially as CB is written using it.  I use wxWidgets exclusively for my projects and would like to not have to bounce between my work environment and the internet to find a specific function or data member for a wxWidget object.  As I said, I believe this has to do with the way the project or default applications setting are. 

As a side note, I went to Project -> Properties -> C/C++ parser and added the following lines to the folders I wanted added to the parse, but that seems to not be enough.
/mywidgetsfolder/wxWidgets-2.9.5/include/wx
/mywidgetsfolder/wxWidgets-2.9.5/include
It was enough to get things like wxALIGN_* to pop up with what is available, but does not work if I do the following.
Code
wxTextCtrl* tc = new wxTextCtrl(parent, NewControlId(), wxEmptyString);
tc->
[/[font=Verdana][/font]code]

Thanks
CB: SVN 9271  CentOS5

Offline anotherOpenGLFan

  • Single posting newcomer
  • *
  • Posts: 6
Re: Help me understand AutoCompletion and ...
« Reply #1 on: August 31, 2013, 05:28:05 pm »
For the auto completion, you can do:
    Settings->Editor->Code Completion (left side panel)->Update Parser While Typing (Code Completion tab, should be checked unless changed by the user)

Or, when you open up a project, you can:
    Right click the project->"Reparse Project"

Keep in mind, that it's parsing is not instantly done, it run's it in the background while your programming. And for large project's that include a lot of library's,
it might take a long time for it to finish parsing all the files. And there may be some quirk to it where it skip's over part's that it doesn't think need to be done,
and thus might not parse through "std::vector". I'm not sure, but I've experienced similar thing's from a variety of places, where it only work's "sometimes".
Personally, the best solution I've found is to know what your programming with. (And Google help's too.)

Offline mmccarty12

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Help me understand AutoCompletion and ...
« Reply #2 on: September 03, 2013, 09:31:41 pm »
I did what you said,
Settings->Editor->Code Completion (left side panel)->Update Parser While Typing
Right click the project->"Reparse Project"

I even added more c++ header files to be included as well as specific wxWidgets headers.  The project I am working on is currently small, only about 20 files total, but includes many wxWidgets widgets.  It still cannot parse the files.  I added the wxWidgets-2.9.5 folders into the Project -> Properties -> C/C++ Parser Options, and still cannot get it to properly parse any of the wxWidgets classes.

Is that a design feature, or is there some specific way to force CB to recognize and parse classes?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Help me understand AutoCompletion and ...
« Reply #3 on: September 03, 2013, 11:16:50 pm »
Are you on Windows or Linux? What version of C::B?

Anyway, something must be wrong with your setup because CC works pretty well for me on both Windows and Linux (I am using an April build). I get mostly accurate completion hints for instances of a large number of wxWidgets and STL classes. Keep in mind that heavily templated or macro'd stuff can cause problems.
« Last Edit: September 03, 2013, 11:18:33 pm by dmoore »

Offline mmccarty12

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Help me understand AutoCompletion and ...
« Reply #4 on: September 04, 2013, 09:35:53 pm »
CB: SVN 9271  CentOS5

And I know something is wrong with my setup, I am trying to find out what is wrong with my setup and fix it.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Help me understand AutoCompletion and ...
« Reply #5 on: September 04, 2013, 11:26:29 pm »
After I fixed the missing semi-colons in your example, code completion worked fine for me for both v and f. (It did not until I did that)

Offline mmccarty12

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Help me understand AutoCompletion and ...
« Reply #6 on: September 05, 2013, 03:20:48 pm »
Those were not errors, they were deliberately left in that state to show where the AutoCompletion popup should come up and didn't for the two examples. 

That still does not help solve my problem in any event.  I am trying to figure out why my AutoCompletion is not working correctly and you decided to play school marm and correct my homework.  Try something more helpful next time, like where I should go besides where I have already gone in my IDE setup.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Help me understand AutoCompletion and ...
« Reply #7 on: September 05, 2013, 04:37:07 pm »
"In your typedef, young man" corrected the School Marm.

(And make sure you save and compile -- I can't remember what is needed to trigger a reparse, but a save alone usually does it)
« Last Edit: September 05, 2013, 04:39:00 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Help me understand AutoCompletion and ...
« Reply #8 on: September 05, 2013, 05:24:32 pm »
In general, it doesn't help us to tell us your what your settings etc are if you are using broken code or a broken setup. CC should just work on a clean setup with libraries in places that the parser can find them.

1. Are you working from a clean install of CB with a clean CB configuration? If not, try that.
2. Are you trying to get CC working from a single standalone source file or in a project? If the former try the latter, because at least historically, CC typically works better for properly configured projects. (For e.g., CC uses project search directories to find headers)
3. Make sure you are doing your testing on the simplest possible project that you can successfully build and run.

As stated already, C::B's CC is far from perfect, but it should at least get you a decent amount of wx and the Standard Lib.


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Help me understand AutoCompletion and ...
« Reply #9 on: September 05, 2013, 10:57:25 pm »
Those were not errors, they were deliberately left in that state to show where the AutoCompletion popup should come up and didn't for the two examples.  

That still does not help solve my problem in any event.  I am trying to figure out why my AutoCompletion is not working correctly and you decided to play school marm and correct my homework.  Try something more helpful next time, like where I should go besides where I have already gone in my IDE setup.


Please try to feel not offended and don't get offending yourself !

Your code misses two semicolons (as dnoore wrote) and with this semicolons cc works correctly for me (adn obviously dmoore) and without them it does not.
Did you really believe dmoore does not recognize the deliberately missing semicolons at the lines the autocompletion did not work for you ?
Please do not blame the IDE or CC, even if it is far from being perfect (as written before), if it can not parse incorrect code.

Offline proxym

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help me understand AutoCompletion and ...
« Reply #10 on: November 05, 2013, 05:57:42 pm »
Settings->Editor->Code Completion (left side panel)->Update Parser While Typing
Right click the project->"Reparse Project"

I can't find "Code Completion" and "Reparse Project".

I have problem with auto completion too.

Code
wxTextCtrl* TextCtrl1;
...
TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
...
TextCtrl1->
No popup after "TextCtrl1->".
Project in attachment.

Code::Blocks 10.05.
Code completion 0.7.
wx2.8-headers 2.8.12.1-6ubuntu2
Ubuntu 12.04



[attachment deleted by admin]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Help me understand AutoCompletion and ...
« Reply #11 on: November 05, 2013, 07:39:11 pm »
Please use a more recent C::B.
The versin in Ubuntu's repo is outdated.
See the actual nightlies thread for more options (dmoore's and pasgui's ppa for Ubuntu).

Offline proxym

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help me understand AutoCompletion and ...
« Reply #12 on: November 06, 2013, 12:50:48 pm »
Please use a more recent C::B.
The versin in Ubuntu's repo is outdated.
See the actual nightlies thread for more options (dmoore's and pasgui's ppa for Ubuntu).

I updated code::blocks to version 12.11svn9156-0ubuntu1~presice ("code completion" 1.0) from pasgui's ppa.
Now autocompletion works fine. Thank you.