Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
CC enhancements/alternatives
MortenMacFly:
--- Quote from: ollydbg on February 07, 2012, 07:12:46 am ---CodeLite now integrates the Clang codecompletion feature.
--- End quote ---
Yes, I know. It seems you can use either one, or even both.
--- Quote from: ollydbg on February 07, 2012, 07:12:46 am ---You want to wrap Codelite's CC, do you mean the "original CC in Codelite" or "the total thing" (include Clang cc in Codelite) ?
--- End quote ---
That would be my first question to Eran: If the interface allows to use both, sure. If it would mean we have to have two plugins then I would start the most promising one first.
However, literally years ago I already started working on that topic and had a C::B plugin ready that at least launched the scanning task using Eran's library. But when integrating with the UI I found myself lost because it required components that were bound to LiteEditor, which we don't have. At that time I stopped. Now I don't know well if the CC part is really de-coupled from the rest of Eran's IDE. 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...
Maybe Eran can give an insight...
oBFusCATed:
As far as I know, the llvm codebase is tailored to make integration easier.
So I don't see any reason to use another layer of abstraction/obfuscation.
I've watched a video about clangs' API and it seemed pretty easy to use.
eranif:
--- Quote ---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...
--- End quote ---
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=markup
Initializing the library is done like this:
--- Code: ---
// 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.
--- End code ---
To create an executable, you need to link against:
Debug:
--- Code: ---libCodeLiteud.dll;libwxsqlite3ud.dll
--- End code ---
Release
--- Code: ---libCodeLiteu.dll;libwxsqlite3u.dll
--- End code ---
Under linux:
--- Code: ---libcodeliteu.so;libwxsqlite3u.so
--- End code ---
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
MortenMacFly:
--- Quote from: eranif on February 07, 2012, 11:24:35 am ---I actually implemented that when creating my CC unit testing.
--- End quote ---
Thank you, Eran that's interesting to see.
--- Quote from: eranif on February 07, 2012, 11:24:35 am ---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.
--- End quote ---
Do you have a similar code snippet for creating the database or point to the direction where this is done to see what's needed?
eranif:
In the link to the source file I posted above, look at:
--- Code: ---void testRetagWorkspace()
--- End code ---
In general the steps are:
- Initialize the TagsManager
- Start the codelite_indexer
- Call TagsManagerST::Get()->RetagFiles(...);
Eran
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version