Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: visualfc on November 10, 2009, 05:16:55 pm

Title: modify codecompletion plugin to macro parser
Post by: visualfc on November 10, 2009, 05:16:55 pm
codecompletion plugin Inadequate
1. macro not parser
2. template<> not parser
3. class member method : MyClass::onTest(int i, int j) != MyClass::onTest(int k, int j)

I look at the above Issue and modify codecompletio plugin. the source based for svn5859( time 2009-11-10)

modify for next function :
*) macro parser .
   example BEGIN_EVENT_TABLE ...
*) template <> class parser
*) member method parser
   example OnAbout(wxCommandEvent& event) == OnAbout(wxCommandEvent& WXUNUSED(event))

download source and window bin:
http://code.google.com/p/visualfc/downloads/list (http://code.google.com/p/visualfc/downloads/list)

Captions edit wxWidgets source
(http://www.cppblog.com/images/cppblog_com/visualfc/HelloWX.PNG)
Captions  edit WTL source
(http://www.cppblog.com/images/cppblog_com/visualfc/HelloWTL.PNG)
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: ollydbg on November 10, 2009, 05:20:25 pm
Great!!!!!
I will test it tomorrow morning, (now ,I need to go to bed)  :D
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: Jenna on November 11, 2009, 12:09:13 am
I did not dig into it deeper (not so familiar with cc), but some remarks.

To make it compile on linux I had to change the type of GetRealArgs from TCHAR to wxChar and the type of the variable ptr in GetRealArgs also.

Find declaration and Find implementation (from context-menu) seems to be partially broken (it does not work for functions) , only tested some random functions and variables.
From symbols browser it works.

Searching in symbols browser is partially broken: if I search for Mgr (if C::B's project-file is open), it shows me the selection-dialog, but chosing any of the entries always jumps to the root-entry (Symbols).

As written, I only did a quick test on linux (debian 64-bit, wx 2.8.10, gcc 4.3.4).
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: visualfc on November 11, 2009, 01:15:11 am
Sorry!

The source only to make and build for Window and Test.

Searching in symbols browser is bug, I will try to repair the。
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: ollydbg on November 11, 2009, 05:52:05 am
Here is my comments:

1, it seems you just let the template argument appending to the "Token name", in my opinion, that is not a good idea, because it will disorder the Token tree, because the Token name is the tree's search key.

2, In the tokenizer.cpp , it seems you just regard every statement like "A(xxx) B(yyyy)" as Macros, that's may breaking of parsing some statement.

3, In tokenizer.cpp, when you read the "template arguments", I think the nestlevel should be considered. I think, from a moduality point, the related code can move from "tokenizer" class to "parserthread" class.

Anyway, Thanks for your efforts.
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: visualfc on November 11, 2009, 07:34:44 am
I already changes the template<> class for browse. the code update for top download

Make new GetRealArgs to supper class member method parser

   example OnAbout(wxCommandEvent& event) == OnAbout(wxCommandEvent& WXUNUSED(event))

The macro parser:
First test the name is all upper then parser to macro. while there are some global function , but the most of the remaining is correct
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: blueshake on November 11, 2009, 08:14:04 am
hi,visualfc
in this statement,
Code
static wxString GetRealArgs(const wxChar * args 
why not use statement like this
Code
static wxString GetRealArgs(const wxString& args)

I just have a quick review on the codes.I don't understand why doing this.
Code
 newToken = TokenExists(newname+realArgs, localParent);
the reason is just as ollydbg said above,
Quote
1, it seems you just let the template argument appending to the "Token name", in my opinion, that is not a good idea, because it will disorder the Token tree, because the Token name is the tree's search key.
since you have save the template args in m_RealArgs.

I think it is better to do this
Code
newToken->m_Type = readType + m_RealArgs;
for better token hover tip.
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: blueshake on November 11, 2009, 08:31:26 am
hi,it seems the template has not worked.
Code
struct qq
{
    int x;
    int y;
};
template<typename aa>
class xx
{
    aa tt;
};

xx<qq> oo;

oo.tt.-------not tip

did I miss something?
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: visualfc on November 11, 2009, 10:37:32 am
@blueshake

I‘m sorry, I'm not English,can only guess what you mean, Similarly, do not know whether the right to write.

The code GetRealArgs is portable code, keep compatibility. I would like to improve the quality of the code。

The code tokenExists(newname+realArgs,...) to ensure that function name unique.The reason is to search class method name.
I will try to the code newToken->m_Type = readType + m_RealArgs;


@blueshake
the template<> already parser, but don't visible on browser tree. only on code search can be find.

Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: blueshake on November 11, 2009, 11:24:19 am
Quote
@blueshake
the template<> already parser, but don't visible on browser tree. only on code search can be find.

hi,Can you provide the codes.For me ,the code suggestion list don't show me the "x" and "y" in the class "qq"body but visual assist worked.
see the screen shot below.
(http://www.ikaca.sh.cn/attachment/200911/11/1745_1257934231AdEK.png)
see the screen shot.this is codeblock's tip.
(http://www.ikaca.sh.cn/attachment/200911/11/1745_1257933705f4ej.png)
this is visual assist's tip.
(http://www.ikaca.sh.cn/attachment/200911/11/1745_1257933706D1m4.png)

see,visual assist can find the right type for oo.tt. I think this is why visual assist can work and codeblock didn't.


Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: visualfc on November 11, 2009, 11:40:12 am
I understand what you mean, But my code did not complete this function.
Is only able to identify the class type is or not  template class type. Is not parser a variable.
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: blueshake on November 11, 2009, 03:50:05 pm
@ollydbg
After some talk with visualfc .He told me the qt creator can parse template and it is open sources.I think we can learn some thing from it. :D
Title: Re: modify codecompletion plugin to macro parser (base for svn5859)
Post by: ollydbg on November 11, 2009, 04:30:06 pm
@ollydbg
After some talk with visualfc .He told me the qt creator can parse template and it is open sources.I think we can learn some thing from it. :D
I have already know that, you can see the links of this wiki page:

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

Actually, I have downloaded the source code of QT creator, but the source code is not easy to read. :(
Title: Re: modify codecompletion plugin to macro parser
Post by: visualfc on November 12, 2009, 03:20:32 pm
Update source.

Remove name+realArgs mode
Code
newToken = TokenExists(newname+realArgs, localParent);

To make and build on ubuntu9.10 bit32

download source and window bin:
http://code.google.com/p/visualfc/downloads/list (http://code.google.com/p/visualfc/downloads/list)

[attachment deleted by admin]
Title: Re: modify codecompletion plugin to macro parser
Post by: oBFusCATed on November 12, 2009, 04:31:10 pm
Kdevelop4 should have the best c++ parser of all OSS IDEs, look their svn for the source:)
But in my opinion the only path for CB's code-completion is using the clang's libs.
Title: Re: modify codecompletion plugin to macro parser
Post by: ollydbg on November 12, 2009, 04:36:00 pm
Kdevelop4 should have the best c++ parser of all OSS IDEs, look their svn for the source:)
But in my opinion the only path for CB's code-completion is using the clang's libs.


hi, what does "clang's libs" mean? I have googled that, but can't find the resource. Can you explain a little? Thanks.
Title: Re: modify codecompletion plugin to macro parser
Post by: MortenMacFly on November 13, 2009, 12:12:24 pm
hi, what does "clang's libs" mean? I have googled that, but can't find the resource. Can you explain a little? Thanks.
I guess he meant ctags.
Title: Re: modify codecompletion plugin to macro parser
Post by: eranif on November 13, 2009, 12:28:40 pm
He meant this:

http://clang.llvm.org/ (http://clang.llvm.org/)

Eran
Title: Re: modify codecompletion plugin to macro parser
Post by: ollydbg on November 13, 2009, 01:12:19 pm
He meant this:

http://clang.llvm.org/ (http://clang.llvm.org/)

Eran
Thanks for the hint.
It seems it is a strong compiler which can give more details than the normal compiler. I'm not sure it can replace the CC plugin.

It is just like the Intel compiler, which can give the caret position to the error statement position.
Title: Re: modify codecompletion plugin to macro parser
Post by: eranif on November 13, 2009, 02:17:30 pm
llvm seems like a nice project, but it does not fully support C++ atm (actually I think C::B parser supports more than clang does).

The problem with c-lang is that it is sponsored by big corporates like Apple and they will push it towards they directions (Objective-C/++) so dont expect to get a full CodeCompletion on silver plate ;)

Here is the C++ status of that project:

http://clang.llvm.org/cxx_status.html (http://clang.llvm.org/cxx_status.html)  - scroll down and see how in-complete it is atm

Eran
 
Title: Re: modify codecompletion plugin to macro parser
Post by: ollydbg on October 25, 2010, 07:47:04 am
llvm seems like a nice project, but it does not fully support C++ atm (actually I think C::B parser supports more than clang does).

just a reminder:

http://clang.llvm.org/cxx_status.html

seems Clang now fully support C++ in the Parser stage.

Maybe, we could use it to support code-completion. :D