Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: AkiraDev on May 13, 2005, 09:29:53 am

Title: Suggestion: class browser improvements
Post by: AkiraDev on May 13, 2005, 09:29:53 am
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
Title: Suggestion: class browser improvements
Post by: mandrav on May 13, 2005, 10:12:15 am
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).

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.

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.

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

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

Yiannis.
Title: Suggestion: class browser improvements
Post by: AkiraDev on May 18, 2005, 08:21:50 pm
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
Title: Suggestion: class browser improvements
Post by: mandrav on May 18, 2005, 09:37:00 pm
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.

I 'll be waiting for your results :)

Yiannis.
Title: Suggestion: class browser improvements
Post by: brendon on June 08, 2005, 04:41:58 am
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
Title: Suggestion: class browser improvements
Post by: brendon on June 14, 2005, 12:52:44 am
I see what my problem was - the class browser shows the CURRENT ACTIVE PROJECT only.  Which kind of makes sense.

In VStudio though, it's possible to have your projects depending on other projects. In this case, you might want to have the class browser show all projects in the workspace.  Is it possible to do this?  Is it a setting that I have missed?

Cheers,
Brendon
Title: Suggestion: class browser improvements
Post by: mandrav on June 14, 2005, 08:35:15 am
Quote
Is it possible to do this? Is it a setting that I have missed?

No, it's just not implemented.

Yiannis.