CodeLite Overview
Preface
In this document I will provide an overview of the
CodeLite library and
how it interacts with LiteEditor.
General
CodeLite is the library
which LiteEditor uses to get CodeCompletion to work. It is based on the free
open source tool - ctags
(http://ctags.sourceforge.net
) to create a symbols database which in turn can be queried to retrieve entries
(hereon, tags). The database is based the open source library SQLite
(http://sqlite.org), hence
the name, CodeLite.
The interaction with ctags is done using a separate thread.
To complete the functionality,
CodeLite adds its own
parsers (see below). The in-house parsers are currently for C/C++ only and will
probably will expand in coming future for other
languages as well.
Overview
The below diagram describes
CodeLite interaction
with the IDE:
CodeLite interaction with
LiteEditor
LiteEditor interacts with
CodeLite, in the
following events:
-
OnCharAdded - user inserted a char, and that char is one of: '.', '->',
'::' or '('
-
User saved a file
Event: User saved a file
When a file is saved, a request is sent to
CodeLite's parsing
thread (which is invoked automatically by the library when it is initialized)
containing the following information:
-
The file name - the modified file's name
Sequence of events (see diagram):
-
User saved a file - the main thread, puts a request on
CodeLite's parsing
thread with containing the saved files' name
-
The parser thread is woken up by the request:
- Load all tags from the database that are belong this the file name
(something like: 'select * from tags
where file='FILE_NAME'), the results are then kept in memory for
later usage
- Delete all tags from the Workspace Symbols's database that belongs to the
modified file
-
CodeLite sends a
new parse command to ctags, Once ctags is done,
CodeLite compares
the old tags (from step 2) and the new entries - as returned from ctags
-
The new tags are stored into the database
-
An event containing the difference between the old and new tags is sent to
the UI to update the Outline View
Event: OnCharAdded
This event is fired whenever a user adds a character to the document. In
case the character is one of the following:
-
'>' - and previous char was '-'
-
'.'
-
':' - and previous char was ':'
-
'('
CodeLite is invoked
directly (not via the parsing thread) to try and resolve the expression. For
example:
After the '.', or any of the above characters for that matters, is typed,
LiteEditor passes
CodeLite the following
parameters:
-
The text up to the point where the caret is placed (in the above example:
'wxString str; str.')
-
The expression where the '.' was found (in the above example:
'str.')
The sequence of events from this point (see diagram):
-
LiteEditor passes
CodeLite the 'text'
and the 'expression'
-
CodeLite processes
the text and expression - the parsing is done using the yacc based parsers
(see below), and by using the symbols database (queries are made against
both
the external and the workspace database), if parsing is successful, a list
of tags is then returned to LiteEditor - which in turn displays them to the
user in the completion box