Question about Code completion of CodeLite

Discussion about CodeLite development process and patches
ollydbg
CodeLite Curious
Posts: 2
Joined: Sat Aug 15, 2009 3:02 pm
Contact:

Question about Code completion of CodeLite

Post by ollydbg » Wed Dec 23, 2009 8:09 am

Hi, eran.
From the link CodeLite IDE LiteEditor/Setting Up Code Completion
It seems you have removed the "ctags" code from the CodeLite project. So all the parsing is done by your own parser?
Am I right?

By the way, I'm ollydbg, I have some interests to prove the CodeCompletion in CodeBlocks, so, is it possible to incorporate the new parser mechanism in CodeBlocks's CC plugin? thanks.

Edit:
Oh, I check the svn log, found that
- Fixed: if a file is taking more than 10 seconds to parse, the file's parsing is aborted (codelite_indexer is restarted) in addition if the parsing output is larger than 15MB, the file parsing is aborted and codelite_indexer is restarted
So, the codelite_indexer is still used if the parser failed?
ollydbg in CodeBlocks' forum

User avatar
eranif
CodeLite Plugin
Posts: 6089
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Question about Code completion of CodeLite

Post by eranif » Wed Dec 23, 2009 10:39 am

ollydbg wrote:t seems you have removed the "ctags" code from the CodeLite project. So all the parsing is done by your own parser?
Am I right?
Nope. codelite still uses ctags (codelite_indexer - a derived version of ctags (fixed parsing issues), using named-pipes/unix domain sockets to communicate with codelite IDE) to build an initial lookup-table.

The actual parsing of statements/expressions is done by the yacc grammar + custom code.

so if a user types this:

Code: Select all

wxString str;
str.AfterFirst().
the parsing is done in this manner:
1) resolve str - this is done by the yacc grammar to locate local variables
2) once str is resolved into wxString, codelite uses the lookup-table to locate all members/methods (including inheritance, etc.)
3) If a match is found from the lookup table to AfterFirst() - codelite analyzes the return code (in our example: wxString) - again, the lookup table is used to find a match for the return value type

The change that I did - I added another yacc grammar and created a "File Crawler" which scans files for include statements based on your current file and then passing this list of the files found to codelite_indexer for parsing.
the parsing results are then stored in the database for future use (along with timestamp which indicates when they were last parsed, so they will be skipped next time, unless they were modified)
ollydbg wrote:is it possible to incorporate the new parser mechanism in CodeBlocks's CC plugin? thanks.
It is possible, but it needs an effort (obviously) - the parsing code + the supporting mechanism are written in a single library which can be incorporated into any application.
If you need a start points, let me know

Eran
Make sure you have read the HOW TO POST thread

ollydbg
CodeLite Curious
Posts: 2
Joined: Sat Aug 15, 2009 3:02 pm
Contact:

Re: Question about Code completion of CodeLite

Post by ollydbg » Thu Dec 24, 2009 8:10 am

eranif wrote:
ollydbg wrote:t seems you have removed the "ctags" code from the CodeLite project. So all the parsing is done by your own parser?
Am I right?
Nope. codelite still uses ctags (codelite_indexer - a derived version of ctags (fixed parsing issues), using named-pipes/unix domain sockets to communicate with codelite IDE) to build an initial lookup-table.

The actual parsing of statements/expressions is done by the yacc grammar + custom code.

so if a user types this:

Code: Select all

wxString str;
str.AfterFirst().
the parsing is done in this manner:
1) resolve str - this is done by the yacc grammar to locate local variables
2) once str is resolved into wxString, codelite uses the lookup-table to locate all members/methods (including inheritance, etc.)
3) If a match is found from the lookup table to AfterFirst() - codelite analyzes the return code (in our example: wxString) - again, the lookup table is used to find a match for the return value type
Thanks for the explanation for the codecompletion algorithm, that's the quite the same as in CodeBlocks' CC, I have wrote these method in 5.3 Do an AI match. The most functionality are the same. ;)
eranif wrote: The change that I did - I added another yacc grammar and created a "File Crawler" which scans files for include statements based on your current file and then passing this list of the files found to codelite_indexer for parsing.
the parsing results are then stored in the database for future use (along with timestamp which indicates when they were last parsed, so they will be skipped next time, unless they were modified)
So, it seems the database generated can be used for "code completion", because only the Tokens in these files can be matched. Currently, Codeblocks doesn't have this file list (we can call it "include file dependency" ;) ), so, all the matching and resolve mechanism are done in the global Token tree.
eranif wrote:
ollydbg wrote:is it possible to incorporate the new parser mechanism in CodeBlocks's CC plugin? thanks.
It is possible, but it needs an effort (obviously) - the parsing code + the supporting mechanism are written in a single library which can be incorporated into any application.
If you need a start points, let me know
Eran
Currently, I think I don't have that ability to start a new CC plugin for CodeBlocks, it's too complex for me . :oops: , anyway, thank you very much for your reply and the contribution to the open-source world.
ollydbg in CodeBlocks' forum

Post Reply