Hello,
I have been working all night on the code completion plugin, and I have noted a few design flaws, but there is an easy workaround for all those I found.
Anyways, I was able to get code completion to work for unions (yay! everyone has been waiting for that), and I'm not stopping there. I've got it working for variables declared using the struct/class/union keyword ("zz" in the example) and for variables declared with a class/structure/union declaration ("aa", "bb", and "cc" in the example). It knows when it is a typedef or not. I'm making it work for structures inside structures. However, I am faced with one small (big) problem. The difference between languages, C and C++.
Example:
typedef struct {
struct s {
int value;
} aa;
} MyStruct;
struct MyOtherStruct {
int val;
} bb, cc;
struct MyOtherStruct zz;
In C, you can declare a variable of type s. But in C++, it has to be of type MyStruct::s. So I am wondering whether I should set s as global, as a child of MyStruct, or both?
Here's my patch: http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2566&group_id=5358
EDIT: Okay, this is my latest version. Spent the whole night on this, time to get a few minutes of sleep.
-- Wolf --
PS: If you need someone to work on the code completion module, I would be glad to help.
Okay, looks like today my patch causes CB to crash. I'll check that out later. It has no security checks, so it is very possible...
EDIT: Found the code responsible for the crash. It is what I was thinking I forgot to handle.
struct MyOtherStruct {
int val;
} bb, cc;
struct MyOtherStruct zz;
It doesn't handle yet declaring multiple variables after a structure declaration. Something very simple to handle... I'll do that soon.
I have fixed the problem, but not uploaded the patch yet patch uploaded, as I'm facing a new problem.
struct HiddenStruct {
int myval;
struct {
int value;
} bb;
};
struct HiddenStruct yy;
struct MyOtherStruct {
int val;
} bb, cc;
It adds 'bb' as a variable of type 'Unnamed-Struct-xxx' with 'HiddenStruct' as a parent.
Then, it adds 'bb' as a variable of type 'MyOtherStruct' with no parent.
And in the symbols browser, 'bb' doesn't show up in the variables. And in 'HiddenStruct', it shows 'bb' as 'MyOtherStruct' instead of 'Unnamed-Struct-xxx'.
If anyone could check this out, it would be appreciated.
Also, I don't really know why, but even if 'cc' is added (so it says in the log), it doesn't appear in the symbols browser.
When I initially load the file (or call a re-parse), it does appear, but when I save the file and the tree is updated, it disappears.
-- Wolf --
yy.bb. // shows val instead of value