Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Contributions to C::B => Topic started by: pingf on March 14, 2009, 02:18:06 am

Title: About the Code Completion
Post by: pingf on March 14, 2009, 02:18:06 am
Hi,
I felt a little disappointed about the C::B's code completion,
e.g.
typedef struct tagABC
{
      int a;
      int b;
} ABC;
and the completion won't find the ABC's members!
so does the OPENFILENAME ,PAINTSTRUCT.......
however,
e.g.
struct M
{
     int a;
     int b;
};
M m;
it finds the m's members immediately!
Title: Re: About the Code Completion
Post by: ollydbg on March 14, 2009, 03:40:33 am
See this thread.

http://forums.codeblocks.org/index.php/topic,9225.msg65886.html#msg65886

I found this patch haven't applied.

Edit:
I investigate the source code in void ParserThread::HandleTypedef(), in parserthread.cpp. This file needs to be modified to parse C type typedef and struct correctly :D.
Title: Re: About the Code Completion
Post by: ollydbg on March 14, 2009, 08:47:46 am
In the beginning, it has these comments.
Code
void ParserThread::HandleTypedef()
{
    // typedefs are handled as tkClass and we put the typedef'd type as the class's
    // ancestor. this way, it will work through inheritance.

The typedef's type as the class's ancestor.

Here is my test code:
Code
class Ancestor{
    public:
    int m_aaaa;
    int m_bbbb;
};
class Child:public Ancestor {
    public:
    int m_cccc;
    int m_dddd;

};

int main()
{
    Child obj;
    obj. // works ok! all the four members will be shown.

    return 0;
}
See the screen shot below.

But the code below can't work.
Code

typedef class Ancestor{
    public:
    int m_aaaa;
    int m_bbbb;
} Parent;

//typedef class Ancestor Parent;


int main()
{
    Parent obj;
    obj. //Show nothing! works badly.

    return 0;
}
If the Parent was treated as Ancestor's parents(said by the comments), I think the public member of Ancestor should be shown. So, it can't work though it's inheritance.



[attachment deleted by admin]
Title: Re: About the Code Completion
Post by: pingf on March 14, 2009, 02:02:56 pm
See this thread.

http://forums.codeblocks.org/index.php/topic,9225.msg65886.html#msg65886

I found this patch haven't applied.

Edit:
I investigate the source code in void ParserThread::HandleTypedef(), in parserthread.cpp. This file needs to be modified to parse C type typedef and struct correctly :D.

THX a lot!
but,How to use the patch? [or install ,compile...whatever]
I'm just a beginner on C::B.
Title: Re: About the Code Completion
Post by: ollydbg on March 14, 2009, 02:17:40 pm
I'm examining the code.

In the parsethread.cpp line 1570, I enable the output to report a typedef token information.
Code
Manager::Get()->GetLogManager()->DebugLog(F(_("Adding typedef: name '%s', ancestor: '%s'"), components.front().c_str(), ancestor.c_str()));

It seems that when I parse the code like this:
Code
typedef class Ancestor{
    public:
    int m_aaaa;
    int m_bbbb;
} Parent;

Then the output is like this:
Code
Adding typedef: name 'Parent', ancestor: ''
Note that the ancestor is an empty string. This is the reason that code completion can't give the correct tooltips.

If the ancestor is string named "Ancestor", I think the code completion will work ok!
Edit: This has been confirmed, I just tested by assigning the ancestor = _T("Ancestor") , in the line 1564 of parsethread.cpp.

Code
    ancestor << typ;
    ancestor = _T("Ancestor");
then, the tips can show correctly.


I'm trying to solve it, but all the codes are hard to understand(currently no document were supplied), so, it will take times, also, I will enrich  the wiki page if I find the solution.

There is another issue: If I try to parse this code
Code
class Ancestor{
    public:
    int m_aaaa;
    int m_bbbb;
};
typedef class Ancestor Parent;
Then no typedef token was recognized. :(
Title: Re: About the Code Completion
Post by: ollydbg on March 14, 2009, 02:20:31 pm
See this thread.

http://forums.codeblocks.org/index.php/topic,9225.msg65886.html#msg65886

I found this patch haven't applied.

Edit:
I investigate the source code in void ParserThread::HandleTypedef(), in parserthread.cpp. This file needs to be modified to parse C type typedef and struct correctly :D.

THX a lot!
but,How to use the patch? [or install ,compile...whatever]
I'm just a beginner on C::B.
Apply a patch is something like you will build the code::blocks from it's source.
You can follow the wiki page
http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Windows#Code::Blocks_sources

also, I have wrote a page in

http://wiki.codeblocks.org/index.php?title=Code_Completion_Design

Title: Re: About the Code Completion
Post by: pingf on March 14, 2009, 03:16:44 pm
See this thread.

http://forums.codeblocks.org/index.php/topic,9225.msg65886.html#msg65886

I found this patch haven't applied.

Edit:
I investigate the source code in void ParserThread::HandleTypedef(), in parserthread.cpp. This file needs to be modified to parse C type typedef and struct correctly :D.

THX a lot!
but,How to use the patch? [or install ,compile...whatever]
I'm just a beginner on C::B.
Apply a path is something like you will build the code::blocks from it's source.
You can follow the wiki page
http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Windows#Code::Blocks_sources

also, I have write a page in

http://wiki.codeblocks.org/index.php?title=Code_Completion_Design


WOW!
It seems a little tough for me now!
if I had enough time, I will try.
Title: Re: About the Code Completion
Post by: ollydbg on March 16, 2009, 10:02:32 am
I try to solve this.
See this thread.
http://forums.codeblocks.org/index.php/topic,10241.msg70863.html#msg70863