Author Topic: modify codecompletion plugin to macro parser  (Read 18863 times)

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
modify codecompletion plugin to macro parser
« 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

Captions edit wxWidgets source

Captions  edit WTL source
« Last Edit: November 12, 2009, 03:17:31 pm by visualfc »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #1 on: November 10, 2009, 05:20:25 pm »
Great!!!!!
I will test it tomorrow morning, (now ,I need to go to bed)  :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #2 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).

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #3 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。
« Last Edit: November 11, 2009, 01:23:43 am by visualfc »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #4 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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #5 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
« Last Edit: November 11, 2009, 07:36:26 am by visualfc »

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #6 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.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #7 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?
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #8 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.


Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #9 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.

see the screen shot.this is codeblock's tip.

this is visual assist's tip.


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


« Last Edit: November 11, 2009, 11:28:12 am by blueshake »
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #10 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.
« Last Edit: November 11, 2009, 11:49:03 am by visualfc »

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #11 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
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: modify codecompletion plugin to macro parser (base for svn5859)
« Reply #12 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. :(
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: modify codecompletion plugin to macro parser
« Reply #13 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

[attachment deleted by admin]
« Last Edit: November 12, 2009, 04:43:54 pm by visualfc »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: modify codecompletion plugin to macro parser
« Reply #14 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]