Author Topic: Requirements / Guidelines for re-writing the Code Completion  (Read 118782 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Requirements / Guidelines for re-writing the Code Completion
« on: December 21, 2005, 05:28:14 am »
Requirements notation:

   This document occasionally uses terms that appear in capital letters.
   When the terms "MUST", "SHOULD", "MUST NOT", "SHOULD NOT", and "MAY"
   appear capitalized, they are being used to indicate particular
   requirements of this specification. A discussion of the meanings of
   these terms appears in RFC 2119.

For those who want to rewrite CodeCompletion using an existing C++ parser, here's what we should do:

(These guidelines are subject to change without notice)
  • It SHOULD be designed around the class browser: Classes, Functions, Variables, Enums, Preprocessor.
  • The code completion plugin MUST hold an in-memory structure (maps, arrays, whatever is necessary) to contain all the tokens. For example, a class would include member variables, methods, and the methods would include the local variables.
  • This structure MUST be independent from the GUI. It MUST be a container. All code MUST be done by another class, but it MAY include saving, reading / writing from cache, and necessary functions.
  • There SHOULD be a structure per development language in the project. It's no use mixing C++ and Perl tokens, it would only create confusion.
  • The codecompletion plugin SHOULD have modules for different languages, these modules would consist of thread-safe functions to add the tokens into the main structure.
  • The ParserThread (this part we'll keep, but with the necessary adaptations) will call the modules to parse the different files.
  • For classes, use of STL classes (like vector and map) is RECOMMENDED, but you MAY NOT use std::string. You MUST use wxString instead. Use of only the std::string compatibility functions is RECOMMENDED.

(Contributions to these ideas are welcome)
« Last Edit: December 21, 2005, 05:40:04 pm by rickg22 »

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #1 on: December 21, 2005, 11:42:38 am »
Should it use wxWidgets functions? like wxString and wxArray, etc.?
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #2 on: December 21, 2005, 12:04:50 pm »
I would use string and abstain from using wx containers to maximum extend possible.

There are three reasons for this:
1. wxString has std::string compatibility functions. If you use string, then you can do:
Code
#if USE_WXWIDGETS
  #include <wx/wx.h>
  #define string wxString
#else
  #include <string>
#endif
This will compile anywhere, with wx or without.

2. wx containers suck really bad. You cannot typedef them, you cannot declare them inside a class, they use obscure macros... Standard containers work really well.

Wait... did I say three?  :lol:
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #3 on: December 21, 2005, 01:23:37 pm »
2. wx containers suck really bad. You cannot typedef them, you cannot declare them inside a class, they use obscure macros... Standard containers work really well.

That's interesting :). Just a question. There are not problems by using standard containers with wxWidgets? Otherside, is not the use of std::string not adviced to be used with wxWidgets?

Michael

takeshimiya

  • Guest
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #4 on: December 21, 2005, 01:34:34 pm »
The picture is:

wxWidgets containers sucks.
STL containers are great.

wxString is great.
STL string sucks (written by english people, for english people).

So I agree with thomas: using STL containers, and using wxString, but trying to use the STL string compatible functions.
« Last Edit: December 21, 2005, 01:37:41 pm by Takeshi Miya »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #5 on: December 21, 2005, 02:03:18 pm »
The picture is:

wxWidgets containers sucks.
STL containers are great.

wxString is great.
STL string sucks (written by english people, for english people).

So I agree with thomas: using STL containers, and using wxString, but trying to use the STL string compatible functions.

STL Containers are good, that's right :), but wxWidgets advices not to use STL. I have had some problems by using STL, wxWidgets and std:string :(. Therefore, I am not sure it would be good by mixing containers. Anyway, I would be happy if I could use STL with wxWidgets without any problems :).

Michael

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #6 on: December 21, 2005, 02:14:05 pm »
I thought the devs of wxWidgets are planning to fully support STL in some version of wxWidgets (wasn't it for 3.0...)
But I agree that we should not mix STL and wxWidgets as long as wxWidgets doesn't fully support this...
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

takeshimiya

  • Guest
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #7 on: December 21, 2005, 02:17:20 pm »
Mm, what kind of problems you had? I mean, STL containers + wxString, instead of wxWidgets+std::string.

And anyways, wxWidgets 3.0 is planned to be release the next year, which will be very STL friendly.

wxWidgets currently advices not to use STL mainly because at the time of 2.0 release, the STL implementations were really bad, especially the MSVC6 one. But now the situation is better (less people using MSVC6 :)).

EDIT: mispunt won me :P

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #8 on: December 21, 2005, 02:35:27 pm »
Mm, what kind of problems you had? I mean, STL containers + wxString, instead of wxWidgets+std::string.

I have had cast problems, problems with STL vectors and linking problems. With some work I solved the cast and the vector problems, but I still could not linking my application in relaese, because of wxWidgets link errors.

And anyways, wxWidgets 3.0 is planned to be release the next year, which will be very STL friendly.

That's would be really good :D.

wxWidgets currently advices not to use STL mainly because at the time of 2.0 release, the STL implementations were really bad, especially the MSVC6 one. But now the situation is better (less people using MSVC6 :)).

Yes, MSVC6 has a real bad STL implementation. Better is to use STLport :). A lot of users solve their STL problems with MSVC6 by using it.


Concerning the use of templates or string class I would like to add that wxWidgets FAQ proposes a workaround if you want to use templates or the string class. But it does not help me by solving my problems :(.

Quote
There is nothing to stop an application using templates or the string class for its own purposes. With wxWidgets debugging options on, you may find you get errors when including STL headers. You can work around it either by switching off memory checking, or by adding this to a header before you include any STL files:

Code
#ifdef new
#undef new
#endif

Michael

takeshimiya

  • Guest
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #9 on: December 21, 2005, 02:48:51 pm »
I think they redefine (by default) the new operator, for debugging purposes, which I think can be safely turned off.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #10 on: December 21, 2005, 02:54:20 pm »
I think they redefine (by default) the new operator, for debugging purposes, which I think can be safely turned off.

Yes, it seems so. But still have some doubts in using STL with wxWidgets.

Michael

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #11 on: December 21, 2005, 04:13:52 pm »
I use STL a lot, because I hate wx containers. The blockallocator in Code::Blocks uses STL, the SVN plugin does, the Uservariable manager does... we compile tinyXML in STL mode, too (although we could do otherwise).  Rick uses STL in his new tree class, the AStyle plugin uses STL if I remember correctly...  just try and do a "find in files" on the project.

All you have to remember is to #undef new to undo the evil of wxWidgets   *shudders*
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #12 on: December 21, 2005, 09:26:24 pm »
I use STL a lot, because I hate wx containers. The blockallocator in Code::Blocks uses STL, the SVN plugin does, the Uservariable manager does... we compile tinyXML in STL mode, too (although we could do otherwise).  Rick uses STL in his new tree class, the AStyle plugin uses STL if I remember correctly...  just try and do a "find in files" on the project.
That's is interesting. My doubts are vanishing :D. Probably, the problems I have had by using STL and wxWidgets have another source(s).

Michael

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #13 on: December 27, 2005, 05:25:46 pm »
Here are another few:

Parsing MUST be done in a separate thread.
Several threads MAY be used.
The parser thread(s) MUST have lower priority than the main thread.
The parser MUST NOT do insane things from the main thread. Events MUST be handed to the worker thread and MUST be handled there.

These requirements address the fact that save all files currently freezes the application for half a minute if you have a dozen modified files open. This is because the parser walks through the tokens array one by one and removes one token at a time for every file saved (causing ~250.000 memcpy() calls on a memory block half the total size of the tokens array). Furthermore, due to thread synchronisation, execution resumes only after all files have been parsed.
It does not matter at all that the actual parsing runs in a separate thread, the GUI still freezes for a time which is clearly longer than necessary and longer than acceptable. This will not change, even if we  make parsing 500 times faster.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #14 on: December 27, 2005, 05:43:06 pm »
<i>These requirements address the fact that save all files currently freezes the application for half a minute if you have a dozen modified files open. This is because the parser walks through the tokens array one by one and removes one token at a time for every file saved</i>

THAT was what caused the freezes? Oh man! I knew it was bad, but not THAT bad! :?

I'll try to figure out how to fix it.
Edit: I'll post about this on another thread.
« Last Edit: December 27, 2005, 06:00:15 pm by rickg22 »

pass86

  • Guest
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #15 on: July 18, 2007, 05:22:16 am »
Like VisualAssistXv10.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #16 on: July 19, 2007, 11:02:07 pm »
I'm adding this link:

http://www.codeproject.com/showcase/VisualAssistX.asp

for reference, to see where we are and where we want to get.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #17 on: July 20, 2007, 12:03:43 am »
Out of STL vs wxWidgets debate:
Maybe it would be good idea to split current CC plugin into two plugins - one for actual code assisting and one for strict code parsing. If it will be done in this way, one can simply write parsing-only plugin to support extra language an thus allowing it inside assist window. And what's also nice about this - other plugins may use tree generated by parser plugin to do some magic - like CodeBrowser plugin (presented somewhere in this forum), becuase there's no use writing separate parser for each plugin that require some code analysis (and just imagine how much it could ease writing refactoring plugin).
Assist plugin could be developed separately giving better code assisting no matter what language is used.

What do you think ?

Regards
   BYO

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #18 on: July 20, 2007, 12:18:58 am »
Sounds great but I wonder if it would be easier and better to start from scratch than to split up the existing CC plugin. Because the CC plugin is already quite complex and I doubt that splitting it can easily be done without a lot of code-rewriting. Probably this will get worse if we try to give both separated plugins a good interface, but this would be needed. But this is just a guess, maybe someone who is more familier with the CC plugin than I am can say more about it :)
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

pass86

  • Guest
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #19 on: July 22, 2007, 10:28:19 am »
It needs to be running more quickly.

Offline patlecat

  • Multiple posting newcomer
  • *
  • Posts: 62
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #20 on: July 22, 2007, 11:38:46 am »
If you want to improve CB, toward what's the best CodeCompletion systems today, then orient yourself instead on Visual Slick Edit (go to Cool Demos). Not on an outdated VC plugin!

I began a project this summer for my employer to reimplement a server written in Perl on a new machine in C++. Target machine is Solaris10-Sparc. So I thought: Great I can develop on Windows with CodeBlocks and just move the files over and compile them there. But apart from the lack of Makefile support the biggest downer for me was the very incomplete support for CodeCompletion that helps you with new Code and Libraries!
So, after 3 weeks of struggling with CB I gave up and bought the excellent Visual Slick Edit.

I have used VSE for some years and have not come across a more convenient Editor since, including VisualC 6-8 ! So I really think that you should let yourself be influenced by this editor as the top notch on the market. Because I would love to use CB for everything as soon as possible!

One key of success is the excellent Tagging-System in VSE which allows you to add new interfaces anytime!
« Last Edit: July 22, 2007, 11:40:25 am by patlecat »

Offline Raindog

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #21 on: August 16, 2007, 09:41:39 am »
If you want to improve CB, toward what's the best CodeCompletion systems today, then orient yourself instead on Visual Slick Edit (go to Cool Demos). Not on an outdated VC plugin!

I began a project this summer for my employer to reimplement a server written in Perl on a new machine in C++. Target machine is Solaris10-Sparc. So I thought: Great I can develop on Windows with CodeBlocks and just move the files over and compile them there. But apart from the lack of Makefile support the biggest downer for me was the very incomplete support for CodeCompletion that helps you with new Code and Libraries!
So, after 3 weeks of struggling with CB I gave up and bought the excellent Visual Slick Edit.

I have used VSE for some years and have not come across a more convenient Editor since, including VisualC 6-8 ! So I really think that you should let yourself be influenced by this editor as the top notch on the market. Because I would love to use CB for everything as soon as possible!

One key of success is the excellent Tagging-System in VSE which allows you to add new interfaces anytime!

Well, if you define "superior" as not properly handing the most basic refactorings on code with templates (including renames), requiring "tag" files for code completion and not actual intelligent knowledge of the source, poor syntax highlighting and extremely outdated editor, then yeah, I would wholeheartedly suggest VSE over VAX.

VAX provides the following features:
* improved syntax highlighting.
* improved code completion. (as good as java or c# intellisense features).
* c/c++ refactoring.
* outline view of code that enables navigation to and re-arrangement of code from within the view.
* spell checking.
* quick templates.
* ability to find references to variables, functions, classes.
* supremely awesome code navigation features/shortcuts.

If anyone develops w/ Visual Studio and does not use VAX, you might as well code in notepad.

Offline patlecat

  • Multiple posting newcomer
  • *
  • Posts: 62
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #22 on: September 27, 2007, 09:39:26 pm »
You've got to be kidding me...

Offline AlekseyT

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #23 on: March 13, 2008, 04:59:45 pm »
May be better use sqlite (www.sqlite.or) for store current project information (parsed function, variable and so on). Back-end in background get all information and write it to database. Only back-end may write and delete information from sqlite database. Front-end(s) use database for reading. Front-end(s) can get information in one transaction (for get consistent information).

With this scheme developers can integrate other back-end (other parse engine) into CB. And plugin-developer can also easy get needed info from parser.

Offline stevenkaras

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #24 on: March 13, 2008, 10:38:23 pm »
May be better use sqlite (www.sqlite.or) for store current project information (parsed function, variable and so on). Back-end in background get all information and write it to database. Only back-end may write and delete information from sqlite database. Front-end(s) use database for reading. Front-end(s) can get information in one transaction (for get consistent information).

With this scheme developers can integrate other back-end (other parse engine) into CB. And plugin-developer can also easy get needed info from parser.

True. You should take a look at the wiki page, where you can find some more info on the C::C rewrite:
http://wiki.codeblocks.org/index.php?title=Code::Completion_Rewrite

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #25 on: December 26, 2008, 04:39:40 am »
Hi, everyone, I found another good IDE named Codelite which has functionality of code completion. I think we could learn from it. By the way, If would help to develop this plugin ( add something to support namespaces), how can I get involved?

It seems that some document? some guideline? and some plug in source code is need.

Thanks
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 Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #26 on: December 26, 2008, 09:22:03 am »
Integrating CodeLite's parser into Code::Blocks has been discussed before, but no one has dared to do it. eranif (CodeLite's developer) was helping us to some extent, and still no one decided to step forward, take the challenge and do it. Just search the forums, and you will see.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #27 on: December 28, 2008, 10:32:46 am »
Thanks.
Now, I have download the whole source code of codeblocks from svn. And I'm reading the code completion part. But it is difficult to read, because no document is supported :(....
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 cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Requirements / Guidelines for re-writing the Code Completion
« Reply #28 on: January 03, 2024, 09:30:44 am »
You guys could use std::u32string which is based on char32_t and can represent any UTF-32 char including obviously any UTF-8 char. With this you could make the IDE support even all Chinese ideograms. You could convert this type of string to the normal std::string which is based on char. And the interaction with wxWidgets is not a problem because you can convert from and to std::string and from there to wxString, std::string is considered a binary buffer of wider characters representation when converted from std::u32string. Furthermore, as std::u32string is based on char32_t you could make arrays of char32_t and used them equally as std::u32string or even a std::vector<std::u32string>.