User forums > General (but related to Code::Blocks)

Suggestion: class browser improvements

(1/2) > >>

AkiraDev:
The built-in "Class Browser" has a fairly good support for classes, namespaces, class templates, etc., making it complete for common use.

However, I noticed a few situations in which there is still room for improvement. While using C::B for the development of a library I'm writing, which makes abusive use of some less commonly used C++ features such as partial template instantiation, I noticed how a few of my helper class templates, which are partially instantiated, show up in the class browser repeatedly. Example:

template<typename type, bool condition = false>
struct arr_conditional
{ ... };

template<typename type>
struct arr_conditional<type, true>
{ ... };

It appears that the template is correctly parsed, but there is no check as to whether a given template actually is a partial instantiation of a previously defined one - in this case, the class name suffices, of course. A good approach would be to store information on class templates in a relational way. (i.e., allowing to nest partial instantiations with the same class name under the most generic template). This would mean that the associated parser would need to keep track of template parameters - not evident at all, I know, but I'm willing to try to implement this myself.
Another thing I would like to know whether it is feasible, is to also list typedefs or show any aliases for a namespace next to its name.
Example (using same struct as above):

 [-] MyNamespace namespace (MyAlias)
  |
  ---[-] arr_conditional <typename, bool>
  |    |
  |    --- arr_conditional <typename> instantiation
  |
  --- typedef arr<double> array

I didn't see such an intelligent class browser in another IDE yet, and bet that C::B could be the first to get there.

EDIT: Please note, I also think that this could help further improvement of the code completion plugin.

Well, enough ranting for now. I apologize for the long post...

Best regards

mandrav:

--- Quote ---It appears that the template is correctly parsed, but there is no check as to whether a given template actually is a partial instantiation of a previously defined one - in this case, the class name suffices, of course. A good approach would be to store information on class templates in a relational way. (i.e., allowing to nest partial instantiations with the same class name under the most generic template).
--- End quote ---

Templates handling was added in beta7, so this makes it a new feature ;)
I guess that what you 're asking can be done, with a parsing-time penalty since more lookups will have to be made. Although, there is still room for improving the parsing time...


--- Quote ---This would mean that the associated parser would need to keep track of template parameters - not evident at all, I know, but I'm willing to try to implement this myself.
--- End quote ---

Woot! It seems that I 'll get help with this plugin  :lol:
If you want to take a peek, the actual parsing code is in plugins/codecompletion/parser/parserthread.cpp (ignore the ParseBufferForFunctions() function which just recognizes functions in .c/.cpp files and is used only by "View->Go to function").
I know it's not well-documented. I 'll try to document it better, after the next release. Until then, ask anything you need about it.


--- Quote ---Another thing I would like to know whether it is feasible, is to also list typedefs or show any aliases for a namespace next to its name.
--- End quote ---

Typedefs are not implemented yet.
As for namespaces, aliases are not supported either because they are using an equal "=" sign which is discarded by the tokenizer.
I.e.

--- Code: ---namespace MyNamespace // namespace definition
{
    int a_member;
};

namespace alias_name = MyNamespace; // namespace alias
--- End code ---

The tokenizer rejects everything after the equal sign. This means it should be hacked to support it only for namespaces...

Yiannis.

AkiraDev:
Hello again...

I've been taking a look at the CodeCompletion classes - although not in the finalbeta yet -, and gave some thought about what I might need to hack to get my desired templates functionality. It seems that by categorically tracking things like template parameters would make the parser somewhat bloated, as I would need to add containers to the Token* classes. OTOH, there also are points in which I might sacrifice code readibility for a little extra performance.

Personally, I was very fond of seeing the inclusion of caching in the C::B finalbeta version.

The bottom line is, I would need to make some fundamental modifications to it, and as such I think I'll try to hack my own version of the CodeCompletion plugin, something like an AdvancedCodeCompletion, which is specific for my needs.

Best regards

mandrav:

--- Quote ---The bottom line is, I would need to make some fundamental modifications to it, and as such I think I'll try to hack my own version of the CodeCompletion plugin, something like an AdvancedCodeCompletion, which is specific for my needs.
--- End quote ---

I 'll be waiting for your results :)

Yiannis.

brendon:
I'm looking at C::B and have downloaded the install exe with build date May 15 2005.

I've imported a (large) VStudio project and so far most things in C::B seem to be working alright. However, the code browser doesn't show any other namespaces other than the Global namespace.  Almost all of my classes are in other namespaces!

I note that the first post in this thread says that namespaces should be handled by the class browser. I'd appreciate any help in fixing the behaviour that I'm seeing!

Thanks!
Brendon

Navigation

[0] Message Index

[#] Next page

Go to full version