That would be the first thing we need to understand (with Eran's help, probably). What are the components we need use, where are the public interfaces not bound into LiteEditor. At the time I tried I used CodeLite, codelite_indexer, CxxParser, sqlite3 and wxsqlite3. I don't know if that has changed though...
NOTE: all the below is for my in-house code completion and not for clang
You can build a wrapper around the code completion without the need of the LiteEditor (the exe project).
I actually implemented that when creating my CC unit testing.
The unit test is a simple executable which links with the CC library "libcodeliteu.dll / libcodelite.so"
However, the unit testing are assuming that a sqlite database with all the symbols is already exists for it to use.
You can browse the SVN here:
http://codelite.svn.sourceforge.net/viewvc/codelite/trunk/CodeCompletionsTests/CCTest/cctest.cpp?revision=5407&view=markupInitializing the library is done like this:
// Here is a simple call flows to initialize the CC of codelite
////////////////////////////////////////////////////////////////
// First, we initialize the TagsManager class
// which is responsible for communicating with the parser thread
// and provides an easy API for the application level
// Set the path to the codelite_indexer binary
// For example, codelite installs codelite_indexer under /usr/bin
// so we path /usr/bin here
TagsManagerST::Get()->SetCodeLiteIndexerPath(wxT("/usr/bin"));
// Start the indexer
// If it will termiante or killed - the TagsManager class will restart it automatically for you
TagsManagerST::Get()->StartCodeLiteIndexer();
// Initialize some settings
wxFileName fn(wxT("/path/to/my/symbols/db.tags"));
TagsManagerST::Get()->OpenDatabase( fn );
// Initialize the parsing thread
// By setting some search paths and event handler to receive the various
// events
// You can set many flags here have a look at tags_options_data.h to see a complete list of flags
// Next, set some incldue and excelude paths
wxArrayString inclPath;
wxArrayString exclPath;
inclPath.Add(wxT("/usr/include/c++/4.4"));
inclPath.Add(wxT("/usr/include/c++/4.4/x86_64-linux-gnu"));
inclPath.Add(wxT("/usr/include/c++/4.4/backward"));
inclPath.Add(wxT("/usr/local/include"));
inclPath.Add(wxT("/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include"));
inclPath.Add(wxT("/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed"));
inclPath.Add(wxT("/usr/include"));
inclPath.Add(wxT("/usr/include/qt4/QtCore"));
inclPath.Add(wxT("/usr/include/qt4/QtGui"));
inclPath.Add(wxT("/usr/include/qt4/QtXml"));
inclPath.Add(wxT("/home/eran/wx29/include/wx-2.9"));
// Set the search paths and start the parser thread
ParseThreadST::Get()->SetSearchPaths(inclPath, exclPath);
//=======================================================
// Set the window that will receive the following events:
//=======================================================
// wxEVT_PARSE_THREAD_MESSAGE - update message from the parsing thread
// wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE - in case the application is managing a cache of the symbols,
// this events instructs the application that now is a good time to clear it
// wxEVT_PARSE_THREAD_SCAN_INCLUDES_DONE - this event indicates that scanning for include files to parse is completed, a complete list of headers
// to parse are included in the event data
// wxEVT_PARSE_THREAD_RETAGGING_PROGRESS - Retagging is in progress
// wxEVT_PARSE_THREAD_RETAGGING_COMPLETED - Retagging is done
// wxEVT_PARSE_THREAD_UPDATED_FILE_SYMBOLS - If you are managing "Tree Symbol" view - this event pretty much tells you to refresh it
// Of course, you set the notifiedWindow to NULL
ParseThreadST::Get()->SetNotifyWindow(NULL);
// Start the parsing thread
ParseThreadST::Get()->Start();
// To communicate with the parser, thread usually you simply call the TagsManager class
// Usage example:
///////////////////////////////////////
// Parsing list of files - quick retag: this means that only modified files since the last
// re tag
std::vector<wxFileName> files; // files are expected to have full path
// this method will not scan all non c-files (or files that their extension does not fit the TagsOptionsData class)
TagsManagerST::Get()->RetagFiles(files, false);
// Full retag: drop all the information stored in the database, and reparse the files
TagsManagerST::Get()->RetagFiles(files, true);
// Suggest completion for 'wxTheClipboard->'
// The output of the function is stored in 'tags'
std::vector<TagEntryPtr> tags;
TagsManagerST::Get()->AutoCompleteCandidates(wxFileName(wxT("/path/to/source/file/name.cpp")), // the full path for the input source file
1, // the line where the caret at
wxT("wxTheClipboard->"), // The requested expression to parse
fileContent, // The content of the file, up to do the caret position (in our example, an empty string will do)
// this is needed to parse for local variables
tags); // The output.
To create an executable, you need to link against:
Debug:
libCodeLiteud.dll;libwxsqlite3ud.dll
Release
libCodeLiteu.dll;libwxsqlite3u.dll
Under linux:
libcodeliteu.so;libwxsqlite3u.so
You can use the codelite_indexer.exe for Windows directly from SVN or build one by pulling codelite's sources and open the workspace /path/to/codelite/sdk/codelite_indexer/codelite_indexer.workspace
The clang completion is a different story and it is tightly coupled with the IDE itself - but this is not an issue for you guys, since you already got one in progress
Eran